From 6928059d8e093e0a06ba61d766fcd6fa176269b2 Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Sat, 18 Jun 2022 04:23:46 -0300 Subject: [PATCH] Remove no longer required refinements Since PR #159, the minimum Ruby version is 2.5.0, a version which no longer requires refinements for String#delete_suffix?, String#match? and Regexp#match?. --- lib/csv.rb | 3 --- lib/csv/delete_suffix.rb | 18 ------------------ lib/csv/match_p.rb | 20 -------------------- lib/csv/parser.rb | 5 ----- lib/csv/writer.rb | 3 --- 5 files changed, 49 deletions(-) delete mode 100644 lib/csv/delete_suffix.rb delete mode 100644 lib/csv/match_p.rb diff --git a/lib/csv.rb b/lib/csv.rb index 31e46d91..7fe185ce 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -95,14 +95,11 @@ require_relative "csv/fields_converter" require_relative "csv/input_record_separator" -require_relative "csv/match_p" require_relative "csv/parser" require_relative "csv/row" require_relative "csv/table" require_relative "csv/writer" -using CSV::MatchP if CSV.const_defined?(:MatchP) - # == \CSV # # === In a Hurry? diff --git a/lib/csv/delete_suffix.rb b/lib/csv/delete_suffix.rb deleted file mode 100644 index d4577189..00000000 --- a/lib/csv/delete_suffix.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# This provides String#delete_suffix? for Ruby 2.4. -unless String.method_defined?(:delete_suffix) - class CSV - module DeleteSuffix - refine String do - def delete_suffix(suffix) - if end_with?(suffix) - self[0...-suffix.size] - else - self - end - end - end - end - end -end diff --git a/lib/csv/match_p.rb b/lib/csv/match_p.rb deleted file mode 100644 index 775559a3..00000000 --- a/lib/csv/match_p.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -# This provides String#match? and Regexp#match? for Ruby 2.3. -unless String.method_defined?(:match?) - class CSV - module MatchP - refine String do - def match?(pattern) - self =~ pattern - end - end - - refine Regexp do - def match?(string) - self =~ string - end - end - end - end -end diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb index 7fe5f0d3..9457ccab 100644 --- a/lib/csv/parser.rb +++ b/lib/csv/parser.rb @@ -2,15 +2,10 @@ require "strscan" -require_relative "delete_suffix" require_relative "input_record_separator" -require_relative "match_p" require_relative "row" require_relative "table" -using CSV::DeleteSuffix if CSV.const_defined?(:DeleteSuffix) -using CSV::MatchP if CSV.const_defined?(:MatchP) - class CSV # Note: Don't use this class directly. This is an internal class. class Parser diff --git a/lib/csv/writer.rb b/lib/csv/writer.rb index 4a9a35c5..8cdf96c4 100644 --- a/lib/csv/writer.rb +++ b/lib/csv/writer.rb @@ -1,11 +1,8 @@ # frozen_string_literal: true require_relative "input_record_separator" -require_relative "match_p" require_relative "row" -using CSV::MatchP if CSV.const_defined?(:MatchP) - class CSV # Note: Don't use this class directly. This is an internal class. class Writer