next_rails 1.4.4 → 1.4.5

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: d1c67d799d599530c9a05a6dc5c45ce565a131cd9d3ae1ef0d433931873ea9e2
4
- data.tar.gz: d48ba5e3aa9332eb34d0a489dbc3977640dd15ffe51845d4c1050ba794ea5a27
3
+ metadata.gz: 3f16a7883af14d16feb650d7790a7a669db53cb552fc87081b77eb6336935d2f
4
+ data.tar.gz: 81d6cba28ac3940e1469a0cf4b2330b62981c612beff780bc6cc17daf48ec0ad
5
5
  SHA512:
6
- metadata.gz: b8083833e12cfaa07b7787b28fc1ce088b42ad09bada36d81af657787a10dadfe6b8f30e0925cb85b96f568dcd7bdf9bf4b1a1ff3bc3f5941e9c19a2767a84dd
7
- data.tar.gz: b838fe07dc40f693974088d1e828210f335139c17a17f183dcaeca1beb2b1a87a9d83634efe3d9e03ba1402469c39810250bcb2a8641fac2f615caa0aeb9c65b
6
+ metadata.gz: 25bdc3b376705f8909d7fcf2f915f883e9de5040821de49506d416bc23ff89e7c80c964da4cba8a180286527ca39d1b7f64d5b1d60288e62d4d524b89d81065f
7
+ data.tar.gz: bff53911bb5c8e3dc461be58acfb0140687e2af8a68ce81d39ec17cb4827203449f340c5283842496562903dd007a7946be8c544c91f9a0a01d3e2f5a9d7c242
data/CHANGELOG.md CHANGED
@@ -1,9 +1,13 @@
1
- # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.4.4...main)
1
+ # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.4.5...main)
2
2
 
3
3
  - [BUGFIX: example](https://github.com/fastruby/next_rails/pull/<number>)
4
4
 
5
5
  * Your changes/patches go here.
6
6
 
7
+ # v1.4.5 / 2025-03-07 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.4...v1.4.5)
8
+
9
+ - [Move rails_version compatibility to its own class](https://github.com/fastruby/next_rails/pull/137)
10
+
7
11
  # v1.4.4 / 2025-02-26 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.3...v1.4.4)
8
12
 
9
13
  - [FEATURE: Update deprecation tracker to support newer Rails versions (7.1+)](https://github.com/fastruby/next_rails/pull/142)
data/exe/bundle_report CHANGED
@@ -67,9 +67,9 @@ at_exit do
67
67
  when "outdated" then NextRails::BundleReport.outdated(options.fetch(:format, nil))
68
68
  else
69
69
  if options[:ruby_version]
70
- NextRails::BundleReport.compatibility(ruby_version: options.fetch(:ruby_version, "2.3"))
70
+ NextRails::BundleReport.ruby_compatibility(ruby_version: options.fetch(:ruby_version, "2.3"))
71
71
  else
72
- NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
72
+ NextRails::BundleReport.rails_compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
73
73
  end
74
74
  end
75
75
  end
@@ -0,0 +1,84 @@
1
+ class NextRails::BundleReport::RailsVersionCompatibility
2
+ def initialize(gems: NextRails::GemInfo.all, options: {})
3
+ @gems = gems
4
+ @options = options
5
+ end
6
+
7
+ def generate
8
+ erb_output
9
+ end
10
+
11
+ def incompatible_gems_by_state
12
+ @incompatible_gems_by_state ||= begin
13
+ incompatible_gems.each { |gem| gem.find_latest_compatible(rails_version: rails_version) }
14
+ incompatible_gems.group_by { |gem| gem.state(rails_version) }
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def erb_output
21
+ template = <<-ERB
22
+ <% if incompatible_gems_by_state[:found_compatible] -%>
23
+ <%= Rainbow("=> Incompatible with Rails #{rails_version} (with new versions that are compatible):").white.bold %>
24
+ <%= Rainbow("These gems will need to be upgraded before upgrading to Rails #{rails_version}.").italic %>
25
+
26
+ <% incompatible_gems_by_state[:found_compatible].each do |gem| -%>
27
+ <%= gem_header(gem) %> - upgrade to <%= gem.latest_compatible_version.version %>
28
+ <% end -%>
29
+
30
+ <% end -%>
31
+ <% if incompatible_gems_by_state[:incompatible] -%>
32
+ <%= Rainbow("=> Incompatible with Rails #{rails_version} (with no new compatible versions):").white.bold %>
33
+ <%= Rainbow("These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.").italic %>
34
+
35
+ <% incompatible_gems_by_state[:incompatible].each do |gem| -%>
36
+ <%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version}
37
+ <% end -%>
38
+
39
+ <% end -%>
40
+ <% if incompatible_gems_by_state[:no_new_version] -%>
41
+ <%= Rainbow("=> Incompatible with Rails #{rails_version} (with no new versions):").white.bold %>
42
+ <%= Rainbow("These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.").italic %>
43
+ <%= Rainbow("This list is likely to contain internal gems, like Cuddlefish.").italic %>
44
+
45
+ <% incompatible_gems_by_state[:no_new_version].each do |gem| -%>
46
+ <%= gem_header(gem) %> - new version not found
47
+ <% end -%>
48
+
49
+ <% end -%>
50
+ <%= Rainbow(incompatible_gems.length.to_s).red %> gems incompatible with Rails <%= rails_version %>
51
+ ERB
52
+
53
+ erb_version = ERB.version
54
+ if erb_version =~ /erb.rb \[([\d\.]+) .*\]/
55
+ erb_version = $1
56
+ end
57
+
58
+ if Gem::Version.new(erb_version) < Gem::Version.new("2.2")
59
+ ERB.new(template, nil, "-").result(binding)
60
+ else
61
+ ERB.new(template, trim_mode: "-").result(binding)
62
+ end
63
+ end
64
+
65
+ def gem_header(_gem)
66
+ header = Rainbow("#{_gem.name} #{_gem.version}").bold
67
+ header << Rainbow(" (loaded from git)").magenta if _gem.sourced_from_git?
68
+ header
69
+ end
70
+
71
+ def incompatible_gems
72
+ @incompatible_gems ||= @gems.reject do |gem|
73
+ gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?)
74
+ end.sort_by { |gem| gem.name }
75
+ end
76
+
77
+ def rails_version
78
+ @options[:rails_version]
79
+ end
80
+
81
+ def include_rails_gems
82
+ @options[:include_rails_gems]
83
+ end
84
+ end
@@ -8,69 +8,18 @@ module NextRails
8
8
  module BundleReport
9
9
  extend self
10
10
 
11
- def compatibility(rails_version: nil, ruby_version: nil, include_rails_gems: nil)
12
- return puts RubyVersionCompatibility.new(options: { ruby_version: ruby_version }).generate if ruby_version
11
+ def ruby_compatibility(ruby_version: nil)
12
+ return unless ruby_version
13
13
 
14
- incompatible_gems = NextRails::GemInfo.all.reject do |gem|
15
- gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?)
16
- end.sort_by { |gem| gem.name }
17
-
18
- incompatible_gems.each { |gem| gem.find_latest_compatible(rails_version: rails_version) }
19
-
20
- incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) }
21
-
22
- puts erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
14
+ options = { ruby_version: ruby_version }
15
+ puts RubyVersionCompatibility.new(options: options).generate
23
16
  end
24
17
 
25
- def erb_output(incompatible_gems_by_state, incompatible_gems, rails_version)
26
- template = <<-ERB
27
- <% if incompatible_gems_by_state[:found_compatible] -%>
28
- <%= Rainbow("=> Incompatible with Rails #{rails_version} (with new versions that are compatible):").white.bold %>
29
- <%= Rainbow("These gems will need to be upgraded before upgrading to Rails #{rails_version}.").italic %>
30
-
31
- <% incompatible_gems_by_state[:found_compatible].each do |gem| -%>
32
- <%= gem_header(gem) %> - upgrade to <%= gem.latest_compatible_version.version %>
33
- <% end -%>
34
-
35
- <% end -%>
36
- <% if incompatible_gems_by_state[:incompatible] -%>
37
- <%= Rainbow("=> Incompatible with Rails #{rails_version} (with no new compatible versions):").white.bold %>
38
- <%= Rainbow("These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.").italic %>
39
-
40
- <% incompatible_gems_by_state[:incompatible].each do |gem| -%>
41
- <%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version}
42
- <% end -%>
43
-
44
- <% end -%>
45
- <% if incompatible_gems_by_state[:no_new_version] -%>
46
- <%= Rainbow("=> Incompatible with Rails #{rails_version} (with no new versions):").white.bold %>
47
- <%= Rainbow("These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.").italic %>
48
- <%= Rainbow("This list is likely to contain internal gems, like Cuddlefish.").italic %>
49
-
50
- <% incompatible_gems_by_state[:no_new_version].each do |gem| -%>
51
- <%= gem_header(gem) %> - new version not found
52
- <% end -%>
53
-
54
- <% end -%>
55
- <%= Rainbow(incompatible_gems.length.to_s).red %> gems incompatible with Rails <%= rails_version %>
56
- ERB
57
-
58
- erb_version = ERB.version
59
- if erb_version =~ /erb.rb \[([\d\.]+) .*\]/
60
- erb_version = $1
61
- end
62
-
63
- if Gem::Version.new(erb_version) < Gem::Version.new("2.2")
64
- ERB.new(template, nil, "-").result(binding)
65
- else
66
- ERB.new(template, trim_mode: "-").result(binding)
67
- end
68
- end
18
+ def rails_compatibility(rails_version: nil, include_rails_gems: nil)
19
+ return unless rails_version
69
20
 
70
- def gem_header(_gem)
71
- header = Rainbow("#{_gem.name} #{_gem.version}").bold
72
- header << Rainbow(" (loaded from git)").magenta if _gem.sourced_from_git?
73
- header
21
+ options = { rails_version: rails_version, include_rails_gems: include_rails_gems }
22
+ puts RailsVersionCompatibility.new(options: options).generate
74
23
  end
75
24
 
76
25
  def compatible_ruby_version(rails_version)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NextRails
4
- VERSION = "1.4.4"
4
+ VERSION = "1.4.5"
5
5
  end
data/lib/next_rails.rb CHANGED
@@ -5,6 +5,7 @@ require "next_rails/version"
5
5
  require "next_rails/init"
6
6
  require "next_rails/bundle_report"
7
7
  require "next_rails/bundle_report/ruby_version_compatibility"
8
+ require "next_rails/bundle_report/rails_version_compatibility"
8
9
  require "deprecation_tracker"
9
10
 
10
11
  module NextRails
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.4.4
4
+ version: 1.4.5
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: 2025-02-26 00:00:00.000000000 Z
12
+ date: 2025-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -183,6 +183,7 @@ files:
183
183
  - lib/deprecation_tracker.rb
184
184
  - lib/next_rails.rb
185
185
  - lib/next_rails/bundle_report.rb
186
+ - lib/next_rails/bundle_report/rails_version_compatibility.rb
186
187
  - lib/next_rails/bundle_report/ruby_version_compatibility.rb
187
188
  - lib/next_rails/gem_info.rb
188
189
  - lib/next_rails/init.rb