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

Remove ruby23 support #1440

Merged
4 commits merged into from
Jan 27, 2022
Merged
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
10 changes: 2 additions & 8 deletions cosmos.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ spec = Gem::Specification.new do |s|

# Runtime Dependencies
s.add_runtime_dependency 'bundler', '>= 1.3'
s.add_runtime_dependency 'psych', '~> 3.3'
s.add_runtime_dependency 'rdoc', '>= 4' # qtbindings doesn't parse in 6.0.0, fixed in 6.0.1
s.add_runtime_dependency 'rake', '>= 10.0' # 10.0 released Nov 12, 2012
s.add_runtime_dependency 'json', '>= 1.5', '< 3' # 2.0+ works with COSMOS
Expand All @@ -86,20 +87,13 @@ spec = Gem::Specification.new do |s|
s.add_runtime_dependency 'uuidtools', '~> 2.1'
s.add_runtime_dependency 'snmp', '~> 1.0'
s.add_runtime_dependency 'rubyzip', '~> 1.2'
s.add_runtime_dependency 'nokogiri', '~> 1.10'
s.add_runtime_dependency 'nokogiri', ['~> 1.10', '< 1.13'] # Nokogiri 1.13 doesn't support Ruby 2.5
s.add_runtime_dependency 'opengl-bindings', '~> 1.6' if RUBY_ENGINE == 'ruby' # MRI Only
s.add_runtime_dependency 'qtbindings', '~> 4.8.6', '>= 4.8.6.2' if RUBY_ENGINE == 'ruby' && !ENV['CI'] # MRI Only, not Github
s.add_runtime_dependency 'puma', '~> 3.10'
s.add_runtime_dependency 'rack', '~> 2.0'
s.add_runtime_dependency 'httpclient', '~> 2.8'

# From http://www.rubydoc.info/gems/puma#Known_Bugs :
# "For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.2.10, 2.3.4 and 2.4.1, you may see stream closed in
# another thread (IOError). It may be caused by a Ruby bug. It can be
# fixed with the gem https://rubygems.org/gems/stopgap_13632"
# This is commented out because the gemspec is only evaluated at gem build time
# s.add_runtime_dependency 'stopgap_13632', '~> 1.2.0' if RUBY_ENGINE == 'ruby' and %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION # MRI Only

# Development Dependencies
s.add_development_dependency 'diff-lcs', '~> 1.3' if RUBY_ENGINE == 'ruby' # Get latest for MRI
s.add_development_dependency 'rspec', '~> 3.5'
Expand Down
6 changes: 0 additions & 6 deletions ext/cosmos/ext/packet/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,9 @@ static VALUE received_time_equals(VALUE self, VALUE received_time) {
* received */
static VALUE received_count_equals(VALUE self, VALUE received_count) {
volatile VALUE read_conversion_cache = rb_ivar_get(self, id_ivar_read_conversion_cache);
#ifdef RUBY_INTEGER_UNIFICATION /* Ruby 2.4.0 unified Fixnum and Bignum into Integer. This check allows the code to build pre- and post-2.4.0. */
if (rb_funcall(received_count, id_method_class, 0) != rb_cInteger) {
rb_raise(rb_eArgError, "received_count must be an Integer but is a %s", RSTRING_PTR(rb_funcall(rb_funcall(received_count, id_method_class, 0), id_method_to_s, 0)));
}
#else
if ((rb_funcall(received_count, id_method_class, 0) != rb_cFixnum) && (rb_funcall(received_count, id_method_class, 0) != rb_cBignum)) {
rb_raise(rb_eArgError, "received_count must be an Integer but is a %s", RSTRING_PTR(rb_funcall(rb_funcall(received_count, id_method_class, 0), id_method_to_s, 0)));
}
#endif
rb_ivar_set(self, id_ivar_received_count, received_count);
if (RTEST(read_conversion_cache)) {
rb_funcall(read_conversion_cache, id_method_clear, 0);
Expand Down
8 changes: 0 additions & 8 deletions lib/cosmos/io/json_drb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
require 'cosmos/io/json_rpc'
require 'cosmos/io/json_drb_rack'
require 'rack/handler/puma'
if RUBY_ENGINE == 'ruby' and %w(2.2.7 2.2.8 2.2.9 2.2.10 2.3.4 2.4.1).include? RUBY_VERSION
begin
require 'stopgap_13632'
rescue Exception => err
msg = "Error loading stopgap. Make sure gem install stopgap_13632 succeeds: #{err.message}"
raise $!, msg, $!.backtrace
end
end

# Add methods to the Puma::Launcher and Puma::Single class so we can tell
# if the server has been started.
Expand Down
16 changes: 2 additions & 14 deletions lib/cosmos/packets/packet_item_limits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,12 @@ def response=(response)
end

def persistence_setting=(persistence_setting)
if 0.class == Integer
# Ruby version >= 2.4.0
raise ArgumentError, "persistence_setting must be an Integer but is a #{persistence_setting.class}" unless Integer === persistence_setting
else
# Ruby version < 2.4.0
raise ArgumentError, "persistence_setting must be a Fixnum but is a #{persistence_setting.class}" unless Fixnum === persistence_setting
end
raise ArgumentError, "persistence_setting must be an Integer but is a #{persistence_setting.class}" unless Integer === persistence_setting
@persistence_setting = persistence_setting
end

def persistence_count=(persistence_count)
if 0.class == Integer
# Ruby version >= 2.4.0
raise ArgumentError, "persistence_count must be an Integer but is a #{persistence_count.class}" unless Integer === persistence_count
else
# Ruby version < 2.4.0
raise ArgumentError, "persistence_count must be a Fixnum but is a #{persistence_count.class}" unless Fixnum === persistence_count
end
raise ArgumentError, "persistence_count must be an Integer but is a #{persistence_count.class}" unless Integer === persistence_count
@persistence_count = persistence_count
end

Expand Down
25 changes: 4 additions & 21 deletions lib/cosmos/packets/structure_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,7 @@ def endianness=(endianness)
end

def bit_offset=(bit_offset)
if 0.class == Integer
# Ruby version >= 2.4.0
raise ArgumentError, "#{@name}: bit_offset must be an Integer" unless Integer === bit_offset
else
# Ruby version < 2.4.0
raise ArgumentError, "#{@name}: bit_offset must be a Fixnum" unless Fixnum === bit_offset
end
raise ArgumentError, "#{@name}: bit_offset must be an Integer" unless Integer === bit_offset

byte_aligned = ((bit_offset % 8) == 0)
if (@data_type == :FLOAT or @data_type == :STRING or @data_type == :BLOCK) and !byte_aligned
Expand All @@ -133,13 +127,8 @@ def bit_offset=(bit_offset)
end

def bit_size=(bit_size)
if 0.class == Integer
# Ruby version >= 2.4.0
raise ArgumentError, "#{name}: bit_size must be an Integer" unless Integer === bit_size
else
# Ruby version < 2.4.0
raise ArgumentError, "#{name}: bit_size must be a Fixnum" unless Fixnum === bit_size
end
raise ArgumentError, "#{name}: bit_size must be an Integer" unless Integer === bit_size

byte_multiple = ((bit_size % 8) == 0)
if bit_size <= 0 and (@data_type == :INT or @data_type == :UINT or @data_type == :FLOAT)
raise ArgumentError, "#{@name}: bit_size cannot be negative or zero for :INT, :UINT, and :FLOAT items: #{bit_size}"
Expand Down Expand Up @@ -171,13 +160,7 @@ def data_type=(data_type)

def array_size=(array_size)
if array_size
if 0.class == Integer
# Ruby version >= 2.4.0
raise ArgumentError, "#{@name}: array_size must be an Integer" unless Integer === array_size
else
# Ruby version < 2.4.0
raise ArgumentError, "#{@name}: array_size must be a Fixnum" unless Fixnum === array_size
end
raise ArgumentError, "#{@name}: array_size must be an Integer" unless Integer === array_size
raise ArgumentError, "#{@name}: array_size must be a multiple of bit_size" unless (@bit_size == 0 or (array_size % @bit_size == 0) or array_size < 0)
raise ArgumentError, "#{@name}: bit_size cannot be negative or zero for array items" if @bit_size <= 0
end
Expand Down
2 changes: 1 addition & 1 deletion make_gems.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# export VERSION= before running this
git checkout master
git pull
rbenv global 2.4.4
rbenv global 2.5.9
rake release VERSION=$VERSION
rake commit_release VERSION=$VERSION
mv *.gem ~/share/.
Expand Down
39 changes: 6 additions & 33 deletions spec/packets/packet_item_limits_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,11 @@ module Cosmos
end

it "complains about persistence_setting = nil" do
if 0.class == Integer
# Ruby version >= 2.4.0
expect { @l.persistence_setting = nil}.to raise_error(ArgumentError, "persistence_setting must be an Integer but is a NilClass")
else
# Ruby version < 2.4.0
expect { @l.persistence_setting = nil}.to raise_error(ArgumentError, "persistence_setting must be a Fixnum but is a NilClass")
end
expect { @l.persistence_setting = nil}.to raise_error(ArgumentError, "persistence_setting must be an Integer but is a NilClass")
end

if 0.class == Integer
# Ruby version >= 2.4.0
it "complains about persistence_setting that aren't Integer" do
expect { @l.persistence_setting = 5.5}.to raise_error(ArgumentError, "persistence_setting must be an Integer but is a Float")
end
else
# Ruby version < 2.4.0
it "complains about persistence_setting that aren't Fixnum" do
expect { @l.persistence_setting = 5.5}.to raise_error(ArgumentError, "persistence_setting must be a Fixnum but is a Float")
end
it "complains about persistence_setting that aren't Integer" do
expect { @l.persistence_setting = 5.5}.to raise_error(ArgumentError, "persistence_setting must be an Integer but is a Float")
end
end

Expand All @@ -114,24 +100,11 @@ module Cosmos
end

it "complains about persistence_count = nil" do
if 0.class == Integer
# Ruby version >= 2.4.0
expect { @l.persistence_count = nil}.to raise_error(ArgumentError, "persistence_count must be an Integer but is a NilClass")
else
# Ruby version < 2.4.0
expect { @l.persistence_count = nil}.to raise_error(ArgumentError, "persistence_count must be a Fixnum but is a NilClass")
end
expect { @l.persistence_count = nil}.to raise_error(ArgumentError, "persistence_count must be an Integer but is a NilClass")
end

if 0.class == Integer
it "complains about persistence_count that aren't Integer" do
expect { @l.persistence_count = 5.5}.to raise_error(ArgumentError, "persistence_count must be an Integer but is a Float")
end
else
# Ruby version < 2.4.0
it "complains about persistence_count that aren't Fixnum" do
expect { @l.persistence_count = 5.5}.to raise_error(ArgumentError, "persistence_count must be a Fixnum but is a Float")
end
it "complains about persistence_count that aren't Integer" do
expect { @l.persistence_count = 5.5}.to raise_error(ArgumentError, "persistence_count must be an Integer but is a Float")
end
end

Expand Down
24 changes: 3 additions & 21 deletions spec/packets/structure_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ module Cosmos

describe "bit_offset=" do
it "compains about bad bit offsets types" do
if 0.class == Integer
# Ruby version >= 2.4.0
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be an Integer")
else
# Ruby version < 2.4.0
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be a Fixnum")
end
expect { StructureItem.new("test", nil, 8, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_offset must be an Integer")
end

it "complains about unaligned bit offsets" do
Expand All @@ -91,13 +85,7 @@ module Cosmos

describe "bit_size=" do
it "complains about bad bit sizes types" do
if 0.class == Integer
# Ruby version >= 2.4.0
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be an Integer")
else
# Ruby version < 2.4.0
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be a Fixnum")
end
expect { StructureItem.new("test", 0, nil, :UINT, :BIG_ENDIAN, nil) }.to raise_error(ArgumentError, "TEST: bit_size must be an Integer")
end

it "complains about 0 size INT, UINT, and FLOAT" do
Expand All @@ -122,13 +110,7 @@ module Cosmos

describe "array_size=" do
it "complains about bad array size types" do
if 0.class == Integer
# Ruby version >= 2.4.0
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be an Integer")
else
# Ruby version < 2.4.0
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be a Fixnum")
end
expect { StructureItem.new("test", 0, 8, :UINT, :BIG_ENDIAN, "") }.to raise_error(ArgumentError, "TEST: array_size must be an Integer")
end

it "complains about array size != multiple of bit size" do
Expand Down