diff --git a/cosmos.gemspec b/cosmos.gemspec index f97f74601..06f291f21 100644 --- a/cosmos.gemspec +++ b/cosmos.gemspec @@ -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 @@ -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' diff --git a/ext/cosmos/ext/packet/packet.c b/ext/cosmos/ext/packet/packet.c index e54d8c9b2..e635b5863 100644 --- a/ext/cosmos/ext/packet/packet.c +++ b/ext/cosmos/ext/packet/packet.c @@ -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); diff --git a/lib/cosmos/io/json_drb.rb b/lib/cosmos/io/json_drb.rb index 840c25343..7ec1c1208 100644 --- a/lib/cosmos/io/json_drb.rb +++ b/lib/cosmos/io/json_drb.rb @@ -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. diff --git a/lib/cosmos/packets/packet_item_limits.rb b/lib/cosmos/packets/packet_item_limits.rb index 0bbfd9841..292f23c13 100644 --- a/lib/cosmos/packets/packet_item_limits.rb +++ b/lib/cosmos/packets/packet_item_limits.rb @@ -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 diff --git a/lib/cosmos/packets/structure_item.rb b/lib/cosmos/packets/structure_item.rb index 3929917c2..793bac072 100644 --- a/lib/cosmos/packets/structure_item.rb +++ b/lib/cosmos/packets/structure_item.rb @@ -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 @@ -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}" @@ -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 diff --git a/make_gems.sh b/make_gems.sh index fc3796980..f76194208 100755 --- a/make_gems.sh +++ b/make_gems.sh @@ -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/. diff --git a/spec/packets/packet_item_limits_spec.rb b/spec/packets/packet_item_limits_spec.rb index 4773b8a75..968adc351 100644 --- a/spec/packets/packet_item_limits_spec.rb +++ b/spec/packets/packet_item_limits_spec.rb @@ -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 @@ -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 diff --git a/spec/packets/structure_item_spec.rb b/spec/packets/structure_item_spec.rb index 94d633d38..4efe97465 100644 --- a/spec/packets/structure_item_spec.rb +++ b/spec/packets/structure_item_spec.rb @@ -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 @@ -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 @@ -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