next_rails 1.2.4 → 1.4.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: e72b90b419e084f28bdd704b0130169cc2e6c6bb0d72e0ab953cede28c2cd11d
4
- data.tar.gz: 7a14d79ce4a037e8a1ff04070021ade0323e245836e1016b7463b106331e96ba
3
+ metadata.gz: 7c82f6a12b6cd481313202fce9894ca2690c222d4397a14398f74c4dd0e6d31f
4
+ data.tar.gz: 546438cf1893b369c1f4c0d05f507a99c96a3dbd939b78b8e3bacbed560f2150
5
5
  SHA512:
6
- metadata.gz: b71eab63bf0f85e0d76ef308704a1247765ab5a404140591f902e3fc5fec13dd6c6c18e8328f2d8d6654cc3fc88fceba714adb1c86e7d9ea4ab0fbf151dc5468
7
- data.tar.gz: a9c71c3d81c477d198b7be8408791ac5f0882da5042afc46a3f4144f76a80b8f93d6283ac3cacdaa93a91d892757e9c8028121f7776ea7399f0a4bcca22e35a4
6
+ metadata.gz: a1330ca26c90f32978737bbf780156458bc8254377addbfdb860c63b1ff697f06a554e640d457bc7c7d1433a3baa7f2cd0115d4860bf451b85d468f8d0501eec
7
+ data.tar.gz: a5b5da58d00c288258931320c395cbccf1341f4eed15f56b680693f2ef3919d96ec97542a9bc2c3c11e5cf82ee5371f44d64162e9630901a4c702ded146e1415
@@ -1,4 +1,4 @@
1
- name: Run rake task
1
+ name: Continuous Integration
2
2
 
3
3
  on:
4
4
  push:
@@ -13,7 +13,7 @@ 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.3", "3.2", "3.1", "3.0", "2.7", "2.6"]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
- # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.2.4...main)
1
+ # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.4.0...main)
2
+
2
3
  * Your changes/patches go here.
3
4
 
5
+ # v1.4.0 / 2024-09-24 [(commits)](https://github.com/fastruby/next_rails/compare/v1.3.0...v1.4.0)
6
+
7
+ - [CHORE: Use next_rails namespace on spec tests.](https://github.com/fastruby/next_rails/pull/117)
8
+ - [CHORE: Remove 2.0.0, 2.1, 2.2 Ruby support](https://github.com/fastruby/next_rails/pull/126)
9
+ - [CHORE: Update compatibility for Ruby versions to use Rainbow](https://github.com/fastruby/next_rails/pull/125)
10
+ - [FEATURE: Support compatibility for Ruby versions](https://github.com/fastruby/next_rails/pull/116)
11
+ - [CHORE: Remove GPL licensed dependency Colorize and replace it with Rainbow]
12
+
13
+ # v1.3.0 / 2023-06-16 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.4...v1.3.0)
14
+
15
+ - [FEATURE: Add NextRails.next? for application usage (e.g. Rails shims)](https://github.com/fastruby/next_rails/pull/97)
16
+ - [BUGFIX: Support ERB versions older than 2.2.0](https://github.com/fastruby/next_rails/pull/100)
17
+
4
18
  # v1.2.4 / 2023-04-21 [(commits)](https://github.com/fastruby/next_rails/compare/v1.2.3...v1.2.4)
5
19
 
6
20
  - [BUGFIX: Update the warn method signature to support for Ruby 3]
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Next Rails
2
2
 
3
+ [![Continuous Integration](https://github.com/fastruby/next_rails/actions/workflows/main.yml/badge.svg)](https://github.com/fastruby/next_rails/actions/workflows/main.yml)
4
+
3
5
  This is a toolkit to upgrade your next Rails application. It will help you
4
6
  set up dual booting, track deprecation warnings, and get a report on outdated
5
7
  dependencies for any Rails application.
@@ -39,12 +41,36 @@ bundle_report outdated --json
39
41
  # Show gems that don't work with Rails 5.2.0
40
42
  bundle_report compatibility --rails-version=5.2.0
41
43
 
42
- # Show the usual help message
43
- bundle_report --help
44
+ # Show gems that don't work with Ruby 3.0
45
+ bundle_report compatibility --ruby-version=3.0
46
+
44
47
  # Find minimum compatible ruby version with Rails 7.0.0
45
48
  bundle_report ruby_check --rails-version=7.0.0
49
+
50
+ # Show the usual help message
51
+ bundle_report --help
46
52
  ```
47
53
 
54
+ ### Application usage
55
+
56
+ Every now and then it will be necessary to add code like this to your
57
+ application:
58
+
59
+ ```ruby
60
+ if NextRails.next?
61
+ # Do things "the Rails 7 way"
62
+ else
63
+ # Do things "the Rails 6.1 way"
64
+ end
65
+ ```
66
+
67
+ The `NextRails.next?` method will use your environment
68
+ (e.g. `ENV['BUNDLE_GEMFILE]`) to determine whether your application is
69
+ running with the next set of dependencies or the current set of dependencies.
70
+
71
+ This might come in handy if you need to inject
72
+ [Ruby or Rails shims](https://www.fastruby.io/blog/rails/upgrades/rails-upgrade-shims.html).
73
+
48
74
  ### Deprecation tracking
49
75
 
50
76
  If you're using RSpec, add this snippet to `rails_helper.rb` or `spec_helper.rb` (whichever loads Rails).
data/exe/bundle_report CHANGED
@@ -16,6 +16,7 @@ at_exit do
16
16
 
17
17
  Examples:
18
18
  #{$0} compatibility --rails-version 5.0
19
+ #{$0} compatibility --ruby-version 3.3
19
20
  #{$0} outdated
20
21
  #{$0} outdated --json
21
22
 
@@ -33,6 +34,10 @@ at_exit do
33
34
  options[:rails_version] = rails_version
34
35
  end
35
36
 
37
+ opts.on("--ruby-version [STRING]", "Ruby version to check compatibility against (defaults to 2.3)") do |ruby_version|
38
+ options[:ruby_version] = ruby_version
39
+ end
40
+
36
41
  opts.on("--include-rails-gems", "Include Rails gems in compatibility report (defaults to false)") do
37
42
  options[:include_rails_gems] = true
38
43
  end
@@ -61,7 +66,11 @@ at_exit do
61
66
  when "ruby_check" then NextRails::BundleReport.compatible_ruby_version(rails_version: options.fetch(:rails_version))
62
67
  when "outdated" then NextRails::BundleReport.outdated(options.fetch(:format, nil))
63
68
  else
64
- NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
69
+ if options[:ruby_version]
70
+ NextRails::BundleReport.compatibility(ruby_version: options.fetch(:ruby_version, "2.3"))
71
+ else
72
+ NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
73
+ end
65
74
  end
66
75
  end
67
76
 
data/exe/deprecations CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "json"
3
- require "colorize"
3
+ require "rainbow/refinement"
4
4
  require "optparse"
5
5
  require "set"
6
6
 
7
+ using Rainbow
8
+
7
9
  def run_tests(deprecation_warnings, opts = {})
8
10
  tracker_mode = opts[:tracker_mode]
9
11
  next_mode = opts[:next_mode]
@@ -1,6 +1,8 @@
1
- require "colorize"
1
+ require "rainbow/refinement"
2
2
  require "json"
3
3
 
4
+ using Rainbow
5
+
4
6
  # A shitlist for deprecation warnings during test runs. It has two modes: "save" and "compare"
5
7
  #
6
8
  # DEPRECATION_TRACKER=save
@@ -0,0 +1,46 @@
1
+ require "rainbow/refinement"
2
+
3
+ class NextRails::BundleReport::RubyVersionCompatibility
4
+ using Rainbow
5
+
6
+ MINIMAL_VERSION = 1.0
7
+ attr_reader :gems, :options
8
+
9
+ def initialize(gems: NextRails::GemInfo.all, options: {})
10
+ @gems = gems
11
+ @options = options
12
+ end
13
+
14
+ def generate
15
+ return invalid_message unless valid?
16
+
17
+ message
18
+ end
19
+
20
+ private
21
+
22
+ def message
23
+ output = "=> Incompatible gems with Ruby #{ruby_version}:".white.bold
24
+ incompatible.each do |gem|
25
+ output += "\n#{gem.name} - required Ruby version: #{gem.gem_specification.required_ruby_version}".magenta
26
+ end
27
+ output += "\n\n#{incompatible.length} incompatible #{incompatible.one? ? 'gem' : 'gems' } with Ruby #{ruby_version}".red
28
+ output
29
+ end
30
+
31
+ def incompatible
32
+ gems.reject { |gem| gem.compatible_with_ruby?(ruby_version) }
33
+ end
34
+
35
+ def ruby_version
36
+ options[:ruby_version].to_f
37
+ end
38
+
39
+ def invalid_message
40
+ "=> Invalid Ruby version: #{options[:ruby_version]}.".red.bold
41
+ end
42
+
43
+ def valid?
44
+ ruby_version > MINIMAL_VERSION
45
+ end
46
+ end
@@ -1,14 +1,18 @@
1
- require "colorize"
1
+ require "rainbow/refinement"
2
2
  require "cgi"
3
3
  require "erb"
4
4
  require "json"
5
5
  require "net/http"
6
6
 
7
+ using Rainbow
8
+
7
9
  module NextRails
8
10
  module BundleReport
9
11
  extend self
10
12
 
11
- def compatibility(rails_version: nil, include_rails_gems: nil)
13
+ def compatibility(rails_version: nil, ruby_version: nil, include_rails_gems: nil)
14
+ return puts RubyVersionCompatibility.new(options: { ruby_version: ruby_version }).generate if ruby_version
15
+
12
16
  incompatible_gems = NextRails::GemInfo.all.reject do |gem|
13
17
  gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?)
14
18
  end.sort_by { |gem| gem.name }
@@ -17,6 +21,10 @@ module NextRails
17
21
 
18
22
  incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) }
19
23
 
24
+ puts erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
25
+ end
26
+
27
+ def erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
20
28
  template = <<-ERB
21
29
  <% if incompatible_gems_by_state[:found_compatible] -%>
22
30
  <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %>
@@ -49,7 +57,16 @@ module NextRails
49
57
  <%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %>
50
58
  ERB
51
59
 
52
- puts ERB.new(template, trim_mode: "-").result(binding)
60
+ erb_version = ERB.version
61
+ if erb_version =~ /erb.rb \[([\d\.]+) .*\]/
62
+ erb_version = $1
63
+ end
64
+
65
+ if Gem::Version.new(erb_version) < Gem::Version.new("2.2")
66
+ ERB.new(template, nil, "-").result(binding)
67
+ else
68
+ ERB.new(template, trim_mode: "-").result(binding)
69
+ end
53
70
  end
54
71
 
55
72
  def gem_header(_gem)
@@ -155,4 +172,4 @@ module NextRails
155
172
  puts footer
156
173
  end
157
174
  end
158
- end
175
+ end
@@ -147,5 +147,9 @@ module NextRails
147
147
  rails_dependency.requirement.satisfied_by?(Gem::Version.new(rails_version))
148
148
  end
149
149
  end
150
+
151
+ def compatible_with_ruby?(ruby_version)
152
+ gem_specification.required_ruby_version.satisfied_by?(Gem::Version.new(ruby_version))
153
+ end
150
154
  end
151
155
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NextRails
4
- VERSION = "1.2.4"
4
+ VERSION = "1.4.0"
5
5
  end
data/lib/next_rails.rb CHANGED
@@ -1,8 +1,28 @@
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"
6
+ require "next_rails/bundle_report/ruby_version_compatibility"
4
7
  require "deprecation_tracker"
5
8
 
6
9
  module NextRails
7
- # Your code goes here...
10
+ @@next_bundle_gemfile = nil
11
+
12
+ # This method will check your environment
13
+ # (e.g. `ENV['BUNDLE_GEMFILE]`) to determine whether your application is
14
+ # running with the next set of dependencies or the current set of dependencies.
15
+ #
16
+ # @return [Boolean]
17
+ def self.next?
18
+ return @@next_bundle_gemfile unless @@next_bundle_gemfile.nil?
19
+
20
+ @@next_bundle_gemfile = File.exist?(ENV["BUNDLE_GEMFILE"]) && File.basename(ENV["BUNDLE_GEMFILE"]) == "Gemfile.next"
21
+ end
22
+
23
+ # This method will reset the @@next_bundle_gemfile variable. Then next time
24
+ # you call `NextRails.next?` it will check the environment once again.
25
+ def self.reset_next_bundle_gemfile
26
+ @@next_bundle_gemfile = nil
27
+ end
8
28
  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"
@@ -23,12 +22,13 @@ Gem::Specification.new do |spec|
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
23
  spec.require_paths = ["lib"]
25
24
 
26
- spec.add_dependency "colorize", ">= 0.8.1"
25
+ spec.add_dependency "rainbow", ">= 3"
27
26
  spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
28
27
  spec.add_development_dependency "rake"
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,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernesto Tagwerker
8
8
  - Luis Sagastume
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-04-21 00:00:00.000000000 Z
12
+ date: 2024-09-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: colorize
15
+ name: rainbow
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.8.1
20
+ version: '3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.8.1
27
+ version: '3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -150,9 +164,7 @@ files:
150
164
  - ".github/workflows/main.yml"
151
165
  - ".gitignore"
152
166
  - ".rspec"
153
- - ".travis.yml"
154
167
  - CHANGELOG.md
155
- - CODEOWNERS
156
168
  - CODE_OF_CONDUCT.md
157
169
  - CONTRIBUTING.md
158
170
  - Gemfile
@@ -171,6 +183,7 @@ files:
171
183
  - lib/deprecation_tracker.rb
172
184
  - lib/next_rails.rb
173
185
  - lib/next_rails/bundle_report.rb
186
+ - lib/next_rails/bundle_report/ruby_version_compatibility.rb
174
187
  - lib/next_rails/gem_info.rb
175
188
  - lib/next_rails/version.rb
176
189
  - next_rails.gemspec
@@ -179,7 +192,7 @@ homepage: https://github.com/fastruby/next_rails
179
192
  licenses:
180
193
  - MIT
181
194
  metadata: {}
182
- post_install_message:
195
+ post_install_message:
183
196
  rdoc_options: []
184
197
  require_paths:
185
198
  - lib
@@ -194,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
207
  - !ruby/object:Gem::Version
195
208
  version: '0'
196
209
  requirements: []
197
- rubygems_version: 3.0.9
198
- signing_key:
210
+ rubygems_version: 3.5.9
211
+ signing_key:
199
212
  specification_version: 4
200
213
  summary: A toolkit to upgrade your next Rails application
201
214
  test_files: []
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.3
5
- - 2.4.10
6
- - 2.5.8
7
- - 2.6.6
8
- - 2.7.2
9
- - 3.0.2
10
- before_install: gem install bundler -v 1.16.1
data/CODEOWNERS DELETED
@@ -1,4 +0,0 @@
1
- # These code owners will be the default owners to everything in the repository.
2
- # Unless a posterior rule has precedence, they will be automatically requested
3
- # for review when a pull request is opened.
4
- * @fastruby/black-bunny-brigade