Skip to content

Commit

Permalink
Merge pull request #34 from tom-lord/unicode_pstore_by_unicode_version
Browse files Browse the repository at this point in the history
Define unicode pstore files by unicode version, not ruby version
  • Loading branch information
tom-lord authored Jun 28, 2019
2 parents 9022973 + b801503 commit 412920b
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 27 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.3
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
language: ruby
rvm:
- 2.0.0
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
- 2.5.5
- 2.6.2
- 2.6.2 # Uses unicode 12.0.0
- 2.6.3 # Uses unicode 12.1.0
- ruby-head
matrix:
allow_failures:
Expand Down
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,18 @@ Obviously, you will get different (random) results if you try these yourself!
```

## Supported ruby versions
* MRI 2.0.x
* MRI 2.1.x
* MRI 2.2.x
* MRI 2.3.x
* MRI 2.4.x
* MRI 2.5.x
* MRI 2.6.x

MRI ≤ 1.9.3 are not supported. This is primarily because MRI 2.0.0 introduced a new
regexp engine (`Oniguruma` was replaced by `Onigmo`). Whilst *most* of this gem could
be made to work with MRI 1.9.x (or even 1.8.x), I feel the changes are too significant
to implement backwards compatability (especially since [long-term support for MRI
1.9.3 has now ended](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/)).

For example, named properties (e.g. `/\p{Alpha}/`) are illegal syntax on MRI 1.9.3.
MRI 2.4.0 (oldest non-[EOL](https://www.ruby-lang.org/en/news/2019/03/31/support-of-ruby-2-3-has-ended/) version) --> 2.6.3 (latest stable version)

MRI 2.0.0 --> 2.3.x were supported until version `1.5.0` of this library. Support was dropped primarily
because of the need to use `RbConfig::CONFIG['UNICODE_VERSION']`, which was added to ruby version `2.4.0`.

MRI versions ≤ 1.9.3 were never supported by this library. This is primarily because MRI 2.0.0 introduced a new
regexp engine (`Oniguruma` was replaced by `Onigmo` -- For example, named properties like `/\p{Alpha}/`
are illegal syntax on MRI 1.9.3.). Whilst *most* of this gem could be made to work with MRI 1.9.x
(or even 1.8.x), I considered the changes too significant to implement backwards compatability
(especially since [long-term support for MRI 1.9.3 has long
ended](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/)).


Other implementations, such as JRuby, could probably work fine -
but I haven't fully tried/tested it. Pull requests are welcome.
Expand Down
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file removed db/unicode_ranges_2.0.pstore
Binary file not shown.
File renamed without changes.
7 changes: 4 additions & 3 deletions lib/regexp-examples/unicode_char_ranges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class UnicodeCharRanges
# These values were generated by: scripts/unicode_lister.rb
# Note: Only the first 128 results are listed, for performance.
# Also, some groups seem to have no matches (weird!)
# (Don't care about ruby micro version number)
STORE_FILENAME = "unicode_ranges_#{RUBY_VERSION[0..2]}.pstore".freeze
STORE_FILENAME = "unicode_ranges_#{RbConfig::CONFIG['UNICODE_VERSION']}.pstore".freeze

attr_reader :range_store

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

private

# The method is written like this to future-proof it a little,
# i.e. the gem won't completely break for a new ruby version release
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"
file <= "#{db_path}/#{STORE_FILENAME}"
end.last
end

Expand Down
2 changes: 1 addition & 1 deletion lib/regexp-examples/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gem version
module RegexpExamples
VERSION = '1.4.4'.freeze
VERSION = '1.5.0'.freeze
end
6 changes: 3 additions & 3 deletions regexp-examples.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']
s.homepage =
'http://rubygems.org/gems/regexp-examples'
s.add_development_dependency 'bundler', '~> 1.7'
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'bundler'
s.add_development_dependency 'rake', '~> 12.0'
s.license = 'MIT'
s.required_ruby_version = '>= 2.0.0'
s.required_ruby_version = '>= 2.4.0'
end

0 comments on commit 412920b

Please sign in to comment.