diff --git a/.gitignore b/.gitignore index 887ce84..18cfc0a 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.so *.o *.a +.*.sw? mkmf.log tags /coverage/ diff --git a/db/unicode_ranges_2.1.pstore b/db/unicode_ranges_2.1.pstore deleted file mode 120000 index 6cfebc2..0000000 --- a/db/unicode_ranges_2.1.pstore +++ /dev/null @@ -1 +0,0 @@ -unicode_ranges_2.0.pstore \ No newline at end of file diff --git a/lib/regexp-examples/helpers.rb b/lib/regexp-examples/helpers.rb index f2edc09..e80fd3d 100644 --- a/lib/regexp-examples/helpers.rb +++ b/lib/regexp-examples/helpers.rb @@ -19,7 +19,8 @@ def self.permutations_of_strings(arrays_of_strings, max_results_limiter = MaxRes end def self.join_preserving_capture_groups(result) - # Only save the LAST group from repeated capture groups, e.g. /([ab]){2}/ + # Only save the LAST group from repeated capture groups, because + # e.g. /([ab]){2} \1/.examples should NOT include "ab a" # (Hence the need for "reverse"!) subgroups = result .flat_map(&:all_subgroups) diff --git a/lib/regexp-examples/unicode_char_ranges.rb b/lib/regexp-examples/unicode_char_ranges.rb index 31e9c28..7daaec0 100644 --- a/lib/regexp-examples/unicode_char_ranges.rb +++ b/lib/regexp-examples/unicode_char_ranges.rb @@ -14,8 +14,8 @@ class UnicodeCharRanges attr_reader :range_store - def initialize(filename = STORE_FILENAME) - @range_store = PStore.new(File.expand_path("../../../db/#{filename}", __FILE__)) + def initialize + @range_store = PStore.new(unicode_ranges_file) end def get(key) @@ -28,6 +28,13 @@ def get(key) private + def unicode_ranges_file + db_path = File.join(__dir__, '../../db') + Dir["#{db_path}/*.pstore"].sort.select do |file| + file <= "#{db_path}/unicode_ranges_#{RUBY_VERSION[0..2]}.pstore" + end.last + end + # TODO: Document example input/output of this method # It's pretty simple, but this code is a little confusing!! def ranges_to_unicode(ranges) diff --git a/lib/regexp-examples/version.rb b/lib/regexp-examples/version.rb index 456477d..4faeac9 100644 --- a/lib/regexp-examples/version.rb +++ b/lib/regexp-examples/version.rb @@ -1,4 +1,4 @@ # Gem version module RegexpExamples - VERSION = '1.2.1' + VERSION = '1.3.0' end