Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruby 3.x support #278

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ language: ruby
script: bundle exec rake rspec
bundler_args: --without development docs
rvm:
- 2.2.4
- 2.3.0
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- 3.1
- 3.2
- 3.3
- jruby-9.0.5.0
jdk:
- openjdk8
Expand All @@ -24,7 +27,16 @@ before_install: |
# Install bundler < 2.0, see https://docs.travis-ci.com/user/languages/ruby/
gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
gem install bundler -v '< 2'

RUBY_MAJOR=$(echo "$TRAVIS_RUBY_VERSION" | cut -d. -f1)
RUBY_MINOR=$(echo "$TRAVIS_RUBY_VERSION" | cut -d. -f2)
if [[ k$TRAVIS_RUBY_VERSION = kjruby* ]] ; then
# Hack the Gemfile.lock file to indicate we're a JRuby gem, to make bundler happy.
sed -e 's/\(cassandra-driver [^)]*\)/\1-java/' -i"" Gemfile.lock
elif (( $RUBY_MAJOR >= 3 && $RUBY_MINOR >= 2)); then
# Hack the Gemfile.lock, bundler 1.x does not work with Ruby 3.2+
sed -e 's/ 1\.17\.3/ 2.5.9/g' -i"" Gemfile.lock
sed -e 's/bundler (~> 1\.6)/bundler (~> 2.5)/g' -i"" Gemfile.lock
# Hack the gemspec, bundler 1.x does not work with Ruby 3.2+
sed -e "s/'bundler', '~> 1\.6'/'bundler', '~> 2.5'/g" -i"" cassandra-driver.gemspec
fi
20 changes: 13 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ GEM
delorean (2.1.0)
chronic
diff-lcs (1.2.5)
docile (1.1.5)
docile (1.3.5)
ffi (1.9.25)
ffi (1.9.25-java)
gherkin (3.2.0)
ione (1.2.4)
json (1.8.6)
json (1.8.6-java)
json (2.7.2)
json (2.7.2-java)
lz4-ruby (0.3.3)
lz4-ruby (0.3.3-java)
minitest (4.7.5)
Expand All @@ -59,6 +59,7 @@ GEM
rake (13.0.1)
rake-compiler (0.9.5)
rake
rbtree (0.4.6)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -84,16 +85,21 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
simplecov (0.11.2)
docile (~> 1.1.0)
json (~> 1.8)
set (1.1.0)
simplecov (0.17.1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bumped simplecov because the underlying json version for the previous version is not compatible with ruby 3.x

docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
simplecov-html (0.10.2)
snappy (0.0.14)
snappy (0.0.14-java)
snappy-jars (~> 1.1.0)
snappy-jars (1.1.0.1.2-java)
thor (0.19.1)
sorted_set (1.0.3)
rbtree
set (~> 1.0)
sorted_set (1.0.3-java)
unicode-display_width (1.3.0)
yard (0.9.20)

Expand Down
3 changes: 2 additions & 1 deletion cassandra-driver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = ['README.md']
s.rdoc_options << '--title' << 'Datastax Ruby Driver' << '--main' << 'README.md' << '--line-numbers'

s.required_ruby_version = '>= 2.2.0'
s.required_ruby_version = '>= 2.3.0'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted_set requires ruby 2.3. I've seen libraries not consider bumps in minimum ruby versions breaking changes when the dropped ruby version(s) is passed EOL so I'll defer here to the maintainers w.r.t versioning.


if defined?(JRUBY_VERSION)
s.platform = 'java'
Expand All @@ -31,6 +31,7 @@ Gem::Specification.new do |s|
end

s.add_runtime_dependency 'ione', '~> 1.2'
s.add_runtime_dependency 'sorted_set', '~> 1.0'

s.add_development_dependency 'bundler', '~> 1.6'
s.add_development_dependency 'rake', '~> 13.0'
Expand Down
10 changes: 8 additions & 2 deletions spec/cassandra/protocol/coder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ module Protocol

describe('RUBY-128') do
it 'reads very large short strings and string' do
column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml"))
buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml"))
# https://bugs.ruby-lang.org/issues/17866
if RUBY_VERSION >= "3.1"
column_specs = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/cols.yml"))
buffer = ::YAML::unsafe_load(::File.open(::File.dirname(__FILE__) + "/buffer.yml"))
else
column_specs = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/cols.yml"))
buffer = ::YAML::load(::File.open(::File.dirname(__FILE__) + "/buffer.yml"))
end

Coder.read_values_v1(buffer, column_specs)
end
Expand Down