From 50bddbea0b76b05ba2d1fe49ae706f9703130eca Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 27 Apr 2019 16:55:03 -0400 Subject: [PATCH 01/20] Add Ruby 2.2.10 to build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 20e09ea..fee4919 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ sudo: false language: ruby rvm: + - 2.2.10 - 2.3.3 before_install: gem install bundler -v 1.16.1 From 524cdd1c6728e313440c3f50bf204a9e0fc552d0 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 27 Apr 2019 16:55:35 -0400 Subject: [PATCH 02/20] Stop using <<~ for heredoc and the safe operator (&.) This is an attempt to make this gem compatible with Ruby 2.2 --- exe/bundle_report | 8 ++++---- exe/deprecations | 2 +- lib/deprecation_tracker.rb | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exe/bundle_report b/exe/bundle_report index d8b82a5..6f07f56 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -8,7 +8,7 @@ at_exit do options = {} option_parser = OptionParser.new do |opts| - opts.banner = <<~EOS + opts.banner = <<-EOS Usage: #{$0} [report-type] [options] report-type There are two report types available: `outdated` and `compatibility` @@ -76,7 +76,7 @@ class BundleReport incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) } - template = <<~ERB + template = <<-ERB <% if incompatible_gems_by_state[:latest_compatible] -%> <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %> <%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %> @@ -126,13 +126,13 @@ class BundleReport out_of_date_gems.each do |_gem| header = "#{_gem.name} #{_gem.version}" - puts <<~MESSAGE + puts <<-MESSAGE #{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age}) MESSAGE end puts "" - puts <<~MESSAGE + puts <<-MESSAGE #{"#{sourced_from_git.count}".yellow} gems are sourced from git #{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%) MESSAGE diff --git a/exe/deprecations b/exe/deprecations index beafb86..0dabad4 100755 --- a/exe/deprecations +++ b/exe/deprecations @@ -36,7 +36,7 @@ end options = {} option_parser = OptionParser.new do |opts| - opts.banner = <<~MESSAGE + opts.banner = <<-MESSAGE Usage: #{__FILE__.to_s} [options] [mode] Parses the deprecation warning shitlist and show info or run tests. diff --git a/lib/deprecation_tracker.rb b/lib/deprecation_tracker.rb index a80cac1..da192ae 100644 --- a/lib/deprecation_tracker.rb +++ b/lib/deprecation_tracker.rb @@ -86,7 +86,7 @@ def compare end if changed_buckets.length > 0 - message = <<~MESSAGE.red + message = <<-MESSAGE.red ⚠️ Deprecation warnings have changed! Code called by the following spec files is now generating different deprecation warnings: @@ -119,7 +119,7 @@ def save new_shitlist = create_temp_shitlist FileUtils.cp(new_shitlist.path, shitlist_path) ensure - new_shitlist&.delete + new_shitlist.delete if new_shitlist end def create_temp_shitlist From 6282a6615e1c6c277786c870f5d36da76cb1bcec Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 27 Apr 2019 16:56:27 -0400 Subject: [PATCH 03/20] Remove activesupport dependency --- Gemfile.lock | 7 +++---- ten_years_rails.gemspec | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 151bb5c..a09ca31 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,6 @@ PATH specs: ten_years_rails (0.2.0) actionview - activesupport colorize (>= 0.8.1) rest-client (>= 2.0.2) @@ -31,7 +30,7 @@ GEM erubi (1.8.0) http-cookie (1.0.3) domain_name (~> 0.5) - i18n (1.6.0) + i18n (1.5.1) concurrent-ruby (~> 1.0) loofah (2.2.3) crass (~> 1.0.2) @@ -42,7 +41,7 @@ GEM mini_portile2 (2.4.0) minitest (5.11.3) netrc (0.11.0) - nokogiri (1.10.2) + nokogiri (1.9.1) mini_portile2 (~> 2.4.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -72,7 +71,7 @@ GEM thread_safe (~> 0.1) unf (0.1.4) unf_ext - unf_ext (0.0.7.5) + unf_ext (0.0.7.6) PLATFORMS ruby diff --git a/ten_years_rails.gemspec b/ten_years_rails.gemspec index 1712ac7..19d7cbc 100644 --- a/ten_years_rails.gemspec +++ b/ten_years_rails.gemspec @@ -21,7 +21,6 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "actionview" - spec.add_dependency "activesupport" spec.add_dependency "colorize", ">= 0.8.1" spec.add_dependency "rest-client", ">= 2.0.2" spec.add_development_dependency "bundler", "~> 1.16" From 2db8f3885b5bd4618cd90a46de776cf5c03e2e2d Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 27 Apr 2019 16:56:56 -0400 Subject: [PATCH 04/20] Fix spec to work with Ruby 2.2.10 --- spec/deprecation_tracker_spec.rb | 82 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/spec/deprecation_tracker_spec.rb b/spec/deprecation_tracker_spec.rb index 92e5237..f161146 100644 --- a/spec/deprecation_tracker_spec.rb +++ b/spec/deprecation_tracker_spec.rb @@ -4,7 +4,7 @@ RSpec.describe DeprecationTracker do let(:shitlist_path) do - shitlist_path = Tempfile.new.path + shitlist_path = Tempfile.new("tmp").path FileUtils.rm(shitlist_path) shitlist_path end @@ -92,14 +92,14 @@ subject.save - expected_json = <<~JSON.chomp - { - "bucket 1": [ - "a", - "b", - "b" - ] - } + expected_json = <<-JSON.chomp +{ + "bucket 1": [ + "a", + "b", + "b" + ] +} JSON expect(File.read(shitlist_path)).to eq(expected_json) end @@ -116,15 +116,15 @@ subject.add("a") subject.save - expected_json = <<~JSON.chomp - { - "bucket 1": [ - "a" - ], - "bucket 2": [ - "a" - ] - } + expected_json = <<-JSON.chomp +{ + "bucket 1": [ + "a" + ], + "bucket 2": [ + "a" + ] +} JSON expect(File.read(shitlist_path)).to eq(expected_json) end @@ -141,12 +141,12 @@ subject.add("b") subject.save - expected_json = <<~JSON.chomp - { - "bucket 1": [ - "b" - ] - } + expected_json = <<-JSON.chomp +{ + "bucket 1": [ + "b" + ] +} JSON expect(File.read(shitlist_path)).to eq(expected_json) end @@ -159,15 +159,15 @@ subject.add("a") subject.save - expected_json = <<~JSON.chomp - { - "bucket 1": [ - "a" - ], - "bucket 2": [ - "a" - ] - } + expected_json = <<-JSON.chomp +{ + "bucket 1": [ + "a" + ], + "bucket 2": [ + "a" + ] +} JSON expect(File.read(shitlist_path)).to eq(expected_json) end @@ -180,14 +180,14 @@ subject.add("a") subject.save - expected_json = <<~JSON.chomp - { - "bucket 1": [ - "a", - "b", - "c" - ] - } + expected_json = <<-JSON.chomp +{ + "bucket 1": [ + "a", + "b", + "c" + ] +} JSON expect(File.read(shitlist_path)).to eq(expected_json) end From 743605a8010338fd2aa47e1cfe4306366f783699 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Tue, 14 May 2019 15:56:40 -0400 Subject: [PATCH 05/20] Make sure that Kernel.warn tracking works even in Ruby < 2.3 --- lib/deprecation_tracker.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/deprecation_tracker.rb b/lib/deprecation_tracker.rb index da192ae..62dfc31 100644 --- a/lib/deprecation_tracker.rb +++ b/lib/deprecation_tracker.rb @@ -29,11 +29,21 @@ def warn(*messages) # There are two forms of the `warn` method: one for class Kernel and one for instances of Kernel (i.e., every Object) Object.prepend(KernelWarnTracker) - Kernel.singleton_class.prepend(KernelWarnTracker) + + # Ruby 2.2 and lower doesn't appear to allow overriding of Kernel.warn using `singleton_class.prepend`. + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0") + Kernel.singleton_class.prepend(KernelWarnTracker) + else + def Kernel.warn(*args, &block) + Object.warn(*args, &block) + end + end def self.track_rspec(rspec_config, shitlist_path:, mode:, transform_message: nil) deprecation_tracker = DeprecationTracker.new(shitlist_path, transform_message) - ActiveSupport::Deprecation.behavior << -> (message, _callstack) { deprecation_tracker.add(message) } + if defined?(ActiveSupport) + ActiveSupport::Deprecation.behavior << -> (message, _callstack) { deprecation_tracker.add(message) } + end KernelWarnTracker.callbacks << -> (message) { deprecation_tracker.add(message) } rspec_config.around do |example| From c7a749a80ddc7774e70d849915de526f8856beff Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Tue, 14 May 2019 15:57:05 -0400 Subject: [PATCH 06/20] Make sure that indenting is not all weird --- exe/bundle_report | 64 +++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/exe/bundle_report b/exe/bundle_report index 6f07f56..8ebeb86 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -77,35 +77,35 @@ class BundleReport incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) } template = <<-ERB - <% if incompatible_gems_by_state[:latest_compatible] -%> - <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %> - <%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %> - - <% incompatible_gems_by_state[:latest_compatible].each do |gem| -%> - <%= gem_header(gem) %> - upgrade to <%= gem.latest_version.version %> - <% end -%> - - <% end -%> - <% if incompatible_gems_by_state[:incompatible] -%> - <%= "=> Incompatible with Rails #{rails_version} (with no new compatible versions):".white.bold %> - <%= "These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.".italic %> - - <% incompatible_gems_by_state[:incompatible].each do |gem| -%> - <%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version} - <% end -%> - - <% end -%> - <% if incompatible_gems_by_state[:no_new_version] -%> - <%= "=> Incompatible with Rails #{rails_version} (with no new versions):".white.bold %> - <%= "These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.".italic %> - <%= "This list is likely to contain internal gems, like Cuddlefish.".italic %> - - <% incompatible_gems_by_state[:no_new_version].each do |gem| -%> - <%= gem_header(gem) %> - new version not found - <% end -%> - - <% end -%> - <%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %> +<% if incompatible_gems_by_state[:latest_compatible] -%> +<%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %> +<%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %> + +<% incompatible_gems_by_state[:latest_compatible].each do |gem| -%> +<%= gem_header(gem) %> - upgrade to <%= gem.latest_version.version %> +<% end -%> + +<% end -%> +<% if incompatible_gems_by_state[:incompatible] -%> +<%= "=> Incompatible with Rails #{rails_version} (with no new compatible versions):".white.bold %> +<%= "These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.".italic %> + +<% incompatible_gems_by_state[:incompatible].each do |gem| -%> +<%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version} +<% end -%> + +<% end -%> +<% if incompatible_gems_by_state[:no_new_version] -%> +<%= "=> Incompatible with Rails #{rails_version} (with no new versions):".white.bold %> +<%= "These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.".italic %> +<%= "This list is likely to contain internal gems, like Cuddlefish.".italic %> + +<% incompatible_gems_by_state[:no_new_version].each do |gem| -%> +<%= gem_header(gem) %> - new version not found +<% end -%> + +<% end -%> +<%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %> ERB puts ERB.new(template, nil, "-").result(binding) @@ -127,14 +127,14 @@ class BundleReport header = "#{_gem.name} #{_gem.version}" puts <<-MESSAGE - #{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age}) +#{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age}) MESSAGE end puts "" puts <<-MESSAGE - #{"#{sourced_from_git.count}".yellow} gems are sourced from git - #{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%) +#{"#{sourced_from_git.count}".yellow} gems are sourced from git +#{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%) MESSAGE end From 9d8defd8a4069116c7972ea857e8889cd4ec4b6f Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 25 May 2019 15:20:50 -0400 Subject: [PATCH 07/20] Try with `time_ago_in_words` instead of `actionview` Change time_ago_in_words implementation. Using this smaller gem will make it easier to support `ten_years_rails` with older versions of Ruby. --- Gemfile.lock | 87 ----------------------------------------- exe/bundle_report | 5 +-- ten_years_rails.gemspec | 3 +- 3 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 151bb5c..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,87 +0,0 @@ -PATH - remote: . - specs: - ten_years_rails (0.2.0) - actionview - activesupport - colorize (>= 0.8.1) - rest-client (>= 2.0.2) - -GEM - remote: https://rubygems.org/ - specs: - actionview (5.2.3) - activesupport (= 5.2.3) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activesupport (5.2.3) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - builder (3.2.3) - colorize (0.8.1) - concurrent-ruby (1.1.5) - crass (1.0.4) - diff-lcs (1.3) - domain_name (0.5.20180417) - unf (>= 0.0.5, < 1.0.0) - erubi (1.8.0) - http-cookie (1.0.3) - domain_name (~> 0.5) - i18n (1.6.0) - concurrent-ruby (~> 1.0) - loofah (2.2.3) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mime-types (3.2.2) - mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) - mini_portile2 (2.4.0) - minitest (5.11.3) - netrc (0.11.0) - nokogiri (1.10.2) - mini_portile2 (~> 2.4.0) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - rake (10.5.0) - rest-client (2.0.2) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - thread_safe (0.3.6) - tzinfo (1.2.5) - thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.5) - -PLATFORMS - ruby - -DEPENDENCIES - bundler (~> 1.16) - rake (~> 10.0) - rspec (~> 3.0) - ten_years_rails! - -BUNDLED WITH - 1.17.2 diff --git a/exe/bundle_report b/exe/bundle_report index d8b82a5..ab8fd51 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -5,6 +5,7 @@ # at_exit do require "optparse" + require "time_ago_in_words" options = {} option_parser = OptionParser.new do |opts| @@ -139,8 +140,6 @@ class BundleReport end class GemInfo - include ActionView::Helpers::DateHelper - class NullGemInfo < GemInfo def initialize; end @@ -187,7 +186,7 @@ class BundleReport end def age - "#{time_ago_in_words(created_at)} ago" + created_at.ago_in_words end def sourced_from_git? diff --git a/ten_years_rails.gemspec b/ten_years_rails.gemspec index 1712ac7..60f8fec 100644 --- a/ten_years_rails.gemspec +++ b/ten_years_rails.gemspec @@ -20,8 +20,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "actionview" - spec.add_dependency "activesupport" + spec.add_dependency "time_ago_in_words" spec.add_dependency "colorize", ">= 0.8.1" spec.add_dependency "rest-client", ">= 2.0.2" spec.add_development_dependency "bundler", "~> 1.16" From 3716898260b964446a89fa12519a327bc93d4a81 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 25 May 2019 15:48:52 -0400 Subject: [PATCH 08/20] Support older versions of Ruby --- exe/bundle_report | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exe/bundle_report b/exe/bundle_report index 8ebeb86..ab9a9ef 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -245,7 +245,9 @@ class BundleReport rails_gems.include?(name) end - private def rails_gems + private + + def rails_gems [ "rails", "activemodel", From 4a0a70ad8debeff3b580a8a3a3500ac19a1a8558 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 25 May 2019 15:47:03 -0400 Subject: [PATCH 09/20] Remove named parameters to support older versions of Ruby --- exe/bundle_report | 11 ++++++++--- exe/deprecations | 7 +++++-- lib/deprecation_tracker.rb | 5 ++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/exe/bundle_report b/exe/bundle_report index ab9a9ef..51f26bd 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -64,7 +64,10 @@ require "json" require "rest-client" class BundleReport - def self.compatibility(rails_version:, include_rails_gems:) + def self.compatibility(opts = {}) + rails_version = opts[:rails_version] + include_rails_gems = opts[:include_rails_gems] + incompatible_gems = BundleReport::GemInfo.all.reject do |gem| gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?) end.sort_by do |gem| @@ -229,11 +232,13 @@ class BundleReport end end - def compatible_with_rails?(rails_version: Gem::Version.new("5.0")) + def compatible_with_rails?(opts = {}) + rails_version = opts[:rails_version] || Gem::Version.new("5.0") unsatisfied_rails_dependencies(rails_version: rails_version).empty? end - def unsatisfied_rails_dependencies(rails_version:) + def unsatisfied_rails_dependencies(opts = {}) + rails_version = opts[:rails_version] rails_dependencies = gem_specification.runtime_dependencies.select {|dependency| rails_gems.include?(dependency.name) } rails_dependencies.reject do |rails_dependency| diff --git a/exe/deprecations b/exe/deprecations index 0dabad4..3d476de 100755 --- a/exe/deprecations +++ b/exe/deprecations @@ -4,7 +4,9 @@ require "colorize" require "optparse" require "set" -def run_tests(deprecation_warnings, tracker_mode:, next_mode:) +def run_tests(deprecation_warnings, opts = {}) + tracker_mode = opts[:tracker_mode] + next_mode = opts[:next_mode] rspec_command = if next_mode "bin/next rspec" else @@ -16,7 +18,8 @@ def run_tests(deprecation_warnings, tracker_mode:, next_mode:) exec command end -def print_info(deprecation_warnings, verbose: false) +def print_info(deprecation_warnings, opts = {}) + verbose = !!opts[:verbose] frequency_by_message = deprecation_warnings.each_with_object({}) do |(test_file, messages), hash| messages.each do |message| hash[message] ||= { test_files: Set.new, occurrences: 0 } diff --git a/lib/deprecation_tracker.rb b/lib/deprecation_tracker.rb index 62dfc31..f4f4f47 100644 --- a/lib/deprecation_tracker.rb +++ b/lib/deprecation_tracker.rb @@ -39,7 +39,10 @@ def Kernel.warn(*args, &block) end end - def self.track_rspec(rspec_config, shitlist_path:, mode:, transform_message: nil) + def self.track_rspec(rspec_config, opts = {}) + shitlist_path = opts[:shitlist_path] + mode = opts[:mode] + transform_message = opts[:transform_message] deprecation_tracker = DeprecationTracker.new(shitlist_path, transform_message) if defined?(ActiveSupport) ActiveSupport::Deprecation.behavior << -> (message, _callstack) { deprecation_tracker.add(message) } From 88db2843ec063c2fdd973bcb4249f74072c90e84 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 6 Jul 2019 12:41:20 -0400 Subject: [PATCH 10/20] Remove `time_ago_in_words` dependency Also, add `timecop` dependency to test time sensitive specs --- ten_years_rails.gemspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ten_years_rails.gemspec b/ten_years_rails.gemspec index 60f8fec..8351c78 100644 --- a/ten_years_rails.gemspec +++ b/ten_years_rails.gemspec @@ -20,10 +20,11 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "time_ago_in_words" spec.add_dependency "colorize", ">= 0.8.1" spec.add_dependency "rest-client", ">= 2.0.2" spec.add_development_dependency "bundler", "~> 1.16" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "timecop", "~> 0.9.1" + spec.add_runtime_dependency "actionview" end From 1106a9e0059afa43c3846f78d62557c0f15eba64 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 6 Jul 2019 12:42:27 -0400 Subject: [PATCH 11/20] Refactor `exe/bundle_report` -- Move classes to `lib` directory This will make it a little easier to add test coverage for `GemInfo` and `BundleReport` Also, I removed unused methods and made `time_ago_in_words` a little smarter so that it doesn't depend on `ActionView` helpers --- exe/bundle_report | 207 +-------------------------- lib/ten_years_rails.rb | 2 + lib/ten_years_rails/bundle_report.rb | 83 +++++++++++ lib/ten_years_rails/gem_info.rb | 129 +++++++++++++++++ 4 files changed, 216 insertions(+), 205 deletions(-) create mode 100644 lib/ten_years_rails/bundle_report.rb create mode 100644 lib/ten_years_rails/gem_info.rb diff --git a/exe/bundle_report b/exe/bundle_report index ab8fd51..dfa60e7 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -5,7 +5,7 @@ # at_exit do require "optparse" - require "time_ago_in_words" + require "ten_years_rails" options = {} option_parser = OptionParser.new do |opts| @@ -49,7 +49,7 @@ at_exit do case report_type when "outdated" then BundleReport.outdated else - BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) + TenYearsRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) end end @@ -58,206 +58,3 @@ require "bundler/setup" require "action_view" require "active_support/core_ext/object/acts_like" -require "colorize" -require "cgi" -require "erb" -require "json" -require "rest-client" - -class BundleReport - def self.compatibility(rails_version:, include_rails_gems:) - incompatible_gems = BundleReport::GemInfo.all.reject do |gem| - gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?) - end.sort_by do |gem| - [ - gem.latest_version.compatible_with_rails?(rails_version: rails_version) ? 0 : 1, - gem.name - ].join("-") - end - - incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) } - - template = <<~ERB - <% if incompatible_gems_by_state[:latest_compatible] -%> - <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %> - <%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %> - - <% incompatible_gems_by_state[:latest_compatible].each do |gem| -%> - <%= gem_header(gem) %> - upgrade to <%= gem.latest_version.version %> - <% end -%> - - <% end -%> - <% if incompatible_gems_by_state[:incompatible] -%> - <%= "=> Incompatible with Rails #{rails_version} (with no new compatible versions):".white.bold %> - <%= "These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.".italic %> - - <% incompatible_gems_by_state[:incompatible].each do |gem| -%> - <%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version} - <% end -%> - - <% end -%> - <% if incompatible_gems_by_state[:no_new_version] -%> - <%= "=> Incompatible with Rails #{rails_version} (with no new versions):".white.bold %> - <%= "These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.".italic %> - <%= "This list is likely to contain internal gems, like Cuddlefish.".italic %> - - <% incompatible_gems_by_state[:no_new_version].each do |gem| -%> - <%= gem_header(gem) %> - new version not found - <% end -%> - - <% end -%> - <%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %> - ERB - - puts ERB.new(template, nil, "-").result(binding) - end - - def self.gem_header(_gem) - header = "#{_gem.name} #{_gem.version}".bold - header << " (loaded from git)".magenta if _gem.sourced_from_git? - header - end - - def self.outdated - gems = BundleReport::GemInfo.all - out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at) - percentage_out_of_date = ((out_of_date_gems.count / gems.count.to_f) * 100).round - sourced_from_git = gems.select(&:sourced_from_git?) - - out_of_date_gems.each do |_gem| - header = "#{_gem.name} #{_gem.version}" - - puts <<~MESSAGE - #{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age}) - MESSAGE - end - - puts "" - puts <<~MESSAGE - #{"#{sourced_from_git.count}".yellow} gems are sourced from git - #{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%) - MESSAGE - end - - class GemInfo - class NullGemInfo < GemInfo - def initialize; end - - def age - "-" - end - - def time_to_latest_version - "-" - end - - def created_at - Time.now - end - - def up_to_date? - false - end - - def version - "NOT FOUND" - end - - def unsatisfied_rails_dependencies(*) - ["unknown"] - end - - def state(_) - :null - end - end - - def self.all - Gem::Specification.each.map do |gem_specification| - new(gem_specification) - end - end - - attr_reader :gem_specification, :version, :name - def initialize(gem_specification) - @gem_specification = gem_specification - @version = gem_specification.version - @name = gem_specification.name - end - - def age - created_at.ago_in_words - end - - def sourced_from_git? - !!gem_specification.git_version - end - - def time_to_latest_version - distance_of_time_in_words(created_at, latest_version.created_at) - end - - def created_at - @created_at ||= gem_specification.date - end - - def up_to_date? - version == latest_version.version - end - - def state(rails_version) - if compatible_with_rails?(rails_version: rails_version) - :compatible - elsif latest_version.compatible_with_rails?(rails_version: rails_version) - :latest_compatible - elsif latest_version.version == "NOT FOUND" - :no_new_version - else - :incompatible - end - end - - def latest_version - @latest_version ||= begin - latest_gem_specification = Gem.latest_spec_for(name) - if latest_gem_specification - GemInfo.new(latest_gem_specification) - else - NullGemInfo.new - end - end - end - - def compatible_with_rails?(rails_version: Gem::Version.new("5.0")) - unsatisfied_rails_dependencies(rails_version: rails_version).empty? - end - - def unsatisfied_rails_dependencies(rails_version:) - rails_dependencies = gem_specification.runtime_dependencies.select {|dependency| rails_gems.include?(dependency.name) } - - rails_dependencies.reject do |rails_dependency| - rails_dependency.requirement.satisfied_by?(Gem::Version.new(rails_version)) - end - end - - def from_rails? - rails_gems.include?(name) - end - - private def rails_gems - [ - "rails", - "activemodel", - "activerecord", - "actionmailer", - "actioncable", - "actionpack", - "actionview", - "activejob", - "activestorage", - "activesupport", - "railties", - ] - end - end -end diff --git a/lib/ten_years_rails.rb b/lib/ten_years_rails.rb index f935bba..2b29775 100644 --- a/lib/ten_years_rails.rb +++ b/lib/ten_years_rails.rb @@ -1,4 +1,6 @@ +require "ten_years_rails/gem_info" require "ten_years_rails/version" +require "ten_years_rails/bundle_report" require "deprecation_tracker" module TenYearsRails diff --git a/lib/ten_years_rails/bundle_report.rb b/lib/ten_years_rails/bundle_report.rb new file mode 100644 index 0000000..db713c1 --- /dev/null +++ b/lib/ten_years_rails/bundle_report.rb @@ -0,0 +1,83 @@ +require "colorize" +require "cgi" +require "erb" +require "json" +require "rest-client" + +module TenYearsRails + class BundleReport + def self.compatibility(rails_version:, include_rails_gems:) + incompatible_gems = TenYearsRails::GemInfo.all.reject do |gem| + gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?) + end.sort_by do |gem| + [ + gem.latest_version.compatible_with_rails?(rails_version: rails_version) ? 0 : 1, + gem.name + ].join("-") + end + + incompatible_gems_by_state = incompatible_gems.group_by { |gem| gem.state(rails_version) } + + template = <<~ERB + <% if incompatible_gems_by_state[:latest_compatible] -%> + <%= "=> Incompatible with Rails #{rails_version} (with new versions that are compatible):".white.bold %> + <%= "These gems will need to be upgraded before upgrading to Rails #{rails_version}.".italic %> + + <% incompatible_gems_by_state[:latest_compatible].each do |gem| -%> + <%= gem_header(gem) %> - upgrade to <%= gem.latest_version.version %> + <% end -%> + + <% end -%> + <% if incompatible_gems_by_state[:incompatible] -%> + <%= "=> Incompatible with Rails #{rails_version} (with no new compatible versions):".white.bold %> + <%= "These gems will need to be removed or replaced before upgrading to Rails #{rails_version}.".italic %> + + <% incompatible_gems_by_state[:incompatible].each do |gem| -%> + <%= gem_header(gem) %> - new version, <%= gem.latest_version.version %>, is not compatible with Rails #{rails_version} + <% end -%> + + <% end -%> + <% if incompatible_gems_by_state[:no_new_version] -%> + <%= "=> Incompatible with Rails #{rails_version} (with no new versions):".white.bold %> + <%= "These gems will need to be upgraded by us or removed before upgrading to Rails #{rails_version}.".italic %> + <%= "This list is likely to contain internal gems, like Cuddlefish.".italic %> + + <% incompatible_gems_by_state[:no_new_version].each do |gem| -%> + <%= gem_header(gem) %> - new version not found + <% end -%> + + <% end -%> + <%= incompatible_gems.length.to_s.red %> gems incompatible with Rails <%= rails_version %> + ERB + + puts ERB.new(template, nil, "-").result(binding) + end + + def self.gem_header(_gem) + header = "#{_gem.name} #{_gem.version}".bold + header << " (loaded from git)".magenta if _gem.sourced_from_git? + header + end + + def self.outdated + gems = TenYearsRails::GemInfo.all + out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at) + percentage_out_of_date = ((out_of_date_gems.count / gems.count.to_f) * 100).round + sourced_from_git = gems.select(&:sourced_from_git?) + + out_of_date_gems.each do |_gem| + header = "#{_gem.name} #{_gem.version}" + + puts <<~MESSAGE + #{header.bold.white}: released #{_gem.age} (latest version, #{_gem.latest_version.version}, released #{_gem.latest_version.age}) + MESSAGE + end + + puts "" + puts <<~MESSAGE + #{"#{sourced_from_git.count}".yellow} gems are sourced from git + #{"#{out_of_date_gems.length}".red} of the #{gems.count} gems are out-of-date (#{percentage_out_of_date}%) + MESSAGE + end + end +end diff --git a/lib/ten_years_rails/gem_info.rb b/lib/ten_years_rails/gem_info.rb new file mode 100644 index 0000000..e0cf67e --- /dev/null +++ b/lib/ten_years_rails/gem_info.rb @@ -0,0 +1,129 @@ +begin + require "action_view" +rescue LoadError + puts "ActionView not available" +end + +module TenYearsRails + class GemInfo + if defined?(ActionView) + include ActionView::Helpers::DateHelper + end + + class NullGemInfo < GemInfo + def initialize; end + + def age + "-" + end + + def created_at + Time.now + end + + def up_to_date? + false + end + + def version + "NOT FOUND" + end + + def unsatisfied_rails_dependencies(*) + ["unknown"] + end + + def state(_) + :null + end + end + + def self.all + Gem::Specification.each.map do |gem_specification| + new(gem_specification) + end + end + + attr_reader :gem_specification, :version, :name + def initialize(gem_specification) + @gem_specification = gem_specification + @version = gem_specification.version + @name = gem_specification.name + end + + def age + if respond_to?(:time_ago_in_words) + "#{time_ago_in_words(created_at)} ago" + else + created_at.strftime("%b %e, %Y") + end + end + + def sourced_from_git? + !!gem_specification.git_version + end + + def created_at + @created_at ||= gem_specification.date + end + + def up_to_date? + version == latest_version.version + end + + def state(rails_version) + if compatible_with_rails?(rails_version: rails_version) + :compatible + elsif latest_version.compatible_with_rails?(rails_version: rails_version) + :latest_compatible + elsif latest_version.version == "NOT FOUND" + :no_new_version + else + :incompatible + end + end + + def latest_version + @latest_version ||= begin + latest_gem_specification = Gem.latest_spec_for(name) + if latest_gem_specification + GemInfo.new(latest_gem_specification) + else + NullGemInfo.new + end + end + end + + def compatible_with_rails?(rails_version: Gem::Version.new("5.0")) + unsatisfied_rails_dependencies(rails_version: rails_version).empty? + end + + def unsatisfied_rails_dependencies(rails_version:) + rails_dependencies = gem_specification.runtime_dependencies.select {|dependency| rails_gems.include?(dependency.name) } + + rails_dependencies.reject do |rails_dependency| + rails_dependency.requirement.satisfied_by?(Gem::Version.new(rails_version)) + end + end + + def from_rails? + rails_gems.include?(name) + end + + private def rails_gems + [ + "rails", + "activemodel", + "activerecord", + "actionmailer", + "actioncable", + "actionpack", + "actionview", + "activejob", + "activestorage", + "activesupport", + "railties", + ] + end + end +end From 7c8cd1cf3950eb8024ba57cd027f3bf02750e781 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 6 Jul 2019 12:43:46 -0400 Subject: [PATCH 12/20] Add coverage for `age` method --- spec/ten_years_rails/gem_info_spec.rb | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/ten_years_rails/gem_info_spec.rb diff --git a/spec/ten_years_rails/gem_info_spec.rb b/spec/ten_years_rails/gem_info_spec.rb new file mode 100644 index 0000000..245492b --- /dev/null +++ b/spec/ten_years_rails/gem_info_spec.rb @@ -0,0 +1,40 @@ +require "spec_helper" +require "timecop" + +RSpec.describe TenYearsRails::GemInfo do + let(:release_date) { Time.utc(2019, 7, 6, 0, 0, 0) } + let(:now) { Time.utc(2019, 7, 6, 12, 0, 0) } + let(:spec) do + Gem::Specification.new do |s| + s.date = release_date + end + end + + subject { TenYearsRails::GemInfo.new(spec) } + + describe "#age" do + around do |example| + Timecop.travel(now) do + example.run + end + end + + context "when ActionView is available" do + it "returns a time ago" do + expect(subject.age).to eq("about 12 hours ago") + end + end + + context "when ActionView is not available" do + let(:result) { now.strftime("%b %e, %Y") } + + before do + subject.instance_eval('undef :time_ago_in_words') + end + + it "returns a date" do + expect(subject.age).to eq(result) + end + end + end +end From 94d5ed9bac08fabdd576506b146b6427ea396e30 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Sat, 6 Jul 2019 12:44:29 -0400 Subject: [PATCH 13/20] Add .ruby-version and .byebug_history to list of ignored files --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index b04a8c8..01a4218 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,9 @@ /spec/reports/ /tmp/ +.byebug_history + # rspec failure tracking .rspec_status + +.ruby-version From cfde4ac6cb4524f1946d6b1fb395e091ec9b28b2 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Tue, 23 Jul 2019 22:14:57 -0400 Subject: [PATCH 14/20] Bundled --- Gemfile.lock | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..715ce39 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,90 @@ +PATH + remote: . + specs: + ten_years_rails (0.2.0) + actionview + colorize (>= 0.8.1) + rest-client (>= 2.0.2) + +GEM + remote: https://rubygems.org/ + specs: + actionview (5.2.3) + activesupport (= 5.2.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activesupport (5.2.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + builder (3.2.3) + byebug (11.0.1) + colorize (0.8.1) + concurrent-ruby (1.1.5) + crass (1.0.4) + diff-lcs (1.3) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + erubi (1.8.0) + http-cookie (1.0.3) + domain_name (~> 0.5) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + loofah (2.2.3) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.0331) + mini_portile2 (2.4.0) + minitest (5.11.3) + netrc (0.11.0) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + rake (10.5.0) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-core (3.8.2) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.4) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-mocks (3.8.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.2) + thread_safe (0.3.6) + timecop (0.9.1) + tzinfo (1.2.5) + thread_safe (~> 0.1) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.6) + +PLATFORMS + ruby + +DEPENDENCIES + bundler (~> 1.16) + byebug + rake (~> 10.0) + rspec (~> 3.0) + ten_years_rails! + timecop (~> 0.9.1) + +BUNDLED WITH + 1.16.6 From 38d89f0b11c40740addd89dc9a582a7612dd4e38 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Tue, 23 Jul 2019 22:23:38 -0400 Subject: [PATCH 15/20] Bundled and removed unnecessary require --- Gemfile.lock | 20 +------------------- lib/ten_years_rails/bundle_report.rb | 1 - 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 715ce39..20408a2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,6 @@ PATH ten_years_rails (0.2.0) actionview colorize (>= 0.8.1) - rest-client (>= 2.0.2) GEM remote: https://rubygems.org/ @@ -21,27 +20,18 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) builder (3.2.3) - byebug (11.0.1) colorize (0.8.1) concurrent-ruby (1.1.5) crass (1.0.4) diff-lcs (1.3) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) erubi (1.8.0) - http-cookie (1.0.3) - domain_name (~> 0.5) i18n (1.6.0) concurrent-ruby (~> 1.0) loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mime-types (3.2.2) - mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) mini_portile2 (2.4.0) minitest (5.11.3) - netrc (0.11.0) nokogiri (1.10.3) mini_portile2 (~> 2.4.0) rails-dom-testing (2.0.3) @@ -50,10 +40,6 @@ GEM rails-html-sanitizer (1.0.4) loofah (~> 2.2, >= 2.2.2) rake (10.5.0) - rest-client (2.0.2) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 4.0) - netrc (~> 0.8) rspec (3.8.0) rspec-core (~> 3.8.0) rspec-expectations (~> 3.8.0) @@ -71,20 +57,16 @@ GEM timecop (0.9.1) tzinfo (1.2.5) thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.6) PLATFORMS ruby DEPENDENCIES bundler (~> 1.16) - byebug rake (~> 10.0) rspec (~> 3.0) ten_years_rails! timecop (~> 0.9.1) BUNDLED WITH - 1.16.6 + 1.17.2 diff --git a/lib/ten_years_rails/bundle_report.rb b/lib/ten_years_rails/bundle_report.rb index db713c1..ea2fcec 100644 --- a/lib/ten_years_rails/bundle_report.rb +++ b/lib/ten_years_rails/bundle_report.rb @@ -2,7 +2,6 @@ require "cgi" require "erb" require "json" -require "rest-client" module TenYearsRails class BundleReport From ad5762b949c69391520a288e3ff96f66cdfb1bf8 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Tue, 23 Jul 2019 22:32:32 -0400 Subject: [PATCH 16/20] Rename gem as `next_rails` to be shipped ASAP I really need to have some of the changes that have been submitted to https://github.com/clio/ten_years_rails, so I've decided to launch a gem so that I can use it in an upcoming workshop --- Gemfile | 2 +- Gemfile.lock | 4 ++-- README.md | 4 ++-- bin/console | 2 +- exe/bundle_report | 2 +- lib/next_rails.rb | 8 ++++++++ lib/{ten_years_rails => next_rails}/bundle_report.rb | 0 lib/{ten_years_rails => next_rails}/gem_info.rb | 0 lib/{ten_years_rails => next_rails}/version.rb | 2 +- lib/ten_years_rails.rb | 8 -------- ten_years_rails.gemspec => next_rails.gemspec | 10 +++++----- spec/spec_helper.rb | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 lib/next_rails.rb rename lib/{ten_years_rails => next_rails}/bundle_report.rb (100%) rename lib/{ten_years_rails => next_rails}/gem_info.rb (100%) rename lib/{ten_years_rails => next_rails}/version.rb (55%) delete mode 100644 lib/ten_years_rails.rb rename ten_years_rails.gemspec => next_rails.gemspec (78%) diff --git a/Gemfile b/Gemfile index de8543e..477ed7f 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } -# Specify your gem's dependencies in ten_years_rails.gemspec +# Specify your gem's dependencies in next_rails.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 20408a2..53558c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ten_years_rails (0.2.0) + next_rails (0.2.0) actionview colorize (>= 0.8.1) @@ -63,9 +63,9 @@ PLATFORMS DEPENDENCIES bundler (~> 1.16) + next_rails! rake (~> 10.0) rspec (~> 3.0) - ten_years_rails! timecop (~> 0.9.1) BUNDLED WITH diff --git a/README.md b/README.md index e86c4c2..4c535c0 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ next rails s # Start server using Gemfile.next Add this line to your application's Gemfile: ```ruby -gem 'ten_years_rails' +gem 'next_rails' ``` And then execute: @@ -89,7 +89,7 @@ And then execute: Or install it yourself as: - $ gem install ten_years_rails + $ gem install next_rails ## License diff --git a/bin/console b/bin/console index 8126674..4f0e904 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "ten_years_rails" +require "next_rails" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. diff --git a/exe/bundle_report b/exe/bundle_report index a8fe9ec..aefb863 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -5,7 +5,7 @@ # at_exit do require "optparse" - require "ten_years_rails" + require "next_rails" options = {} option_parser = OptionParser.new do |opts| diff --git a/lib/next_rails.rb b/lib/next_rails.rb new file mode 100644 index 0000000..33c9d42 --- /dev/null +++ b/lib/next_rails.rb @@ -0,0 +1,8 @@ +require "next_rails/gem_info" +require "next_rails/version" +require "next_rails/bundle_report" +require "deprecation_tracker" + +module TenYearsRails + # Your code goes here... +end diff --git a/lib/ten_years_rails/bundle_report.rb b/lib/next_rails/bundle_report.rb similarity index 100% rename from lib/ten_years_rails/bundle_report.rb rename to lib/next_rails/bundle_report.rb diff --git a/lib/ten_years_rails/gem_info.rb b/lib/next_rails/gem_info.rb similarity index 100% rename from lib/ten_years_rails/gem_info.rb rename to lib/next_rails/gem_info.rb diff --git a/lib/ten_years_rails/version.rb b/lib/next_rails/version.rb similarity index 55% rename from lib/ten_years_rails/version.rb rename to lib/next_rails/version.rb index 1ab27a9..f6268de 100644 --- a/lib/ten_years_rails/version.rb +++ b/lib/next_rails/version.rb @@ -1,3 +1,3 @@ module TenYearsRails - VERSION = "0.2.0" + VERSION = "1.0.0" end diff --git a/lib/ten_years_rails.rb b/lib/ten_years_rails.rb deleted file mode 100644 index 2b29775..0000000 --- a/lib/ten_years_rails.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "ten_years_rails/gem_info" -require "ten_years_rails/version" -require "ten_years_rails/bundle_report" -require "deprecation_tracker" - -module TenYearsRails - # Your code goes here... -end diff --git a/ten_years_rails.gemspec b/next_rails.gemspec similarity index 78% rename from ten_years_rails.gemspec rename to next_rails.gemspec index f9edb0a..72438de 100644 --- a/ten_years_rails.gemspec +++ b/next_rails.gemspec @@ -1,17 +1,17 @@ lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "ten_years_rails/version" +require "next_rails/version" Gem::Specification.new do |spec| - spec.name = "ten_years_rails" + spec.name = "next_rails" spec.version = TenYearsRails::VERSION - spec.authors = ["Jordan Raine"] - spec.email = ["jnraine@gmail.com"] + spec.authors = ["Jordan Raine", "Ernesto Tagwerker"] + spec.email = ["jnraine@gmail.com", "ernesto@ombulabs.com"] spec.summary = %q{Companion code to Ten Years of Rails Upgrades} spec.description = %q{A set of handy tools to upgrade your Rails application and keep it up to date} - spec.homepage = "https://github.com/clio/ten_years_rails" + spec.homepage = "https://github.com/fastruby/ten_years_rails" spec.license = "MIT" spec.required_ruby_version = ">= 2.3.0" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 570a8a5..61b037a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require "bundler/setup" -require "ten_years_rails" +require "next_rails" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure From 636083fa12fc5bcc3ccf4c16a6379737491b49d8 Mon Sep 17 00:00:00 2001 From: Ernesto Tagwerker Date: Fri, 26 Jul 2019 21:56:11 -0400 Subject: [PATCH 17/20] Rename gem and classes --- Gemfile.lock | 2 +- exe/bundle_report | 4 ++-- lib/next_rails.rb | 2 +- lib/next_rails/bundle_report.rb | 6 +++--- lib/next_rails/gem_info.rb | 2 +- lib/next_rails/version.rb | 4 ++-- next_rails.gemspec | 2 +- spec/ten_years_rails/gem_info_spec.rb | 4 ++-- spec/ten_years_rails_spec.rb | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 53558c8..cddf5dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - next_rails (0.2.0) + next_rails (1.0.0) actionview colorize (>= 0.8.1) diff --git a/exe/bundle_report b/exe/bundle_report index aefb863..aab61cc 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -47,9 +47,9 @@ at_exit do report_type = ARGV.first case report_type - when "outdated" then BundleReport.outdated + when "outdated" then NextRails::BundleReport.outdated else - TenYearsRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) + NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) end end diff --git a/lib/next_rails.rb b/lib/next_rails.rb index 33c9d42..105b252 100644 --- a/lib/next_rails.rb +++ b/lib/next_rails.rb @@ -3,6 +3,6 @@ require "next_rails/bundle_report" require "deprecation_tracker" -module TenYearsRails +module NextRails # Your code goes here... end diff --git a/lib/next_rails/bundle_report.rb b/lib/next_rails/bundle_report.rb index ea2fcec..11c89d4 100644 --- a/lib/next_rails/bundle_report.rb +++ b/lib/next_rails/bundle_report.rb @@ -3,10 +3,10 @@ require "erb" require "json" -module TenYearsRails +module NextRails class BundleReport def self.compatibility(rails_version:, include_rails_gems:) - incompatible_gems = TenYearsRails::GemInfo.all.reject do |gem| + incompatible_gems = NextRails::GemInfo.all.reject do |gem| gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?) end.sort_by do |gem| [ @@ -59,7 +59,7 @@ def self.gem_header(_gem) end def self.outdated - gems = TenYearsRails::GemInfo.all + gems = NextRails::GemInfo.all out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at) percentage_out_of_date = ((out_of_date_gems.count / gems.count.to_f) * 100).round sourced_from_git = gems.select(&:sourced_from_git?) diff --git a/lib/next_rails/gem_info.rb b/lib/next_rails/gem_info.rb index e0cf67e..6afc825 100644 --- a/lib/next_rails/gem_info.rb +++ b/lib/next_rails/gem_info.rb @@ -4,7 +4,7 @@ puts "ActionView not available" end -module TenYearsRails +module NextRails class GemInfo if defined?(ActionView) include ActionView::Helpers::DateHelper diff --git a/lib/next_rails/version.rb b/lib/next_rails/version.rb index f6268de..bc2d8ea 100644 --- a/lib/next_rails/version.rb +++ b/lib/next_rails/version.rb @@ -1,3 +1,3 @@ -module TenYearsRails - VERSION = "1.0.0" +module NextRails + VERSION = "1.0.1" end diff --git a/next_rails.gemspec b/next_rails.gemspec index 72438de..3e37d9a 100644 --- a/next_rails.gemspec +++ b/next_rails.gemspec @@ -5,7 +5,7 @@ require "next_rails/version" Gem::Specification.new do |spec| spec.name = "next_rails" - spec.version = TenYearsRails::VERSION + spec.version = NextRails::VERSION spec.authors = ["Jordan Raine", "Ernesto Tagwerker"] spec.email = ["jnraine@gmail.com", "ernesto@ombulabs.com"] diff --git a/spec/ten_years_rails/gem_info_spec.rb b/spec/ten_years_rails/gem_info_spec.rb index 245492b..80dd989 100644 --- a/spec/ten_years_rails/gem_info_spec.rb +++ b/spec/ten_years_rails/gem_info_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "timecop" -RSpec.describe TenYearsRails::GemInfo do +RSpec.describe NextRails::GemInfo do let(:release_date) { Time.utc(2019, 7, 6, 0, 0, 0) } let(:now) { Time.utc(2019, 7, 6, 12, 0, 0) } let(:spec) do @@ -10,7 +10,7 @@ end end - subject { TenYearsRails::GemInfo.new(spec) } + subject { NextRails::GemInfo.new(spec) } describe "#age" do around do |example| diff --git a/spec/ten_years_rails_spec.rb b/spec/ten_years_rails_spec.rb index 6bd41d9..1399699 100644 --- a/spec/ten_years_rails_spec.rb +++ b/spec/ten_years_rails_spec.rb @@ -1,5 +1,5 @@ -RSpec.describe TenYearsRails do +RSpec.describe NextRails do it "has a version number" do - expect(TenYearsRails::VERSION).not_to be nil + expect(NextRails::VERSION).not_to be nil end end From ff9fa51985a3ecb4bdb0262d2f2a6ac8988579a5 Mon Sep 17 00:00:00 2001 From: Jamie Macey Date: Wed, 25 Sep 2019 18:05:00 -0700 Subject: [PATCH 18/20] Update homepage in gemspec --- next_rails.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next_rails.gemspec b/next_rails.gemspec index 3e37d9a..fd58fe3 100644 --- a/next_rails.gemspec +++ b/next_rails.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |spec| spec.summary = %q{Companion code to Ten Years of Rails Upgrades} spec.description = %q{A set of handy tools to upgrade your Rails application and keep it up to date} - spec.homepage = "https://github.com/fastruby/ten_years_rails" + spec.homepage = "https://github.com/fastruby/next_rails" spec.license = "MIT" spec.required_ruby_version = ">= 2.3.0" From 79658d95cb995c6a7caedf13d98ab25b31c3f121 Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Thu, 5 Dec 2019 08:21:37 -0800 Subject: [PATCH 19/20] next_rails -> ten_years_rails --- Gemfile | 2 +- Gemfile.lock | 4 ++-- README.md | 4 ++-- bin/console | 2 +- exe/bundle_report | 6 +++--- lib/next_rails.rb | 8 -------- lib/ten_years_rails.rb | 8 ++++++++ lib/{next_rails => ten_years_rails}/bundle_report.rb | 6 +++--- lib/{next_rails => ten_years_rails}/gem_info.rb | 2 +- lib/{next_rails => ten_years_rails}/version.rb | 2 +- spec/spec_helper.rb | 2 +- spec/ten_years_rails/gem_info_spec.rb | 4 ++-- spec/ten_years_rails_spec.rb | 4 ++-- next_rails.gemspec => ten_years_rails.gemspec | 8 ++++---- 14 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 lib/next_rails.rb create mode 100644 lib/ten_years_rails.rb rename lib/{next_rails => ten_years_rails}/bundle_report.rb (96%) rename lib/{next_rails => ten_years_rails}/gem_info.rb (99%) rename lib/{next_rails => ten_years_rails}/version.rb (53%) rename next_rails.gemspec => ten_years_rails.gemspec (85%) diff --git a/Gemfile b/Gemfile index 477ed7f..de8543e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,5 +2,5 @@ source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } -# Specify your gem's dependencies in next_rails.gemspec +# Specify your gem's dependencies in ten_years_rails.gemspec gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 631051b..652a9fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - next_rails (1.0.0) + ten_years_rails (1.0.0) actionview colorize (>= 0.8.1) @@ -63,7 +63,7 @@ PLATFORMS DEPENDENCIES bundler (~> 1.16) - next_rails! + ten_years_rails! rake (~> 10.0) rspec (~> 3.0) timecop (~> 0.9.1) diff --git a/README.md b/README.md index 4c535c0..e86c4c2 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ next rails s # Start server using Gemfile.next Add this line to your application's Gemfile: ```ruby -gem 'next_rails' +gem 'ten_years_rails' ``` And then execute: @@ -89,7 +89,7 @@ And then execute: Or install it yourself as: - $ gem install next_rails + $ gem install ten_years_rails ## License diff --git a/bin/console b/bin/console index 4f0e904..8126674 100755 --- a/bin/console +++ b/bin/console @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require "bundler/setup" -require "next_rails" +require "ten_years_rails" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. diff --git a/exe/bundle_report b/exe/bundle_report index aab61cc..064a658 100755 --- a/exe/bundle_report +++ b/exe/bundle_report @@ -5,7 +5,7 @@ # at_exit do require "optparse" - require "next_rails" + require "ten_years_rails" options = {} option_parser = OptionParser.new do |opts| @@ -47,9 +47,9 @@ at_exit do report_type = ARGV.first case report_type - when "outdated" then NextRails::BundleReport.outdated + when "outdated" then TenYearsRails::BundleReport.outdated else - NextRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) + TenYearsRails::BundleReport.compatibility(rails_version: options.fetch(:rails_version, "5.0"), include_rails_gems: options.fetch(:include_rails_gems, false)) end end diff --git a/lib/next_rails.rb b/lib/next_rails.rb deleted file mode 100644 index 105b252..0000000 --- a/lib/next_rails.rb +++ /dev/null @@ -1,8 +0,0 @@ -require "next_rails/gem_info" -require "next_rails/version" -require "next_rails/bundle_report" -require "deprecation_tracker" - -module NextRails - # Your code goes here... -end diff --git a/lib/ten_years_rails.rb b/lib/ten_years_rails.rb new file mode 100644 index 0000000..2b29775 --- /dev/null +++ b/lib/ten_years_rails.rb @@ -0,0 +1,8 @@ +require "ten_years_rails/gem_info" +require "ten_years_rails/version" +require "ten_years_rails/bundle_report" +require "deprecation_tracker" + +module TenYearsRails + # Your code goes here... +end diff --git a/lib/next_rails/bundle_report.rb b/lib/ten_years_rails/bundle_report.rb similarity index 96% rename from lib/next_rails/bundle_report.rb rename to lib/ten_years_rails/bundle_report.rb index 11c89d4..ea2fcec 100644 --- a/lib/next_rails/bundle_report.rb +++ b/lib/ten_years_rails/bundle_report.rb @@ -3,10 +3,10 @@ require "erb" require "json" -module NextRails +module TenYearsRails class BundleReport def self.compatibility(rails_version:, include_rails_gems:) - incompatible_gems = NextRails::GemInfo.all.reject do |gem| + incompatible_gems = TenYearsRails::GemInfo.all.reject do |gem| gem.compatible_with_rails?(rails_version: rails_version) || (!include_rails_gems && gem.from_rails?) end.sort_by do |gem| [ @@ -59,7 +59,7 @@ def self.gem_header(_gem) end def self.outdated - gems = NextRails::GemInfo.all + gems = TenYearsRails::GemInfo.all out_of_date_gems = gems.reject(&:up_to_date?).sort_by(&:created_at) percentage_out_of_date = ((out_of_date_gems.count / gems.count.to_f) * 100).round sourced_from_git = gems.select(&:sourced_from_git?) diff --git a/lib/next_rails/gem_info.rb b/lib/ten_years_rails/gem_info.rb similarity index 99% rename from lib/next_rails/gem_info.rb rename to lib/ten_years_rails/gem_info.rb index 6afc825..e0cf67e 100644 --- a/lib/next_rails/gem_info.rb +++ b/lib/ten_years_rails/gem_info.rb @@ -4,7 +4,7 @@ puts "ActionView not available" end -module NextRails +module TenYearsRails class GemInfo if defined?(ActionView) include ActionView::Helpers::DateHelper diff --git a/lib/next_rails/version.rb b/lib/ten_years_rails/version.rb similarity index 53% rename from lib/next_rails/version.rb rename to lib/ten_years_rails/version.rb index bc2d8ea..65b8e2a 100644 --- a/lib/next_rails/version.rb +++ b/lib/ten_years_rails/version.rb @@ -1,3 +1,3 @@ -module NextRails +module TenYearsRails VERSION = "1.0.1" end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 61b037a..570a8a5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,5 @@ require "bundler/setup" -require "next_rails" +require "ten_years_rails" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure diff --git a/spec/ten_years_rails/gem_info_spec.rb b/spec/ten_years_rails/gem_info_spec.rb index 80dd989..245492b 100644 --- a/spec/ten_years_rails/gem_info_spec.rb +++ b/spec/ten_years_rails/gem_info_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" require "timecop" -RSpec.describe NextRails::GemInfo do +RSpec.describe TenYearsRails::GemInfo do let(:release_date) { Time.utc(2019, 7, 6, 0, 0, 0) } let(:now) { Time.utc(2019, 7, 6, 12, 0, 0) } let(:spec) do @@ -10,7 +10,7 @@ end end - subject { NextRails::GemInfo.new(spec) } + subject { TenYearsRails::GemInfo.new(spec) } describe "#age" do around do |example| diff --git a/spec/ten_years_rails_spec.rb b/spec/ten_years_rails_spec.rb index 1399699..6bd41d9 100644 --- a/spec/ten_years_rails_spec.rb +++ b/spec/ten_years_rails_spec.rb @@ -1,5 +1,5 @@ -RSpec.describe NextRails do +RSpec.describe TenYearsRails do it "has a version number" do - expect(NextRails::VERSION).not_to be nil + expect(TenYearsRails::VERSION).not_to be nil end end diff --git a/next_rails.gemspec b/ten_years_rails.gemspec similarity index 85% rename from next_rails.gemspec rename to ten_years_rails.gemspec index fd58fe3..6951006 100644 --- a/next_rails.gemspec +++ b/ten_years_rails.gemspec @@ -1,17 +1,17 @@ lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "next_rails/version" +require "ten_years_rails/version" Gem::Specification.new do |spec| - spec.name = "next_rails" - spec.version = NextRails::VERSION + spec.name = "ten_years_rails" + spec.version = TenYearsRails::VERSION spec.authors = ["Jordan Raine", "Ernesto Tagwerker"] spec.email = ["jnraine@gmail.com", "ernesto@ombulabs.com"] spec.summary = %q{Companion code to Ten Years of Rails Upgrades} spec.description = %q{A set of handy tools to upgrade your Rails application and keep it up to date} - spec.homepage = "https://github.com/fastruby/next_rails" + spec.homepage = "https://github.com/clio/ten_years_rails" spec.license = "MIT" spec.required_ruby_version = ">= 2.3.0" From d824ccc9e1a53f73a38a6115611966c6b60eecfd Mon Sep 17 00:00:00 2001 From: Alex Taylor Date: Thu, 5 Dec 2019 08:38:30 -0800 Subject: [PATCH 20/20] Update actionview --- Gemfile.lock | 26 +++++++++++++------------- ten_years_rails.gemspec | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 652a9fb..76019c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,20 +1,20 @@ PATH remote: . specs: - ten_years_rails (1.0.0) - actionview + ten_years_rails (1.0.1) + actionview (~> 5.2.3) colorize (>= 0.8.1) GEM remote: https://rubygems.org/ specs: - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (5.2.4) + activesupport (= 5.2.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activesupport (5.2.3) + activesupport (5.2.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -24,21 +24,21 @@ GEM concurrent-ruby (1.1.5) crass (1.0.5) diff-lcs (1.3) - erubi (1.8.0) - i18n (1.6.0) + erubi (1.9.0) + i18n (1.7.0) concurrent-ruby (~> 1.0) - loofah (2.3.1) + loofah (2.4.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mini_portile2 (2.4.0) - minitest (5.11.3) - nokogiri (1.10.5) + minitest (5.13.0) + nokogiri (1.10.7) mini_portile2 (~> 2.4.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rake (10.5.0) rspec (3.8.0) rspec-core (~> 3.8.0) @@ -63,9 +63,9 @@ PLATFORMS DEPENDENCIES bundler (~> 1.16) - ten_years_rails! rake (~> 10.0) rspec (~> 3.0) + ten_years_rails! timecop (~> 0.9.1) BUNDLED WITH diff --git a/ten_years_rails.gemspec b/ten_years_rails.gemspec index 6951006..4f37a1f 100644 --- a/ten_years_rails.gemspec +++ b/ten_years_rails.gemspec @@ -28,5 +28,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "timecop", "~> 0.9.1" - spec.add_runtime_dependency "actionview" + spec.add_runtime_dependency "actionview", "~> 5.2.3" end