Ruby 2.4 Fixnum deprecation

In Ruby 2.4, Fixnum is deprecated and the following produces a warning:

$ irb
irb(main):001:0> puts RUBY_VERSION
2.4.0
=> nil
irb(main):002:0> require 'oga'
=> true
irb(main):003:0> Oga.parse_xml('<people><person>Alice</person></people>').css(':nth-child(1)')
/Users/pcheah/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/oga-2.7/lib/oga/xpath/conversion.rb:79: warning: constant ::Fixnum is deprecated
=> NodeSet(Element(name: "people" children: NodeSet(Element(name: "person" children: NodeSet(Text("Alice"))))), Element(name: "person" children: NodeSet(Text("Alice"))))
irb(main):004:0>
$

So oga/xpath/conversion.rb needs to test for Integer instead of Fixnum.

Also, it appears that json 1.8.3 no longer builds under Ruby 2.4, so the gemfile has to be upgraded to json 2.0.
This commit is contained in:
Po Shan Cheah authored and Yorick Peterse committed 2017-01-03 21:38:04 +01:00
1 parent f5370c35d2
commit c75ca96d22
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -76,7 +76,7 @@ module Oga
if value.is_a?(Float)
bool = !value.nan? && !value.zero?
elsif value.is_a?(Fixnum)
elsif value.is_a?(Integer)
bool = !value.zero?
elsif value.respond_to?(:empty?)
bool = !value.empty?