summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2019-02-23 15:23:04 +0100
committerGitHub <noreply@github.com>2019-02-23 15:23:04 +0100
commit7818585e14039e56fb279399ea0a97ee2013068d (patch)
tree91fd0352c98985277e8fed3b4f2517ae11d55b24
parentd38502167541a1cd1b505a0e468e0098e3ae7538 (diff)
parentdc767fca8ae78cf5760d3bf1d7e7150fde6c5951 (diff)
downloadcoderay-7818585e14039e56fb279399ea0a97ee2013068d.tar.gz
Merge pull request #233 from junaruga/hotfix/ruby26-expression-enumerator
Add Ruby 2.6 fixing issues
-rw-r--r--.travis.yml2
-rw-r--r--Gemfile2
-rw-r--r--lib/coderay/tokens.rb3
-rw-r--r--test/unit/filter.rb2
4 files changed, 7 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml
index 49829cd..c1fa23a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,7 @@ rvm:
- 2.3
- 2.4.2
- 2.5
+ - 2.6
- ruby-head
- jruby
branches:
@@ -20,7 +21,6 @@ before_script:
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.3"); then export RUBYOPT="--enable-frozen-string-literal"; fi; echo $RUBYOPT
matrix:
allow_failures:
- - rvm: 2.5
- rvm: ruby-head
- rvm: jruby
script: "rake test" # test:scanners"
diff --git a/Gemfile b/Gemfile
index 530c0e8..c19ac08 100644
--- a/Gemfile
+++ b/Gemfile
@@ -14,5 +14,5 @@ group :development do
gem 'shoulda-context', RUBY_VERSION < '1.9' ? '= 1.2.1' : '>= 1.2.1'
gem 'test-unit', RUBY_VERSION < '1.9' ? '~> 2.0' : '>= 3.0'
gem 'json', '>= 1.8' if RUBY_VERSION < '1.9'
- gem 'rdoc', RUBY_VERSION < '1.9' ? '~> 4.2.2' : '>= 4.2.2'
+ 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'
end
diff --git a/lib/coderay/tokens.rb b/lib/coderay/tokens.rb
index e7bffce..b5f78e7 100644
--- a/lib/coderay/tokens.rb
+++ b/lib/coderay/tokens.rb
@@ -39,6 +39,9 @@ module CodeRay
# You can serialize it to a JSON string and store it in a database, pass it
# around to encode it more than once, send it to other algorithms...
class Tokens < Array
+ # Remove Array#filter that is a new alias for Array#select on Ruby 2.6,
+ # for method_missing called with filter method.
+ undef_method :filter if instance_methods.include?(:filter)
# The Scanner instance that created the tokens.
attr_accessor :scanner
diff --git a/test/unit/filter.rb b/test/unit/filter.rb
index 25dff77..6e939f3 100644
--- a/test/unit/filter.rb
+++ b/test/unit/filter.rb
@@ -18,6 +18,7 @@ class FilterTest < Test::Unit::TestCase
tokens.text_token i.to_s, :index
end
assert_equal tokens, CodeRay::Encoders::Filter.new.encode_tokens(tokens)
+ assert_equal CodeRay::Tokens, tokens.filter.class
assert_equal tokens, tokens.filter
end
@@ -32,6 +33,7 @@ class FilterTest < Test::Unit::TestCase
tokens.end_line :index
end
assert_equal tokens, CodeRay::Encoders::Filter.new.encode_tokens(tokens)
+ assert_equal CodeRay::Tokens, tokens.filter.class
assert_equal tokens, tokens.filter
end