Skip to content

Commit

Permalink
Add Ruby 2.6 fixing issues
Browse files Browse the repository at this point in the history
* Remove existing Tokens#filter (Array#filter) for Ruby 2.6 compatibility.
* Install proper version's rdoc considering installed Ruby version.
  • Loading branch information
junaruga committed Feb 14, 2019
1 parent d385021 commit dc767fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,6 +11,7 @@ rvm:
- 2.3
- 2.4.2
- 2.5
- 2.6
- ruby-head
- jruby
branches:
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -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
3 changes: 3 additions & 0 deletions lib/coderay/tokens.rb
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/unit/filter.rb
Expand Up @@ -18,6 +18,7 @@ def test_filtering_text_tokens
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

Expand All @@ -32,6 +33,7 @@ def test_filtering_block_tokens
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

Expand Down

0 comments on commit dc767fc

Please sign in to comment.