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

Use Integer class for checking integer instead of Fixnum #62

Merged
merged 3 commits into from
Feb 10, 2017

Conversation

makimoto
Copy link
Contributor

Since Fixnum and Bignum are unfied into Integer in Ruby 2.4+, a warning
occurs for using Fixnum (or Bignum).

Since Fixnum and Bignum are unfied into Integer in Ruby 2.4+, a warning
occurs for using Fixnum (or Bignum).
json 1.8.3 cannot be build with Ruby 2.4
@makimoto
Copy link
Contributor Author

Oops... json 1.8.3 is failed with ruby 2.4. I updated json to 2.0.3 in ddfb982.
Btw Gemfile.lock is unnecessary for gem packages, so we can remove it probably.

@lfittl how do you think?

@@ -22,7 +22,7 @@ def from(item)

def deparse_item(item, context = nil) # rubocop:disable Metrics/CyclomaticComplexity
return if item.nil?
return item if item.is_a?(Fixnum)
return item if item.is_a?(Integer)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a version-check for the Ruby version here?

(this might not be tested by the test suite right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this works with any version rubies.

  • In ruby 2.3.x or older, Integer class is an ancestor of Fixnum and Bignum.
  • In ruby 2.4+, all integers are Integer class.

So item.is_a?(Integer) works in both cases.
Supporting Bignum in older rubies is a difference, but it may work as intended.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yes, you are indeed correct!

@lfittl
Copy link
Member

lfittl commented Feb 10, 2017

@makimoto I think updating it in the Gemfile.lock is fine. You are correct that we don't necessarily need that in a library, but its useful to have the tests run with predictable versions.

@makimoto
Copy link
Contributor Author

Gemfile.lock

OK. I got it.

@lfittl lfittl merged commit fc5d01c into pganalyze:master Feb 10, 2017
@lfittl
Copy link
Member

lfittl commented Feb 10, 2017

@makimoto Merged - thanks for your contribution!

@makimoto makimoto deleted the unified-integer branch February 11, 2017 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants