Skip to content

Commit 7818585

Browse files
authored
Merge pull request #233 from junaruga/hotfix/ruby26-expression-enumerator
Add Ruby 2.6 fixing issues
2 parents d385021 + dc767fc commit 7818585

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ rvm:
1111
- 2.3
1212
- 2.4.2
1313
- 2.5
14+
- 2.6
1415
- ruby-head
1516
- jruby
1617
branches:
@@ -20,7 +21,6 @@ before_script:
2021
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.3"); then export RUBYOPT="--enable-frozen-string-literal"; fi; echo $RUBYOPT
2122
matrix:
2223
allow_failures:
23-
- rvm: 2.5
2424
- rvm: ruby-head
2525
- rvm: jruby
2626
script: "rake test" # test:scanners"

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ group :development do
1414
gem 'shoulda-context', RUBY_VERSION < '1.9' ? '= 1.2.1' : '>= 1.2.1'
1515
gem 'test-unit', RUBY_VERSION < '1.9' ? '~> 2.0' : '>= 3.0'
1616
gem 'json', '>= 1.8' if RUBY_VERSION < '1.9'
17-
gem 'rdoc', RUBY_VERSION < '1.9' ? '~> 4.2.2' : '>= 4.2.2'
17+
gem 'rdoc', Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9.3') ? '~> 4.2.2' : Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.2.2') ? '< 6' : '>= 6'
1818
end

lib/coderay/tokens.rb

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ module CodeRay
3939
# You can serialize it to a JSON string and store it in a database, pass it
4040
# around to encode it more than once, send it to other algorithms...
4141
class Tokens < Array
42+
# Remove Array#filter that is a new alias for Array#select on Ruby 2.6,
43+
# for method_missing called with filter method.
44+
undef_method :filter if instance_methods.include?(:filter)
4245

4346
# The Scanner instance that created the tokens.
4447
attr_accessor :scanner

test/unit/filter.rb

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def test_filtering_text_tokens
1818
tokens.text_token i.to_s, :index
1919
end
2020
assert_equal tokens, CodeRay::Encoders::Filter.new.encode_tokens(tokens)
21+
assert_equal CodeRay::Tokens, tokens.filter.class
2122
assert_equal tokens, tokens.filter
2223
end
2324

@@ -32,6 +33,7 @@ def test_filtering_block_tokens
3233
tokens.end_line :index
3334
end
3435
assert_equal tokens, CodeRay::Encoders::Filter.new.encode_tokens(tokens)
36+
assert_equal CodeRay::Tokens, tokens.filter.class
3537
assert_equal tokens, tokens.filter
3638
end
3739

0 commit comments

Comments
 (0)