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

Replace Fixnum and Bignum with Integer #132

Merged
merged 1 commit into from
Apr 10, 2017
Merged

Replace Fixnum and Bignum with Integer #132

merged 1 commit into from
Apr 10, 2017

Conversation

mcasper
Copy link
Contributor

@mcasper mcasper commented Apr 6, 2017

Ruby 2.4 deprecated the use of both Fixnum and Bignum, instead
encouraging everyone to just use Integer, which is their superclass.

So, we can replace all instances of the two deprecated classes with just
Integer, silencing the warnings from this library when on Ruby 2.4.X.

It looks like this exact change has been opened twice, and then immediately closed out by the owners? Is there a reason for this?

https://bugs.ruby-lang.org/issues/12005

@coveralls
Copy link

coveralls commented Apr 6, 2017

Coverage Status

Coverage decreased (-0.8%) to 98.171% when pulling ca8fe8d on mcasper:ruby-2-4-warnings into a55e8e2 on brooklynDev:master.

@coveralls
Copy link

coveralls commented Apr 8, 2017

Coverage Status

Coverage increased (+0.004%) to 98.975% when pulling 3e5e598 on mcasper:ruby-2-4-warnings into a55e8e2 on brooklynDev:master.

@sethpollack
Copy link
Collaborator

Thanks for the PR, can you move the logic to a function and use if Integer == Fixnum instead of if RUBY_VERSION.match(/^2.4/)

@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Hey @sethpollack! Happy to move it to a method, but won't using if Integer == Fixnum still cause the deprecation warning, since Fixnum will get evaluated in the Ruby 2.4 case?

@sethpollack
Copy link
Collaborator

I found the fix in rails, also I tested it and it works.

@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Right, it works, but it still emits a deprecation warning. If you look at Rails master, you'll see they changed it to if 0.class == Integer

@coveralls
Copy link

coveralls commented Apr 10, 2017

Coverage Status

Coverage increased (+0.007%) to 98.978% when pulling d86735f on mcasper:ruby-2-4-warnings into a55e8e2 on brooklynDev:master.

Ruby 2.4 deprecated the use of both Fixnum and Bignum, instead
encouraging everyone to just use Integer, which is their superclass.

So, we can replace all instances of the two deprecated classes with just
Integer, silencing the warnings from this library when on Ruby 2.4.X.

https://bugs.ruby-lang.org/issues/12005
@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Updated this to use if 0.class == Integer. (0's class is Fixnum prior to Ruby 2.4.0)

@coveralls
Copy link

coveralls commented Apr 10, 2017

Coverage Status

Coverage increased (+0.005%) to 98.976% when pulling eef7105 on mcasper:ruby-2-4-warnings into a55e8e2 on brooklynDev:master.

@sethpollack
Copy link
Collaborator

Ok so lets go with 0.class == Integer

@sethpollack
Copy link
Collaborator

Perfect thanks!

@sethpollack sethpollack merged commit 46050a4 into brooklynDev:master Apr 10, 2017
@mcasper mcasper deleted the ruby-2-4-warnings branch April 10, 2017 04:21
@sethpollack
Copy link
Collaborator

Ok published the new version

@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Awesome, thanks!

@sethpollack
Copy link
Collaborator

@mcasper
What do you think about using any?{|type| value.is_a?(type) instead. Then you can just use Integer and would never need Bignum/Fixnum.

@sethpollack
Copy link
Collaborator

I can push up the changes, just wanted to hear your thoughts?

@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Hmm, but don't we need to keep Fixnum and Bignum around so we don't break Ruby 2.3 and lower functionality? If we can remove Fixnum and Bignum functionality from the lower versions, then let's just remove all this checking and put Integer everywhere

@sethpollack
Copy link
Collaborator

No in the lower versions Integer is the superclass of Fixnum and Bignum. For example:

> Fixnum.superclass
 => Integer

> 1.class
 => Fixnum

> 1.is_a?(Integer)
 => true

So I'm suggesting only using Integer and just changing the expect_type logic to use is_a? instead of comparing the classes.

@sethpollack
Copy link
Collaborator

Ok, I pushed up the changes.

@mcasper
Copy link
Contributor Author

mcasper commented Apr 10, 2017

Ohhh sorry, I see what you mean now. Looks great!

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.

3 participants