fastruby / next_rails

A toolkit to upgrade your next Rails application
https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html?utm_source=github&utm_medium=description&utm_campaign=github&utm_term=next-rails
MIT License
466 stars 28 forks source link

Next method #97

Closed etagwerker closed 1 year ago

etagwerker commented 1 year ago

Description

This PR introduces a new method to be used in your application code:

if NextRails.next?
  # do something with the next version of Ruby/Rails
else
  # do the same you were doing with the current version of Ruby/Rails
end

Please check it out and let me know what you think.

Thanks!

Motivation and Context

How Has This Been Tested?

Screenshots:

I will abide by the code of conduct

arielj commented 1 year ago

I wonder if it would be better to make it a module attribute instead of a method, like @@next? = ENV["BUNDLE_GEMFILE"] == "Gemfile.next", so then the true/false value is stored/memoized when the gem loads and we don't need to do a method call and the comparison every time.

etagwerker commented 1 year ago

@arielj Good idea. Memoizing is not so straightforward in a module, so I had to add another method.

Please check it out and let me know what you think. Thanks!

arielj commented 1 year ago

I'm merging this since it has all the feedback addressed and it's up to date with main

I also tested and it shows the correct value with and without bundle exec