next_rails 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b939f85a063cc87019deb0355769fd28ba31f4cb0b86e3f6d6108efab7c34a1
4
- data.tar.gz: 5cee83e0ec770a5b01b7ce51c0efbcbc3ed9bdc1e70027a92cc6b8a3eee17dc9
3
+ metadata.gz: e37620e9fa92eea06f9faa05a1ace3cd1b9ff2585da96b838e165f1b98b06129
4
+ data.tar.gz: 47335d3ccaf72cfb828deeeab67ae93700fe83f38a7aeb7194ddccad5ebb0f3d
5
5
  SHA512:
6
- metadata.gz: dc3b4d1bd7b0fd4398c781b65f19f068af6ba01c5e6ff994ab77b832524094788fdd473ffea1bcf0ec3ffd4efd805a5c0a9906d0c10ae2169270bc07128d31b1
7
- data.tar.gz: d5d5125673d14079de4cdd333c9414666962c9c5daa1873e964abd724f1ae75a45fe0df9336283e6d99e8d15abf97b8d91860b4d7c50733399ac57194f8edea7
6
+ metadata.gz: d449a18c9279d4bc1a2889440843c800dc5f8b1e1d50cacdb2ace1cdebb5b7eb7c14fb6247059e30f7e39412bbb97f15d5ec7b674320bf8bc8c840edf1144fa2
7
+ data.tar.gz: 8b22f60cdb23275ee943e68835374ea18c54d4ecb1718db2f2e9b0b701bad9a73da2dcc73c03438ed0269b610ed67bbcd7b5bd2eb9906d2c758394abbe0bf8e3
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: "[BUG] "
5
+ labels: bug
6
+ assignees: ""
7
+ ---
8
+
9
+ **IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.**
10
+
11
+ **Before we start...:**
12
+
13
+ - [ ] I checked the documentation and found no answer
14
+ - [ ] I checked to make sure that this issue has not already been filed
15
+ - [ ] I'm reporting the issue to the correct repository (for multi-repository projects)
16
+
17
+ **Version, Branch, or Commit:**
18
+
19
+ What branch/commit/version of "next_rails" you are using?
20
+
21
+ **Expected behavior:**
22
+
23
+ Please include a detailed description of the behavior you were expecting when you encountered this issue.
24
+
25
+ **Actual behavior:**
26
+
27
+ Please include a detailed description of the actual behavior of the application.
28
+
29
+ **Steps to reproduce:**
30
+
31
+ How do I achieve this behavior? Use the following format to provide a step-by-step guide:
32
+
33
+ 1. Step 1: ...
34
+ 2. Step 2: ...
35
+
36
+ **Context and environment:**
37
+
38
+ Provide any relevant information about your setup (Customize the list accordingly based on what info is relevant to this project)
39
+
40
+ 1. Version of the software the issue is being opened for.
41
+ 2. Operating System
42
+ 3. Operating System version
43
+ 4. Ruby version
44
+
45
+ _Delete any information that is not relevant._
46
+
47
+ **Logs**
48
+
49
+ Include relevant log snippets or files here.
50
+
51
+ **I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md)**
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: Feature request
3
+ about: Request a new feature
4
+ title: "[REQUEST]"
5
+ labels: enhancement
6
+ assignees: ""
7
+ ---
8
+
9
+ **IMPORTANT: please make sure you ask yourself all intro questions and fill all sections of the template.**
10
+
11
+ **Before we start...:**
12
+
13
+ - [ ] I checked the documentation and didn't find this feature
14
+ - [ ] I checked to make sure that this feature has not already been requested
15
+
16
+ **Branch/Commit:**
17
+
18
+ Inform what branch/commit/version of "next_rails" you are using.
19
+
20
+ **Describe the feature:**
21
+
22
+ Please include a detailed description of the feature you are requesting and any detail on it’s expected behavior.
23
+
24
+ > **As a \<role name\>** > **I do \<something\>** > **And then I do \<another action\>** > **And I see \<some result\>**
25
+
26
+ **Problem:**
27
+
28
+ Please include a detailed description of the problem this feature would solve.
29
+
30
+ > **As a \<role name\>** > **I want to \<do something\>** > **So that I can achieve a \<goal\>**
31
+
32
+ **Mockups:**
33
+
34
+ Include any mockup idea related to the requested feature if it applies.
35
+
36
+ **Resources:**
37
+
38
+ If you have resources related to the implementation or research for this feature, add them here.
39
+
40
+ **I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md)**
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,20 @@
1
+ name: Run rake task
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: [3.1, 2.7.5]
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true
19
+ - name: Run rake task
20
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,7 +1,29 @@
1
1
  # main [(unreleased)](https://github.com/fastruby/next_rails/compare/v1.0.4...main)
2
2
 
3
+ * [FEATURE: Try to find the latest **compatible** version of a gem if the latest version is not compatible with the desired Rails version when checking compatibility](https://github.com/fastruby/next_rails/pull/49)
4
+
5
+ * [FEATURE: Added option --version to get the version of the gem being used](https://github.com/fastruby/next_rails/pull/38)
6
+
7
+ * [Added github action workflow](https://github.com/fastruby/next_rails/pull/40)
8
+
9
+ * [FEATURE: Add support to use DeprecationTracker with Minitest](Add support to use DeprecationTracker with Minitest)
10
+
11
+ * [FEATURE: Add dependabot](https://github.com/fastruby/next_rails/pull/41)
12
+
13
+ * [DOCUMENTATION: Update the code of conduct link in PR template](https://github.com/fastruby/next_rails/pull/46)
14
+
15
+ * [DOCUMENTATION: Add FEATURE REQUEST and BUG REPORT templates ](https://github.com/fastruby/next_rails/pull/48)
16
+
17
+ * [BUGFIX: Make behavior arguments optional](https://github.com/fastruby/next_rails/pull/44)
18
+
19
+ * [FEATURE: Command line option to check for recommended ruby version for the desired Rails version](https://github.com/fastruby/next_rails/pull/39)
20
+
21
+
22
+ # v1.0.5 / 2022-03-29 [(commits)](https://github.com/fastruby/next_rails/compare/v1.0.4...v1.0.5)
23
+
3
24
  * [FEATURE: Initialize the Gemfile.next.lock to avoid major version jumps when used without an initial Gemfile.next.lock](https://github.com/fastruby/next_rails/pull/25)
4
25
  * [FEATURE: Drop `actionview` dependency because it is not really used](https://github.com/fastruby/next_rails/pull/26)
26
+ * [BUGFIX: If shitlist path does not exist, create it for the user of the gem](https://github.com/fastruby/next_rails/pull/37)
5
27
 
6
28
  # v1.0.4 / 2021-04-09 [(commits)](https://github.com/fastruby/next_rails/compare/v1.0.3...v1.0.4)
7
29
 
@@ -11,10 +33,11 @@
11
33
 
12
34
  * [BUGFIX: Update README.md to better document this `ten_years_rails` fork](https://github.com/fastruby/next_rails/pull/11)
13
35
  * [BUGFIX: Make ActionView an optional dependency](https://github.com/fastruby/next_rails/pull/6)
36
+
14
37
  # v1.0.2 / 2020-01-20
15
38
 
16
39
  # v1.0.1 / 2019-07-26
17
40
 
18
41
  # v1.0.0 / 2019-07-24
19
42
 
20
- * Official Release
43
+ * Official Release
data/CODEOWNERS ADDED
@@ -0,0 +1,4 @@
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
data/README.md CHANGED
@@ -34,6 +34,8 @@ bundle_report outdated | head -n 5
34
34
  # Show gems that don't work with Rails 5.2.0
35
35
  bundle_report compatibility --rails-version=5.2.0
36
36
  bundle_report --help
37
+ # Find minimum compatible ruby version with Rails 7.0.0
38
+ bundle_report ruby_check --rails-version=7.0.0
37
39
  ```
38
40
 
39
41
  ### Deprecation tracking
@@ -54,7 +56,20 @@ RSpec.configure do |config|
54
56
  end
55
57
  ```
56
58
 
57
- We don't use MiniTest, so there isn't a prebuilt config for it but I suspect it's pretty similar to `DeprecationTracker.track_rspec`.
59
+ If using minitest, add this somewhere close to the top of your `test_helper.rb`:
60
+
61
+ ```ruby
62
+ # Tracker deprecation messages in each file
63
+ if ENV["DEPRECATION_TRACKER"]
64
+ DeprecationTracker.track_minitest(
65
+ shitlist_path: "test/support/deprecation_warning.shitlist.json",
66
+ mode: ENV["DEPRECATION_TRACKER"],
67
+ transform_message: -> (message) { message.gsub("#{Rails.root}/", "") }
68
+ )
69
+ end
70
+ ```
71
+
72
+ > Keep in mind this is currently not compatible with the `minitest/parallel_fork` gem!
58
73
 
59
74
  Once you have that, you can start using deprecation tracking in your tests:
60
75
 
@@ -78,6 +93,15 @@ deprecations --help # For more options and examples
78
93
 
79
94
  Right now, the path to the shitlist is hardcoded so make sure you store yours at `spec/support/deprecations.shitlist.json`.
80
95
 
96
+ #### `next_rails` command
97
+
98
+ You can use `next_rails` to fetch the version of the gem installed.
99
+
100
+ ```bash
101
+ next_rails --version
102
+ next_rails --help # For more options and examples
103
+ ```
104
+
81
105
  ### Dual-boot Rails next
82
106
 
83
107
  This command helps you dual-boot your application.
@@ -112,7 +136,7 @@ Execute:
112
136
  $ next --init
113
137
 
114
138
  Init will create a Gemfile.next and an initialized Gemfile.next.lock.
115
- The Gemfile.next.lock is initialized with the contents of your existing
139
+ The Gemfile.next.lock is initialized with the contents of your existing
116
140
  Gemfile.lock lock file. We initialize the Gemfile.next.lock to prevent
117
141
  major version jumps when running the next version of Rails.
118
142
 
data/exe/bundle_report CHANGED
@@ -17,6 +17,12 @@ at_exit do
17
17
  Examples:
18
18
  #{$0} compatibility --rails-version 5.0
19
19
  #{$0} outdated
20
+
21
+ ruby_check To find a compatible ruby version for the target rails version
22
+
23
+ Examples:
24
+ #{$0} ruby_check --rails-version 7.0.0
25
+
20
26
  EOS
21
27
 
22
28
  opts.separator ""
@@ -47,6 +53,7 @@ at_exit do
47
53
  report_type = ARGV.first
48
54
 
49
55
  case report_type
56
+ when "ruby_check" then NextRails::BundleReport.compatible_ruby_version(rails_version: options.fetch(:rails_version))
50
57
  when "outdated" then NextRails::BundleReport.outdated
51
58
  else
52
59
  NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false))
data/exe/next_rails ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require "optparse"
3
+ require "next_rails/version"
4
+
5
+ options = {}
6
+ option_parser = OptionParser.new do |opts|
7
+ opts.banner = <<-MESSAGE
8
+ Usage: #{__FILE__.to_s} [options]
9
+
10
+ Examples:
11
+ bin/next_rails --version info # Show the version of the gem installed
12
+ MESSAGE
13
+
14
+ opts.on("--version", "show version of the gem") do
15
+ options[:version] = true
16
+ end
17
+
18
+ opts.on_tail("-h", "--help", "Prints this help") do
19
+ puts opts
20
+ exit
21
+ end
22
+ end
23
+
24
+ option_parser.parse!
25
+
26
+ if options.fetch(:version, false)
27
+ puts NextRails::VERSION
28
+ exit 2
29
+ end
@@ -27,6 +27,25 @@ class DeprecationTracker
27
27
  end
28
28
  end
29
29
 
30
+ module MinitestExtension
31
+ def self.new(deprecation_tracker)
32
+ @@deprecation_tracker = deprecation_tracker
33
+
34
+ Module.new do
35
+ def before_setup
36
+ test_file_name = method(name).source_location.first.to_s
37
+ @@deprecation_tracker.bucket = test_file_name.gsub(Rails.root.to_s, ".")
38
+ super
39
+ end
40
+
41
+ def after_teardown
42
+ super
43
+ @@deprecation_tracker.bucket = nil
44
+ end
45
+ end
46
+ end
47
+ end
48
+
30
49
  # There are two forms of the `warn` method: one for class Kernel and one for instances of Kernel (i.e., every Object)
31
50
  Object.prepend(KernelWarnTracker)
32
51
 
@@ -39,16 +58,24 @@ class DeprecationTracker
39
58
  end
40
59
  end
41
60
 
42
- def self.track_rspec(rspec_config, opts = {})
61
+ def self.init_tracker(opts = {})
43
62
  shitlist_path = opts[:shitlist_path]
44
63
  mode = opts[:mode]
45
64
  transform_message = opts[:transform_message]
46
- deprecation_tracker = DeprecationTracker.new(shitlist_path, transform_message)
65
+ deprecation_tracker = DeprecationTracker.new(shitlist_path, transform_message, mode)
47
66
  if defined?(ActiveSupport)
48
- ActiveSupport::Deprecation.behavior << -> (message, _callstack, _deprecation_horizon, _gem_name) { deprecation_tracker.add(message) }
67
+ ActiveSupport::Deprecation.behavior << -> (message, _callstack = nil, _deprecation_horizon = nil, _gem_name = nil) {
68
+ deprecation_tracker.add(message)
69
+ }
49
70
  end
50
71
  KernelWarnTracker.callbacks << -> (message) { deprecation_tracker.add(message) }
51
72
 
73
+ deprecation_tracker
74
+ end
75
+
76
+ def self.track_rspec(rspec_config, opts = {})
77
+ deprecation_tracker = init_tracker(opts)
78
+
52
79
  rspec_config.around do |example|
53
80
  deprecation_tracker.bucket = example.metadata.fetch(:rerun_file_path)
54
81
 
@@ -60,21 +87,27 @@ class DeprecationTracker
60
87
  end
61
88
 
62
89
  rspec_config.after(:suite) do
63
- if mode == "save"
64
- deprecation_tracker.save
65
- elsif mode == "compare"
66
- deprecation_tracker.compare
67
- end
90
+ deprecation_tracker.after_run
68
91
  end
69
92
  end
70
93
 
71
- attr_reader :deprecation_messages, :shitlist_path, :transform_message
72
- attr_reader :bucket
94
+ def self.track_minitest(opts = {})
95
+ tracker = init_tracker(opts)
96
+
97
+ Minitest.after_run do
98
+ tracker.after_run
99
+ end
100
+
101
+ ActiveSupport::TestCase.include(MinitestExtension.new(tracker))
102
+ end
73
103
 
74
- def initialize(shitlist_path, transform_message = nil)
104
+ attr_reader :deprecation_messages, :shitlist_path, :transform_message, :bucket, :mode
105
+
106
+ def initialize(shitlist_path, transform_message = nil, mode = :save)
75
107
  @shitlist_path = shitlist_path
76
108
  @transform_message = transform_message || -> (message) { message }
77
109
  @deprecation_messages = {}
110
+ @mode = mode.to_sym
78
111
  end
79
112
 
80
113
  def add(message)
@@ -88,6 +121,14 @@ class DeprecationTracker
88
121
  @deprecation_messages[value] ||= [] unless value.nil?
89
122
  end
90
123
 
124
+ def after_run
125
+ if mode == :save
126
+ save
127
+ elsif mode == :compare
128
+ compare
129
+ end
130
+ end
131
+
91
132
  def compare
92
133
  shitlist = read_shitlist
93
134
 
@@ -2,28 +2,26 @@ require "colorize"
2
2
  require "cgi"
3
3
  require "erb"
4
4
  require "json"
5
+ require "net/http"
5
6
 
6
7
  module NextRails
7
8
  class BundleReport
8
9
  def self.compatibility(rails_version:, include_rails_gems:)
9
10
  incompatible_gems = NextRails::GemInfo.all.reject do |gem|
10
11
  gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?)
11
- end.sort_by do |gem|
12
- [
13
- gem.latest_version.compatible_with_rails?(rails_version: rails_version) ? 0 : 1,
14
- gem.name
15
- ].join("-")
16
- end
12
+ end.sort_by { |gem| gem.name }
13
+
14
+ incompatible_gems.each { |gem| gem.find_latest_compatible(rails_version: rails_version) }
17
15
 
18
16
  incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) }
19
17
 
20
18
  template = <<~ERB
21
- <% if incompatible_gems_by_state[:latest_compatible] -%>
19
+ <% if incompatible_gems_by_state[:found_compatible] -%>
22
20
  <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %>
23
21
  <%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %>
24
22
 
25
- <% incompatible_gems_by_state[:latest_compatible].each do |gem| -%>
26
- <%= gem_header(gem) %> - upgrade to <%= gem.latest_version.version %>
23
+ <% incompatible_gems_by_state[:found_compatible].each do |gem| -%>
24
+ <%= gem_header(gem) %> - upgrade to <%= gem.latest_compatible_version.version %>
27
25
  <% end -%>
28
26
 
29
27
  <% end -%>
@@ -58,6 +56,45 @@ module NextRails
58
56
  header
59
57
  end
60
58
 
59
+ def self.compatible_ruby_version(rails_version)
60
+ # find all the versions of rails gem
61
+ uri = URI('https://rubygems.org/api/v1/versions/rails.json')
62
+ res = Net::HTTP.get_response(uri)
63
+ all_versions_res = JSON.parse(res.body)
64
+
65
+ # push all the versions in an array
66
+ all_versions = []
67
+ all_versions_res.each { |rv| all_versions << rv['number'] }
68
+
69
+ rv = rails_version[:rails_version]
70
+ matched_versions = all_versions.select { |h| h.start_with?(rv) }
71
+
72
+ # the list can either have the exact version or the latest version in the series of versions
73
+ # you are looking at
74
+ # ex: matched_versions = ["6.1.4.2", "6.1.4.1", "6.1.4"]
75
+ # if you have passed "6.1.4" and the list has the exact version, it will match and send
76
+ # the ruby version for it bu tif you had passed "6.1", then it will look for the
77
+ # latest version matching "6.1" which is "6.1.4.2" in this case and will return ruby
78
+ # version for it.
79
+ exact_version = matched_versions.include?(rv) ? rv : matched_versions[0]
80
+
81
+ if exact_version
82
+ uri = URI("https://rubygems.org/api/v2/rubygems/rails/versions/#{exact_version}.json")
83
+ res = Net::HTTP.get_response(uri)
84
+ ruby_version = JSON.parse(res.body)["ruby_version"]
85
+ else
86
+ ruby_version = nil
87
+ end
88
+
89
+
90
+ if ruby_version
91
+ puts "The required ruby version is #{ruby_version} for matched rails version #{exact_version}"
92
+ ruby_version
93
+ else
94
+ puts "Could not find a compatible ruby version"
95
+ end
96
+ end
97
+
61
98
  def self.outdated
62
99
  gems = NextRails::GemInfo.all
63
100
  out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at)
@@ -28,13 +28,28 @@ module NextRails
28
28
  end
29
29
  end
30
30
 
31
+ RAILS_GEMS = [
32
+ "rails",
33
+ "activemodel",
34
+ "activerecord",
35
+ "actionmailer",
36
+ "actioncable",
37
+ "actionpack",
38
+ "actionview",
39
+ "activejob",
40
+ "activestorage",
41
+ "activesupport",
42
+ "railties",
43
+ ].freeze
44
+
31
45
  def self.all
32
46
  Gem::Specification.each.map do |gem_specification|
33
47
  new(gem_specification)
34
48
  end
35
49
  end
36
50
 
37
- attr_reader :gem_specification, :version, :name
51
+ attr_reader :gem_specification, :version, :name, :latest_compatible_version
52
+
38
53
  def initialize(gem_specification)
39
54
  @gem_specification = gem_specification
40
55
  @version = gem_specification.version
@@ -57,59 +72,69 @@ module NextRails
57
72
  version == latest_version.version
58
73
  end
59
74
 
75
+ def from_rails?
76
+ RAILS_GEMS.include?(name)
77
+ end
78
+
60
79
  def state(rails_version)
61
80
  if compatible_with_rails?(rails_version: rails_version)
62
81
  :compatible
63
- elsif latest_version.compatible_with_rails?(rails_version: rails_version)
64
- :latest_compatible
65
- elsif latest_version.version == "NOT FOUND"
82
+ elsif latest_compatible_version.version == "NOT FOUND"
66
83
  :no_new_version
84
+ elsif latest_compatible_version
85
+ :found_compatible
67
86
  else
68
87
  :incompatible
69
88
  end
70
89
  end
71
90
 
72
- def latest_version
73
- @latest_version ||= begin
74
- latest_gem_specification = Gem.latest_spec_for(name)
75
- if latest_gem_specification
76
- GemInfo.new(latest_gem_specification)
77
- else
78
- NullGemInfo.new
79
- end
80
- end
81
- end
82
-
83
- def compatible_with_rails?(rails_version: Gem::Version.new("5.0"))
91
+ def compatible_with_rails?(rails_version:)
84
92
  unsatisfied_rails_dependencies(rails_version: rails_version).empty?
85
93
  end
86
94
 
87
95
  def unsatisfied_rails_dependencies(rails_version:)
88
- rails_dependencies = gem_specification.runtime_dependencies.select {|dependency| rails_gems.include?(dependency.name) }
96
+ spec_compatible_with_rails?(specification: gem_specification, rails_version: rails_version)
97
+ end
89
98
 
90
- rails_dependencies.reject do |rails_dependency|
91
- rails_dependency.requirement.satisfied_by?(Gem::Version.new(rails_version))
99
+ def find_latest_compatible(rails_version:)
100
+ dependency = Gem::Dependency.new(@name)
101
+ fetcher = Gem::SpecFetcher.new
102
+
103
+ # list all available data for released gems
104
+ list, errors = fetcher.available_specs(:released)
105
+
106
+ specs = []
107
+ # filter only specs for the current gem and older versions
108
+ list.each do |source, gem_tuples|
109
+ gem_tuples.each do |gem_tuple|
110
+ if gem_tuple.name == @name && gem_tuple.version > @version
111
+ specs << source.fetch_spec(gem_tuple)
112
+ end
113
+ end
92
114
  end
93
- end
94
115
 
95
- def from_rails?
96
- rails_gems.include?(name)
116
+ # if nothing is found, consider gem incompatible
117
+ if specs.empty?
118
+ @latest_compatible_version = NullGemInfo.new
119
+ return
120
+ end
121
+
122
+ # if specs are found, look for the first one from that is compatible
123
+ # with the desired rails version starting from the end
124
+ specs.reverse.each do |spec|
125
+ if spec_compatible_with_rails?(specification: spec, rails_version: rails_version).empty?
126
+ @latest_compatible_version = spec
127
+ break
128
+ end
129
+ end
97
130
  end
98
131
 
99
- private def rails_gems
100
- [
101
- "rails",
102
- "activemodel",
103
- "activerecord",
104
- "actionmailer",
105
- "actioncable",
106
- "actionpack",
107
- "actionview",
108
- "activejob",
109
- "activestorage",
110
- "activesupport",
111
- "railties",
112
- ]
132
+ def spec_compatible_with_rails?(specification:, rails_version:)
133
+ rails_dependencies = specification.runtime_dependencies.select {|dependency| RAILS_GEMS.include?(dependency.name) }
134
+
135
+ rails_dependencies.reject do |rails_dependency|
136
+ rails_dependency.requirement.satisfied_by?(Gem::Version.new(rails_version))
137
+ end
113
138
  end
114
139
  end
115
140
  end
@@ -1,3 +1,3 @@
1
1
  module NextRails
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
data/next_rails.gemspec CHANGED
@@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency "colorize", ">= 0.8.1"
27
27
  spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  spec.add_development_dependency "simplecov", "~> 0.17.1"
31
31
  spec.add_development_dependency "timecop", "~> 0.9.1"
32
+ spec.add_development_dependency "webmock"
32
33
  end
@@ -6,4 +6,4 @@ Description:
6
6
 
7
7
  Please include a summary of the change and which issue is fixed or which feature is introduced. If changes to the behavior are made, clearly describe what changes.
8
8
 
9
- I will abide by the [code of conduct](CODE_OF_CONDUCT.md).
9
+ I will abide by the [code of conduct](https://github.com/fastruby/next_rails/blob/main/CODE_OF_CONDUCT.md).
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: next_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.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: 2022-03-29 00:00:00.000000000 Z
12
+ date: 2022-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -51,14 +51,14 @@ dependencies:
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '13.0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rspec
64
64
  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: webmock
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
  description: A set of handy tools to upgrade your Rails application and keep it up
105
119
  to date
106
120
  email:
@@ -112,13 +126,19 @@ executables:
112
126
  - gem-next-diff
113
127
  - next
114
128
  - next.sh
129
+ - next_rails
115
130
  extensions: []
116
131
  extra_rdoc_files: []
117
132
  files:
133
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
134
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
135
+ - ".github/dependabot.yml"
136
+ - ".github/workflows/main.yml"
118
137
  - ".gitignore"
119
138
  - ".rspec"
120
139
  - ".travis.yml"
121
140
  - CHANGELOG.md
141
+ - CODEOWNERS
122
142
  - CODE_OF_CONDUCT.md
123
143
  - Gemfile
124
144
  - LICENSE.txt
@@ -132,6 +152,7 @@ files:
132
152
  - exe/gem-next-diff
133
153
  - exe/next
134
154
  - exe/next.sh
155
+ - exe/next_rails
135
156
  - lib/deprecation_tracker.rb
136
157
  - lib/next_rails.rb
137
158
  - lib/next_rails/bundle_report.rb
@@ -143,7 +164,7 @@ homepage: https://github.com/fastruby/next_rails
143
164
  licenses:
144
165
  - MIT
145
166
  metadata: {}
146
- post_install_message:
167
+ post_install_message:
147
168
  rdoc_options: []
148
169
  require_paths:
149
170
  - lib
@@ -158,8 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
179
  - !ruby/object:Gem::Version
159
180
  version: '0'
160
181
  requirements: []
161
- rubygems_version: 3.1.3
162
- signing_key:
182
+ rubygems_version: 3.1.6
183
+ signing_key:
163
184
  specification_version: 4
164
185
  summary: A toolkit to upgrade your next Rails application
165
186
  test_files: []