Skip to content

Commit ecc46d2

Browse files
committed
Use unicode version instead of ruby version
1 parent a6755a4 commit ecc46d2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/regexp-examples/unicode_char_ranges.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class UnicodeCharRanges
1111
# These values were generated by: scripts/unicode_lister.rb
1212
# Note: Only the first 128 results are listed, for performance.
1313
# Also, some groups seem to have no matches (weird!)
14-
# (Don't care about ruby micro version number)
15-
STORE_FILENAME = "unicode_ranges_#{RUBY_VERSION[0..2]}.pstore".freeze
14+
STORE_FILENAME = "unicode_ranges_#{RbConfig::CONFIG['UNICODE_VERSION']}.pstore".freeze
1615

1716
attr_reader :range_store
1817

@@ -30,10 +29,12 @@ def get(key)
3029

3130
private
3231

32+
# The method is written like this to future-proof it a little,
33+
# i.e. the gem won't completely break for a new ruby version release
3334
def unicode_ranges_file
3435
db_path = File.join(__dir__, '../../db')
3536
Dir["#{db_path}/*.pstore"].sort.select do |file|
36-
file <= "#{db_path}/unicode_ranges_#{RUBY_VERSION[0..2]}.pstore"
37+
file <= "#{db_path}/#{STORE_FILENAME}"
3738
end.last
3839
end
3940

0 commit comments

Comments
 (0)