next_rails 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57c4fac0e45a33071dcb6df1938840ba6854ab1ccc4dd7782e365568e91f17c5
4
- data.tar.gz: 10e5be9d8d4bbfa9dfc7b2dd04905d1c47a76f600be53a8a7f61d25ca3628589
3
+ metadata.gz: 7c7f594ed23846772d59319982c2e1b866b2ba2aeea221e9f276b876d1bfa6a5
4
+ data.tar.gz: 9f197cf8c84806932c34b5efe31467dab0b58d53408252ce7db193e6547486b2
5
5
  SHA512:
6
- metadata.gz: 3377c0643a78dda0406d386adfbc4c749f507a2d000d13f84b6ee13cd9e3bab79cbebea75efb56e6e94c936a2794e77eda0aca4e684dd025ec1fa4c91c4a2c33
7
- data.tar.gz: 355383fd6dc9ec1f726ec2c2bf43b4bf9b0b289dd2ee2d7e321e87deff18d86f8f9eb6469e694d40797a676a1e3935ce1712b208e153f6857b447be26807138e
6
+ metadata.gz: 9608a14f3d6ec0dd9b939d52b6b94c3670d4ad8a9a4d4ffc70b2b4f459b5545fa762da0a74f0782efd58ec25f293671cc5039e90f2425e7e7d8570e68f4ad7ba
7
+ data.tar.gz: 5f3de5c08c617fd74c78d517480cd04747cbf2ac22a6e4348005dae32ba387596f5a74b4ac2b31a6489fedd3d267213432ec94a000ad5cd0162c99b22e4d90c0
@@ -13,7 +13,23 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: [3.2, 3.1, 3.0, 2.7, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0.0]
16
+ ruby-version: [3.2, 3.1, 3.0, 2.7, 2.6, 2.5, 2.4, 2.3]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true
25
+ - name: Run rake task
26
+ run: bundle exec rake
27
+
28
+ test_older:
29
+ runs-on: ubuntu-20.04
30
+ strategy:
31
+ matrix:
32
+ ruby-version: [2.2, 2.1, 2.0.0]
17
33
 
18
34
  steps:
19
35
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
- # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.2.3...main)
1
+ # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.3.0...main)
2
+
2
3
  * Your changes/patches go here.
3
4
 
5
+ # v1.3.0 / 2023-06-16 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.4...v1.3.0)
6
+
7
+ - [FEATURE: Add NextRails.next? for application usage (e.g. Rails shims)](https://github.com/fastruby/next_rails/pull/97)
8
+ - [BUGFIX: Support ERB versions older than 2.2.0](https://github.com/fastruby/next_rails/pull/100)
9
+
10
+ # v1.2.4 / 2023-04-21 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.3...v1.2.4)
11
+
12
+ - [BUGFIX: Update the warn method signature to support for Ruby 3]
13
+
4
14
  # v1.2.3 / 2023-04-12 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.2...v1.2.3)
5
15
 
6
16
  - [Fix ERB deprecation warning in Ruby 3.1]
data/README.md CHANGED
@@ -45,6 +45,26 @@ bundle_report --help
45
45
  bundle_report ruby_check --rails-version=7.0.0
46
46
  ```
47
47
 
48
+ ### Application usage
49
+
50
+ Every now and then it will be necessary to add code like this to your
51
+ application:
52
+
53
+ ```ruby
54
+ if NextRails.next?
55
+ # Do things "the Rails 7 way"
56
+ else
57
+ # Do things "the Rails 6.1 way"
58
+ end
59
+ ```
60
+
61
+ The `NextRails.next?` method will use your environment
62
+ (e.g. `ENV['BUNDLE_GEMFILE]`) to determine whether your application is
63
+ running with the next set of dependencies or the current set of dependencies.
64
+
65
+ This might come in handy if you need to inject
66
+ [Ruby or Rails shims](https://www.fastruby.io/blog/rails/upgrades/rails-upgrade-shims.html).
67
+
48
68
  ### Deprecation tracking
49
69
 
50
70
  If you're using RSpec, add this snippet to `rails_helper.rb` or `spec_helper.rb` (whichever loads Rails).
@@ -18,13 +18,15 @@ class DeprecationTracker
18
18
  @callbacks ||= []
19
19
  end
20
20
 
21
- def warn(*messages, uplevel: nil)
21
+ def warn(*messages, uplevel: nil, category: nil)
22
22
  KernelWarnTracker.callbacks.each do |callback|
23
23
  messages.each { |message| callback.(message) }
24
24
  end
25
25
 
26
26
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5.0")
27
- super *messages
27
+ super(*messages)
28
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0")
29
+ super(*messages, uplevel: nil)
28
30
  else
29
31
  super
30
32
  end
@@ -17,6 +17,10 @@ module NextRails
17
17
 
18
18
  incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) }
19
19
 
20
+ puts erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
21
+ end
22
+
23
+ def erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
20
24
  template = <<-ERB
21
25
  <% if incompatible_gems_by_state[:found_compatible] -%>
22
26
  <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %>
@@ -49,7 +53,16 @@ module NextRails
49
53
  <%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %>
50
54
  ERB
51
55
 
52
- puts ERB.new(template, trim_mode: "-").result(binding)
56
+ erb_version = ERB.version
57
+ if erb_version =~ /erb.rb \[([\d\.]+) .*\]/
58
+ erb_version = $1
59
+ end
60
+
61
+ if Gem::Version.new(erb_version) < Gem::Version.new("2.2")
62
+ ERB.new(template, nil, "-").result(binding)
63
+ else
64
+ ERB.new(template, trim_mode: "-").result(binding)
65
+ end
53
66
  end
54
67
 
55
68
  def gem_header(_gem)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NextRails
4
- VERSION = "1.2.3"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/next_rails.rb CHANGED
@@ -1,8 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "next_rails/gem_info"
2
4
  require "next_rails/version"
3
5
  require "next_rails/bundle_report"
4
6
  require "deprecation_tracker"
5
7
 
6
8
  module NextRails
7
- # Your code goes here...
9
+ @@next_bundle_gemfile = nil
10
+
11
+ # This method will check your environment
12
+ # (e.g. `ENV['BUNDLE_GEMFILE]`) to determine whether your application is
13
+ # running with the next set of dependencies or the current set of dependencies.
14
+ #
15
+ # @return [Boolean]
16
+ def self.next?
17
+ return @@next_bundle_gemfile unless @@next_bundle_gemfile.nil?
18
+
19
+ @@next_bundle_gemfile = File.exist?(ENV["BUNDLE_GEMFILE"]) && File.basename(ENV["BUNDLE_GEMFILE"]) == "Gemfile.next"
20
+ end
21
+
22
+ # This method will reset the @@next_bundle_gemfile variable. Then next time
23
+ # you call `NextRails.next?` it will check the environment once again.
24
+ def self.reset_next_bundle_gemfile
25
+ @@next_bundle_gemfile = nil
26
+ end
8
27
  end
data/next_rails.gemspec CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "next_rails/version"
@@ -29,6 +28,7 @@ Gem::Specification.new do |spec|
29
28
  spec.add_development_dependency "rspec", "~> 3.0"
30
29
  spec.add_development_dependency "simplecov", "~> 0.17.1"
31
30
  spec.add_development_dependency "timecop", "~> 0.9.1"
31
+ spec.add_development_dependency "byebug"
32
32
  spec.add_development_dependency "rexml", "3.1.7.3" # limited on purpose, new versions don't work with old rubies
33
33
  spec.add_development_dependency "webmock", "3.16.2" # limited on purpose, new versions don't work with old rubies
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-04-12 00:00:00.000000000 Z
12
+ date: 2023-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -101,6 +101,20 @@ dependencies:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.9.1
104
+ - !ruby/object:Gem::Dependency
105
+ name: byebug
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
104
118
  - !ruby/object:Gem::Dependency
105
119
  name: rexml
106
120
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
208
  - !ruby/object:Gem::Version
195
209
  version: '0'
196
210
  requirements: []
197
- rubygems_version: 3.0.9
211
+ rubygems_version: 3.0.3.1
198
212
  signing_key:
199
213
  specification_version: 4
200
214
  summary: A toolkit to upgrade your next Rails application