From 746e48797292c6eb70eb398ee6d4ed4afd683c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 30 Sep 2019 18:07:51 +0200 Subject: [PATCH 01/22] Reword one spec --- spec/commands/outdated_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index ae54b9d8665..9ae74f4c313 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -143,7 +143,7 @@ def test_group_option(group = nil, gems_list_size = 1) end end - describe "with --group option and outdated transitive dependencies" do + describe "with --groups option and outdated transitive dependencies" do before do update_repo2 do build_gem "bar", %w[2.0.0] From dba2a0b62a86dc3ac5bb358c525777208199f330 Mon Sep 17 00:00:00 2001 From: Todd Lynam Date: Thu, 27 Oct 2016 21:12:38 -0700 Subject: [PATCH 02/22] Improve readability of outdated --- lib/bundler/cli.rb | 1 + lib/bundler/cli/outdated.rb | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0083f7e7de7..c3dc691c11d 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -407,6 +407,7 @@ def add(*gems) "Use minimal formatting for more parseable output" method_option "only-explicit", :type => :boolean, :banner => "Only list gems specified in your Gemfile, not their dependencies" + method_option "pretty", :type => :boolean, :banner => "Use pretty formatting" def outdated(*gems) require_relative "cli/outdated" Outdated.new(options, gems).run diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index ae40d050217..b5b3356f862 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -111,6 +111,21 @@ def run print_gems(gems) end + elsif options[:pretty] + header = ["Gem Name", "Installed", "New", "Requested", "Groups"] + header << "Load Path" if options[:verbose] + + outdated_gems_list.map! do |gem| + current_version = "#{gem[:current_spec].version}#{gem[:current_spec].git_version}" + spec_version = "#{gem[:active_spec].version}#{gem[:active_spec].git_version}" + dependency = gem[:dependency].requirement if gem[:dependency] && gem[:dependency].specific? + + ret_val = [gem[:active_spec].name, current_version, spec_version, dependency.to_s, gem[:groups].to_s] + ret_val << gem[:active_spec].loaded_from if options[:verbose] + ret_val + end + + print_indented header, *outdated_gems_list else print_gems(outdated_gems_list) end @@ -253,5 +268,23 @@ def get_version_semver_portion_value(spec, version_portion_index) version_section = spec.version.segments[version_portion_index, 1] version_section.to_a[0].to_i end + + def print_indented(*data) + columns = data.first.size + + column_sizes = Array.new(columns) do |index| + data.max_by {|row| row[index].to_s.length }[index].length + end + + data.sort_by! {|row| row[0] } + + data.each do |row| + row = row.each_with_index.map do |element, index| + element.to_s.ljust(column_sizes[index]) + end + + Bundler.ui.info row.join(" ") + "\n" + end + end end end From c004288901687775f68545e3f01750851d5707b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 30 Sep 2019 18:19:56 +0200 Subject: [PATCH 03/22] Extract table header to a method --- lib/bundler/cli/outdated.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index b5b3356f862..9da8fc8f1d0 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -112,9 +112,6 @@ def run print_gems(gems) end elsif options[:pretty] - header = ["Gem Name", "Installed", "New", "Requested", "Groups"] - header << "Load Path" if options[:verbose] - outdated_gems_list.map! do |gem| current_version = "#{gem[:current_spec].version}#{gem[:current_spec].git_version}" spec_version = "#{gem[:active_spec].version}#{gem[:active_spec].git_version}" @@ -125,7 +122,7 @@ def run ret_val end - print_indented header, *outdated_gems_list + print_indented table_header, *outdated_gems_list else print_gems(outdated_gems_list) end @@ -286,5 +283,11 @@ def print_indented(*data) Bundler.ui.info row.join(" ") + "\n" end end + + def table_header + header = ["Gem Name", "Installed", "New", "Requested", "Groups"] + header << "Load Path" if options[:verbose] + header + end end end From cf0ac921e5c2dcfbdeb55155392ca68c10f1fd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 30 Sep 2019 18:25:27 +0200 Subject: [PATCH 04/22] Make hash alignment style more diff-friendly With this, if we rename the hash, we don't have to change the indentation of every entry to keep it consistent. --- lib/bundler/cli/outdated.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 9da8fc8f1d0..d69404278aa 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -87,10 +87,12 @@ def run groups = dependency.groups.join(", ") end - outdated_gems_list << { :active_spec => active_spec, - :current_spec => current_spec, - :dependency => dependency, - :groups => groups } + outdated_gems_list << { + :active_spec => active_spec, + :current_spec => current_spec, + :dependency => dependency, + :groups => groups, + } end if outdated_gems_list.empty? From 3742b33af58a3619044facbbaa2bd48fb80cfa60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 30 Sep 2019 18:30:35 +0200 Subject: [PATCH 05/22] Rename outdated_gems_list The list part doesn't add much and it's very implementation dependent. --- lib/bundler/cli/outdated.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index d69404278aa..fc58b6a3db2 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -3,7 +3,7 @@ module Bundler class CLI::Outdated attr_reader :options, :gems, :options_include_groups, :filter_options_patch, :sources, :strict - attr_accessor :outdated_gems_list + attr_accessor :outdated_gems def initialize(options, gems) @options = options @@ -12,7 +12,7 @@ def initialize(options, gems) @filter_options_patch = options.keys & %w[filter-major filter-minor filter-patch] - @outdated_gems_list = [] + @outdated_gems = [] @options_include_groups = [:group, :groups].any? do |v| options.keys.include?(v.to_s) @@ -87,7 +87,7 @@ def run groups = dependency.groups.join(", ") end - outdated_gems_list << { + outdated_gems << { :active_spec => active_spec, :current_spec => current_spec, :dependency => dependency, @@ -95,7 +95,7 @@ def run } end - if outdated_gems_list.empty? + if outdated_gems.empty? display_nothing_outdated_message else unless options[:parseable] @@ -103,7 +103,7 @@ def run end if options_include_groups - outdated_gems_list.group_by {|g| g[:groups] }.sort.each do |groups, gems| + outdated_gems.group_by {|g| g[:groups] }.sort.each do |groups, gems| contains_group = groups.split(", ").include?(options[:group]) next unless options[:groups] || contains_group @@ -114,7 +114,7 @@ def run print_gems(gems) end elsif options[:pretty] - outdated_gems_list.map! do |gem| + outdated_gems.map! do |gem| current_version = "#{gem[:current_spec].version}#{gem[:current_spec].git_version}" spec_version = "#{gem[:active_spec].version}#{gem[:active_spec].git_version}" dependency = gem[:dependency].requirement if gem[:dependency] && gem[:dependency].specific? @@ -124,9 +124,9 @@ def run ret_val end - print_indented table_header, *outdated_gems_list + print_indented table_header, *outdated_gems else - print_gems(outdated_gems_list) + print_gems(outdated_gems) end exit 1 From f6ef1505b3d3f62c6d29d4bc2e71034f9a68efc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Mon, 30 Sep 2019 18:44:07 +0200 Subject: [PATCH 06/22] Add a bit more space between columns --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index fc58b6a3db2..0b17c2b9f36 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -282,7 +282,7 @@ def print_indented(*data) element.to_s.ljust(column_sizes[index]) end - Bundler.ui.info row.join(" ") + "\n" + Bundler.ui.info row.join(" ") + "\n" end end From 3ed6cf852871c1caca0a9978b7574cd89ce59364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 27 Sep 2019 12:03:52 +0200 Subject: [PATCH 07/22] Change "Gem Name" header to just "Gem" --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 0b17c2b9f36..8d2d32f0c10 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -287,7 +287,7 @@ def print_indented(*data) end def table_header - header = ["Gem Name", "Installed", "New", "Requested", "Groups"] + header = ["Gem", "Installed", "New", "Requested", "Groups"] header << "Load Path" if options[:verbose] header end From 17e71ea01291b2f9ee2417c31bbe95efb9602767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 27 Sep 2019 12:20:30 +0200 Subject: [PATCH 08/22] Change "New" header to "Latest" The output feels a bit cleaner because there's more space, and the term is more clear in my opinion. --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 8d2d32f0c10..e97501d6920 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -287,7 +287,7 @@ def print_indented(*data) end def table_header - header = ["Gem", "Installed", "New", "Requested", "Groups"] + header = ["Gem", "Installed", "Latest", "Requested", "Groups"] header << "Load Path" if options[:verbose] header end From 78ae7d9ee81cf43257ff9f8e75c05b00f7c80196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 27 Sep 2019 12:26:20 +0200 Subject: [PATCH 09/22] Remove outdated header I don't think it adds much to the output? --- lib/bundler/cli/outdated.rb | 12 ------------ spec/commands/outdated_spec.rb | 2 -- 2 files changed, 14 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index e97501d6920..fd0ec5a3a38 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -98,10 +98,6 @@ def run if outdated_gems.empty? display_nothing_outdated_message else - unless options[:parseable] - Bundler.ui.info(header_outdated_message) - end - if options_include_groups outdated_gems.group_by {|g| g[:groups] }.sort.each do |groups, gems| contains_group = groups.split(", ").include?(options[:group]) @@ -139,14 +135,6 @@ def groups_text(group_text, groups) "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\"" end - def header_outdated_message - if options[:pre] - "Outdated gems included in the bundle (including pre-releases):" - else - "Outdated gems included in the bundle:" - end - end - def header_group_message(groups) if groups.empty? "===== Without group =====" diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 9ae74f4c313..844781b5155 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -517,7 +517,6 @@ def test_group_option(group = nil, gems_list_size = 1) G bundle "outdated" - expect(out).to include("Outdated gems included in the bundle:") expect(out).to include("laduradura (newest 5.15.3, installed 5.15.2, requested = 5.15.2)") end end @@ -527,7 +526,6 @@ def test_group_option(group = nil, gems_list_size = 1) shared_examples_for "version update is detected" do it "reports that a gem has a newer version" do subject - expect(out).to include("Outdated gems included in the bundle:") expect(out).to include("activesupport (newest") expect(out).to_not include("ERROR REPORT TEMPLATE") end From 43b4c56a64931a3b64eecbfc866404ac3c5ef883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 12:49:57 +0200 Subject: [PATCH 10/22] Remove unnecessary expectations If bundler crashes, specs should fail anyways. --- spec/commands/outdated_spec.rb | 2 -- spec/install/gemfile/path_spec.rb | 1 - 2 files changed, 3 deletions(-) diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 844781b5155..6bba399247e 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -527,7 +527,6 @@ def test_group_option(group = nil, gems_list_size = 1) it "reports that a gem has a newer version" do subject expect(out).to include("activesupport (newest") - expect(out).to_not include("ERROR REPORT TEMPLATE") end end @@ -583,7 +582,6 @@ def test_group_option(group = nil, gems_list_size = 1) it "does not detect any version updates" do subject expect(out).to include("updates to display.") - expect(out).to_not include("ERROR REPORT TEMPLATE") expect(out).to_not include("activesupport (newest") expect(out).to_not include("weakling (newest") end diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 5261e18bbed..d8c8904f882 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -227,7 +227,6 @@ gem "foo", :path => "#{lib_path("foo-1.0")}" G - expect(err).to_not include("ERROR REPORT") expect(err).to_not include("Your Gemfile has no gem server sources.") expect(err).to match(/is not valid. Please fix this gemspec./) expect(err).to match(/The validation error was 'missing value for attribute version'/) From a4d2ff44a9ad7797d771ce49a3cde8a041cb02a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 12:47:22 +0200 Subject: [PATCH 11/22] Tighten some expectations --- spec/commands/outdated_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 6bba399247e..21e60b74ac8 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -192,7 +192,7 @@ def test_group_option(group = nil, gems_list_size = 1) it "not outdated gems" do bundle "outdated --groups" - expect(out).to include("Bundle up to date!") + expect(out).to end_with("Bundle up to date!") end it "returns a sorted list of outdated gems by groups" do @@ -299,7 +299,8 @@ def test_group_option(group = nil, gems_list_size = 1) end bundle "outdated" - expect(out).not_to include("activesupport (3.0.0.beta > 2.3.5)") + + expect(out).to end_with("Bundle up to date!") end end @@ -354,7 +355,7 @@ def test_group_option(group = nil, gems_list_size = 1) bundle :outdated, filter_strict_option => true - expect(out).to_not include("rack (1.2") + expect(out).to end_with("Bundle up to date!") end describe "and filter options" do @@ -493,7 +494,7 @@ def test_group_option(group = nil, gems_list_size = 1) it "reports that no updates are available" do bundle "outdated" - expect(out).to include("Bundle up to date!") + expect(out).to end_with("Bundle up to date!") end end @@ -505,7 +506,7 @@ def test_group_option(group = nil, gems_list_size = 1) G bundle "outdated" - expect(out).to include("Bundle up to date!") + expect(out).to end_with("Bundle up to date!") end it "reports that updates are available if the JRuby platform is used" do From fb72186924cf2f1dcbbbe3c88586753debf31352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 16:13:04 +0200 Subject: [PATCH 12/22] Change "Load Path" header to just "Path" --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index fd0ec5a3a38..19e596b074a 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -276,7 +276,7 @@ def print_indented(*data) def table_header header = ["Gem", "Installed", "Latest", "Requested", "Groups"] - header << "Load Path" if options[:verbose] + header << "Path" if options[:verbose] header end end From 5ab4db12e8b943c8bb8ecebc0b043a67e9a5f42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 16:30:39 +0200 Subject: [PATCH 13/22] Change "Installed" column to "Locked" The "Latest" version may also be installed, so I think it's more accurate to use "Locked" here. --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 19e596b074a..3c2b47333a1 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -275,7 +275,7 @@ def print_indented(*data) end def table_header - header = ["Gem", "Installed", "Latest", "Requested", "Groups"] + header = ["Gem", "Locked", "Latest", "Requested", "Groups"] header << "Path" if options[:verbose] header end From 0c9aeb96fb1e263830de65f335f1c091da06a7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 11:07:12 +0200 Subject: [PATCH 14/22] Consistenly pass strings to method that prints a table --- lib/bundler/cli/outdated.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 3c2b47333a1..f04c8752736 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -116,7 +116,7 @@ def run dependency = gem[:dependency].requirement if gem[:dependency] && gem[:dependency].specific? ret_val = [gem[:active_spec].name, current_version, spec_version, dependency.to_s, gem[:groups].to_s] - ret_val << gem[:active_spec].loaded_from if options[:verbose] + ret_val << gem[:active_spec].loaded_from.to_s if options[:verbose] ret_val end @@ -260,14 +260,14 @@ def print_indented(*data) columns = data.first.size column_sizes = Array.new(columns) do |index| - data.max_by {|row| row[index].to_s.length }[index].length + data.max_by {|row| row[index].length }[index].length end data.sort_by! {|row| row[0] } data.each do |row| row = row.each_with_index.map do |element, index| - element.to_s.ljust(column_sizes[index]) + element.ljust(column_sizes[index]) end Bundler.ui.info row.join(" ") + "\n" From 95e9bd9651e718b06a6cf468a275db71dd2f8952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 10:58:33 +0200 Subject: [PATCH 15/22] Move row justification logic to a method --- lib/bundler/cli/outdated.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index f04c8752736..826bcdfe900 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -266,11 +266,7 @@ def print_indented(*data) data.sort_by! {|row| row[0] } data.each do |row| - row = row.each_with_index.map do |element, index| - element.ljust(column_sizes[index]) - end - - Bundler.ui.info row.join(" ") + "\n" + Bundler.ui.info justify(row, column_sizes) end end @@ -279,5 +275,11 @@ def table_header header << "Path" if options[:verbose] header end + + def justify(row, sizes) + row.each_with_index.map do |element, index| + element.ljust(sizes[index]) + end.join(" ") + "\n" + end end end From 37ae646105e6b08bd0766bf300b74e2f38de4799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 10:58:55 +0200 Subject: [PATCH 16/22] Strip row trailing spaces --- lib/bundler/cli/outdated.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 826bcdfe900..152954a4fc1 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -279,7 +279,7 @@ def table_header def justify(row, sizes) row.each_with_index.map do |element, index| element.ljust(sizes[index]) - end.join(" ") + "\n" + end.join(" ").strip + "\n" end end end From eb47767be21e36b8d456c7788155e9cb91e6db85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 12:47:33 +0200 Subject: [PATCH 17/22] Remove --pretty option and make it the default --- lib/bundler/cli.rb | 1 - lib/bundler/cli/outdated.rb | 63 ++++++---- spec/commands/outdated_spec.rb | 218 +++++++++++++++++++++------------ spec/other/platform_spec.rb | 20 ++- 4 files changed, 193 insertions(+), 109 deletions(-) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c3dc691c11d..0083f7e7de7 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -407,7 +407,6 @@ def add(*gems) "Use minimal formatting for more parseable output" method_option "only-explicit", :type => :boolean, :banner => "Only list gems specified in your Gemfile, not their dependencies" - method_option "pretty", :type => :boolean, :banner => "Use pretty formatting" def outdated(*gems) require_relative "cli/outdated" Outdated.new(options, gems).run diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 152954a4fc1..926794da9e6 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -99,30 +99,24 @@ def run display_nothing_outdated_message else if options_include_groups - outdated_gems.group_by {|g| g[:groups] }.sort.each do |groups, gems| + relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems| contains_group = groups.split(", ").include?(options[:group]) next unless options[:groups] || contains_group - unless options[:parseable] - Bundler.ui.info(header_group_message(groups)) - end + gems + end.compact - print_gems(gems) - end - elsif options[:pretty] - outdated_gems.map! do |gem| - current_version = "#{gem[:current_spec].version}#{gem[:current_spec].git_version}" - spec_version = "#{gem[:active_spec].version}#{gem[:active_spec].git_version}" - dependency = gem[:dependency].requirement if gem[:dependency] && gem[:dependency].specific? - - ret_val = [gem[:active_spec].name, current_version, spec_version, dependency.to_s, gem[:groups].to_s] - ret_val << gem[:active_spec].loaded_from.to_s if options[:verbose] - ret_val + if options[:parseable] + relevant_outdated_gems.each do |gems| + print_gems(gems) + end + else + print_gems_table(relevant_outdated_gems) end - - print_indented table_header, *outdated_gems - else + elsif options[:parseable] print_gems(outdated_gems) + else + print_gems_table(outdated_gems) end exit 1 @@ -135,14 +129,6 @@ def groups_text(group_text, groups) "#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\"" end - def header_group_message(groups) - if groups.empty? - "===== Without group =====" - else - "===== #{groups_text("Group", groups)} =====" - end - end - def nothing_outdated_message if filter_options_patch.any? display = filter_options_patch.map do |o| @@ -186,6 +172,19 @@ def print_gems(gems_list) end end + def print_gems_table(gems_list) + data = gems_list.map do |gem| + gem_column_for( + gem[:current_spec], + gem[:active_spec], + gem[:dependency], + gem[:groups], + ) + end + + print_indented([table_header] + data) + end + def print_gem(current_spec, active_spec, dependency, groups) spec_version = "#{active_spec.version}#{active_spec.git_version}" spec_version += " (from #{active_spec.loaded_from})" if Bundler.ui.debug? && active_spec.loaded_from @@ -209,6 +208,16 @@ def print_gem(current_spec, active_spec, dependency, groups) Bundler.ui.info output_message.rstrip end + def gem_column_for(current_spec, active_spec, dependency, groups) + current_version = "#{current_spec.version}#{current_spec.git_version}" + spec_version = "#{active_spec.version}#{active_spec.git_version}" + dependency = dependency.requirement if dependency + + ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s] + ret_val << active_spec.loaded_from.to_s if options[:verbose] + ret_val + end + def check_for_deployment_mode! return unless Bundler.frozen_bundle? suggested_command = if Bundler.settings.locations("frozen")[:global] @@ -256,7 +265,7 @@ def get_version_semver_portion_value(spec, version_portion_index) version_section.to_a[0].to_i end - def print_indented(*data) + def print_indented(data) columns = data.first.size column_sizes = Array.new(columns) do |index| diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 21e60b74ac8..19eb7f75e25 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -29,13 +29,15 @@ bundle "outdated" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)") - expect(out).to include("weakling (newest 0.2, installed 0.0.3, requested ~> 0.0.1)") - expect(out).to include("foo (newest 1.0") + expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 default + foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default + weakling 0.0.3 0.2 ~> 0.0.1 default + zebra 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default + TABLE - # Gem names are one per-line, between "*" and their parenthesized version. - gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact - expect(gem_list).to eq(gem_list.sort) + expect(out).to match(Regexp.new(expected_output)) end it "returns non zero exit status if outdated gems present" do @@ -70,8 +72,14 @@ update_repo2 { build_gem "terranova", "9" } bundle "outdated --verbose" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5) in groups \"development, test\"") - expect(out).to include("terranova (newest 9, installed 8, requested = 8) in group \"default\"") + + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups Path + activesupport 2.3.5 3.0 = 2.3.5 development, test + terranova 8 9 = 8 default + TABLE + + expect(out).to end_with(expected_output) end end @@ -89,7 +97,7 @@ G end - def test_group_option(group = nil, gems_list_size = 1) + def test_group_option(group) update_repo2 do build_gem "activesupport", "3.0" build_gem "terranova", "9" @@ -97,49 +105,46 @@ def test_group_option(group = nil, gems_list_size = 1) end bundle "outdated --group #{group}" - - # Gem names are one per-line, between "*" and their parenthesized version. - gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact - expect(gem_list).to eq(gem_list.sort) - expect(gem_list.size).to eq gems_list_size end it "works when the bundle is up to date" do bundle "outdated --group" - expect(out).to include("Bundle up to date!") + expect(out).to end_with("Bundle up to date!") end it "returns a sorted list of outdated gems from one group => 'default'" do test_group_option("default") - expect(out).to include("===== Group \"default\" =====") - expect(out).to include("terranova (") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + terranova 8 9 = 8 default + TABLE - expect(out).not_to include("===== Groups \"development, test\" =====") - expect(out).not_to include("activesupport") - expect(out).not_to include("duradura") + expect(out).to end_with(expected_output) end it "returns a sorted list of outdated gems from one group => 'development'" do - test_group_option("development", 2) + test_group_option("development") - expect(out).not_to include("===== Group \"default\" =====") - expect(out).not_to include("terranova (") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test + TABLE - expect(out).to include("===== Groups \"development, test\" =====") - expect(out).to include("activesupport") - expect(out).to include("duradura") + expect(out).to end_with(expected_output) end it "returns a sorted list of outdated gems from one group => 'test'" do - test_group_option("test", 2) + test_group_option("test") - expect(out).not_to include("===== Group \"default\" =====") - expect(out).not_to include("terranova (") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test + TABLE - expect(out).to include("===== Groups \"development, test\" =====") - expect(out).to include("activesupport") - expect(out).to include("duradura") + expect(out).to end_with(expected_output) end end @@ -167,12 +172,12 @@ def test_group_option(group = nil, gems_list_size = 1) it "returns a sorted list of outdated gems" do bundle "outdated --groups" - expect(out).to include("===== Without group =====") - expect(out).to include("bar (newest 3.0.0, installed 2.0.0)") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + bar 2.0.0 3.0.0 + TABLE - # Gem names are one per-line, between "*" and their parenthesized version. - gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact - expect(gem_list).to eq(gem_list.sort) + expect(out).to end_with(expected_output) end end @@ -203,15 +208,15 @@ def test_group_option(group = nil, gems_list_size = 1) end bundle "outdated --groups" - expect(out).to include("===== Group \"default\" =====") - expect(out).to include("terranova (newest 9, installed 8, requested = 8)") - expect(out).to include("===== Groups \"development, test\" =====") - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)") - expect(out).to include("duradura (newest 8.0, installed 7.0, requested = 7.0)") - expect(out).not_to include("weakling (") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test + terranova 8 9 = 8 default + TABLE - # TODO: check gems order inside the group + expect(out).to end_with(expected_output) end end @@ -230,7 +235,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle "outdated --local" - expect(out).to include("activesupport (newest 2.3.5, installed 2.3.4, requested = 2.3.4)") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 2.3.4 2.3.5 = 2.3.4 default + TABLE + + expect(out).to end_with(expected_output) end it "doesn't hit repo2" do @@ -286,8 +296,13 @@ def test_group_option(group = nil, gems_list_size = 1) end bundle "outdated foo" - expect(out).not_to include("activesupport (newest") - expect(out).to include("foo (newest 1.0") + + expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip + Gem Locked Latest Requested Groups + foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default + TABLE + + expect(out).to match(Regexp.new(expected_output)) end end @@ -311,7 +326,13 @@ def test_group_option(group = nil, gems_list_size = 1) end bundle "outdated --pre" - expect(out).to include("activesupport (newest 3.0.0.beta, installed 2.3.5, requested = 2.3.5)") + + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0.0.beta = 2.3.5 default + TABLE + + expect(out).to end_with(expected_output) end end @@ -328,7 +349,13 @@ def test_group_option(group = nil, gems_list_size = 1) G bundle "outdated" - expect(out).to include("(newest 3.0.0.beta.2, installed 3.0.0.beta.1, requested = 3.0.0.beta.1)") + + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + activesupport 3.0.0.beta.1 3.0.0.beta.2 = 3.0.0.beta.1 default + TABLE + + expect(out).to end_with(expected_output) end end end @@ -343,8 +370,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle :outdated, filter_strict_option => true - expect(out).to_not include("activesupport (newest") - expect(out).to include("(newest 0.0.5, installed 0.0.3, requested ~> 0.0.1)") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + weakling 0.0.3 0.0.5 ~> 0.0.1 default + TABLE + + expect(out).to end_with(expected_output) end it "only reports gem dependencies when they can actually be updated" do @@ -373,8 +404,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle :outdated, filter_strict_option => true, "filter-patch" => true - expect(out).to_not include("activesupport (newest") - expect(out).to include("(newest 0.0.5, installed 0.0.3") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + weakling 0.0.3 0.0.5 >= 0.0.1 default + TABLE + + expect(out).to end_with(expected_output) end it "only reports gems that match requirement and minor filter level" do @@ -391,8 +426,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle :outdated, filter_strict_option => true, "filter-minor" => true - expect(out).to_not include("activesupport (newest") - expect(out).to include("(newest 0.1.5, installed 0.0.3") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + weakling 0.0.3 0.1.5 >= 0.0.1 default + TABLE + + expect(out).to end_with(expected_output) end it "only reports gems that match requirement and major filter level" do @@ -409,8 +448,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle :outdated, filter_strict_option => true, "filter-major" => true - expect(out).to_not include("activesupport (newest") - expect(out).to include("(newest 1.1.5, installed 0.0.3") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + weakling 0.0.3 1.1.5 >= 0.0.1 default + TABLE + + expect(out).to end_with(expected_output) end end end @@ -518,7 +561,13 @@ def test_group_option(group = nil, gems_list_size = 1) G bundle "outdated" - expect(out).to include("laduradura (newest 5.15.3, installed 5.15.2, requested = 5.15.2)") + + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + laduradura 5.15.2 5.15.3 = 5.15.2 default + TABLE + + expect(out).to end_with(expected_output) end end end @@ -527,7 +576,10 @@ def test_group_option(group = nil, gems_list_size = 1) shared_examples_for "version update is detected" do it "reports that a gem has a newer version" do subject - expect(out).to include("activesupport (newest") + + outdated_gems = out.split("\n").drop_while {|l| !l.start_with?("Gem") }[1..-1] + + expect(outdated_gems.size).to be > 0 end end @@ -582,9 +634,7 @@ def test_group_option(group = nil, gems_list_size = 1) shared_examples_for "no version updates are detected" do it "does not detect any version updates" do subject - expect(out).to include("updates to display.") - expect(out).to_not include("activesupport (newest") - expect(out).to_not include("weakling (newest") + expect(out).to end_with("updates to display.") end end @@ -707,26 +757,32 @@ def test_group_option(group = nil, gems_list_size = 1) it "shows nothing when patching and filtering to minor" do bundle "outdated --patch --filter-minor" - expect(out).to include("No minor updates to display.") - expect(out).not_to include("patch (newest") - expect(out).not_to include("minor (newest") - expect(out).not_to include("major (newest") + expect(out).to end_with("No minor updates to display.") end it "shows all gems when patching and filtering to patch" do bundle "outdated --patch --filter-patch" - expect(out).to include("patch (newest 1.0.1") - expect(out).to include("minor (newest 1.0.1") - expect(out).to include("major (newest 1.0.1") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + major 1.0.0 1.0.1 >= 0 default + minor 1.0.0 1.0.1 >= 0 default + patch 1.0.0 1.0.1 >= 0 default + TABLE + + expect(out).to end_with(expected_output) end it "shows minor and major when updating to minor and filtering to patch and minor" do bundle "outdated --minor --filter-minor" - expect(out).not_to include("patch (newest") - expect(out).to include("minor (newest 1.1.0") - expect(out).to include("major (newest 1.1.0") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + major 1.0.0 1.1.0 >= 0 default + minor 1.0.0 1.1.0 >= 0 default + TABLE + + expect(out).to end_with(expected_output) end it "shows minor when updating to major and filtering to minor with parseable" do @@ -774,9 +830,13 @@ def test_group_option(group = nil, gems_list_size = 1) it "shows gems with update-strict updating to patch and filtering to patch" do bundle "outdated --patch --update-strict --filter-patch" - expect(out).to include("foo (newest 1.4.4") - expect(out).to include("bar (newest 2.0.5") - expect(out).not_to include("qux (newest") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + bar 2.0.3 2.0.5 + foo 1.4.3 1.4.4 >= 0 default + TABLE + + expect(out).to end_with(expected_output) end end end @@ -803,8 +863,12 @@ def test_group_option(group = nil, gems_list_size = 1) bundle "outdated --only-explicit" - expect(out).to include("weakling (newest 0.3") - expect(out).not_to include("bar (newest 2.2") + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups + weakling 0.2 0.3 >= 0 default + TABLE + + expect(out).to end_with(expected_output) end end end diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index b61a3f1b030..30bacfccd1b 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -1185,8 +1185,14 @@ def should_be_patchlevel_fixnum G bundle "outdated" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5") - expect(out).to include("foo (newest 1.0") + + expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 default + foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default + TABLE + + expect(out).to match(Regexp.new(expected_output)) end it "returns list of outdated gems when the ruby version matches for any engine" do @@ -1206,8 +1212,14 @@ def should_be_patchlevel_fixnum G bundle "outdated" - expect(out).to include("activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)") - expect(out).to include("foo (newest 1.0") + + expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip + Gem Locked Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 default + foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default + TABLE + + expect(out).to match(Regexp.new(expected_output)) end end From a65304f0da902cbbad775d0fb46dc939ebb4961d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 11:01:03 +0200 Subject: [PATCH 18/22] Don't include table header when ordering --- lib/bundler/cli/outdated.rb | 11 +++++++---- spec/commands/outdated_spec.rb | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 926794da9e6..242d60b629a 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -265,13 +265,16 @@ def get_version_semver_portion_value(spec, version_portion_index) version_section.to_a[0].to_i end - def print_indented(data) - columns = data.first.size + def print_indented(matrix) + header = matrix[0] + data = matrix[1..-1] - column_sizes = Array.new(columns) do |index| - data.max_by {|row| row[index].length }[index].length + column_sizes = Array.new(header.size) do |index| + matrix.max_by {|row| row[index].length }[index].length end + Bundler.ui.info justify(header, column_sizes) + data.sort_by! {|row| row[0] } data.each do |row| diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 19eb7f75e25..437e7632ae1 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -40,6 +40,26 @@ expect(out).to match(Regexp.new(expected_output)) end + it "excludes header row from the sorting" do + update_repo2 do + build_gem "AAA", %w[1.0.0 2.0.0] + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + gem "AAA", "1.0.0" + G + + bundle "outdated" + + expected_output = <<~TABLE + Gem Locked Latest Requested Groups + AAA 1.0.0 2.0.0 = 1.0.0 default + TABLE + + expect(out).to include(expected_output.strip) + end + it "returns non zero exit status if outdated gems present" do update_repo2 do build_gem "activesupport", "3.0" From f5ddf680f1bba8bd3720b50829611c1d4ff10fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 12:44:48 +0200 Subject: [PATCH 19/22] Inline one method All the other screen output and checks for `--parseable` are doing inline, so let's do it here too. --- lib/bundler/cli/outdated.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 242d60b629a..7f66eaae749 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -96,7 +96,9 @@ def run end if outdated_gems.empty? - display_nothing_outdated_message + unless options[:parseable] + Bundler.ui.info(nothing_outdated_message) + end else if options_include_groups relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems| @@ -155,12 +157,6 @@ def retrieve_active_spec(definition, current_spec) active_spec end - def display_nothing_outdated_message - unless options[:parseable] - Bundler.ui.info(nothing_outdated_message) - end - end - def print_gems(gems_list) gems_list.each do |gem| print_gem( From 73ff5d58831161aa73fbe21e8600c509d63bda8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 16:12:48 +0200 Subject: [PATCH 20/22] Normalize `bundle outdated --verbose` option handling `--parseable` checks `Bundler.ui.debug?` instead of look at the option directly. --- lib/bundler/cli/outdated.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 7f66eaae749..5599017e986 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -210,7 +210,7 @@ def gem_column_for(current_spec, active_spec, dependency, groups) dependency = dependency.requirement if dependency ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s] - ret_val << active_spec.loaded_from.to_s if options[:verbose] + ret_val << active_spec.loaded_from.to_s if Bundler.ui.debug? ret_val end @@ -280,7 +280,7 @@ def print_indented(matrix) def table_header header = ["Gem", "Locked", "Latest", "Requested", "Groups"] - header << "Path" if options[:verbose] + header << "Path" if Bundler.ui.debug? header end From a7cec294ac06de02388a71bdef10702e290cacbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 1 Oct 2019 16:39:00 +0200 Subject: [PATCH 21/22] Split --verbose option to a separate spec --- spec/commands/outdated_spec.rb | 37 ++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 437e7632ae1..8824f7d68ca 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -91,10 +91,10 @@ update_repo2 { build_gem "activesupport", "3.0" } update_repo2 { build_gem "terranova", "9" } - bundle "outdated --verbose" + bundle "outdated" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups Path + Gem Locked Latest Requested Groups activesupport 2.3.5 3.0 = 2.3.5 development, test terranova 8 9 = 8 default TABLE @@ -103,6 +103,39 @@ end end + describe "with --verbose option" do + it "shows the location of the latest version's gemspec if installed" do + bundle! "config set clean false" + + update_repo2 { build_gem "activesupport", "3.0" } + update_repo2 { build_gem "terranova", "9" } + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + + gem "terranova", '9' + gem 'activesupport', '2.3.5' + G + + gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + + gem "terranova", '8' + gem 'activesupport', '2.3.5' + G + + bundle "outdated --verbose" + + expected_output = <<~TABLE.strip + Gem Locked Latest Requested Groups Path + activesupport 2.3.5 3.0 = 2.3.5 default + terranova 8 9 = 8 default #{default_bundle_path("specifications/terranova-9.gemspec")} + TABLE + + expect(out).to end_with(expected_output) + end + end + describe "with --group option" do before do install_gemfile <<-G From 76b1d8916a0d1204e263a874b4babb757a6de2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sat, 12 Oct 2019 16:53:59 +0200 Subject: [PATCH 22/22] Rename "Locked" to "Current" --- lib/bundler/cli/outdated.rb | 2 +- spec/commands/outdated_spec.rb | 102 ++++++++++++++++----------------- spec/other/platform_spec.rb | 4 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 5599017e986..3d4922f8b50 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -279,7 +279,7 @@ def print_indented(matrix) end def table_header - header = ["Gem", "Locked", "Latest", "Requested", "Groups"] + header = ["Gem", "Current", "Latest", "Requested", "Groups"] header << "Path" if Bundler.ui.debug? header end diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index 8824f7d68ca..7631bcb4574 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -30,7 +30,7 @@ bundle "outdated" expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip - Gem Locked Latest Requested Groups + Gem Current Latest Requested Groups activesupport 2.3.5 3.0 = 2.3.5 default foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default weakling 0.0.3 0.2 ~> 0.0.1 default @@ -53,8 +53,8 @@ bundle "outdated" expected_output = <<~TABLE - Gem Locked Latest Requested Groups - AAA 1.0.0 2.0.0 = 1.0.0 default + Gem Current Latest Requested Groups + AAA 1.0.0 2.0.0 = 1.0.0 default TABLE expect(out).to include(expected_output.strip) @@ -94,9 +94,9 @@ bundle "outdated" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.5 3.0 = 2.3.5 development, test - terranova 8 9 = 8 default + Gem Current Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + terranova 8 9 = 8 default TABLE expect(out).to end_with(expected_output) @@ -127,9 +127,9 @@ bundle "outdated --verbose" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups Path - activesupport 2.3.5 3.0 = 2.3.5 default - terranova 8 9 = 8 default #{default_bundle_path("specifications/terranova-9.gemspec")} + Gem Current Latest Requested Groups Path + activesupport 2.3.5 3.0 = 2.3.5 default + terranova 8 9 = 8 default #{default_bundle_path("specifications/terranova-9.gemspec")} TABLE expect(out).to end_with(expected_output) @@ -169,8 +169,8 @@ def test_group_option(group) test_group_option("default") expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - terranova 8 9 = 8 default + Gem Current Latest Requested Groups + terranova 8 9 = 8 default TABLE expect(out).to end_with(expected_output) @@ -180,9 +180,9 @@ def test_group_option(group) test_group_option("development") expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.5 3.0 = 2.3.5 development, test - duradura 7.0 8.0 = 7.0 development, test + Gem Current Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test TABLE expect(out).to end_with(expected_output) @@ -192,9 +192,9 @@ def test_group_option(group) test_group_option("test") expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.5 3.0 = 2.3.5 development, test - duradura 7.0 8.0 = 7.0 development, test + Gem Current Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test TABLE expect(out).to end_with(expected_output) @@ -226,8 +226,8 @@ def test_group_option(group) bundle "outdated --groups" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - bar 2.0.0 3.0.0 + Gem Current Latest Requested Groups + bar 2.0.0 3.0.0 TABLE expect(out).to end_with(expected_output) @@ -263,10 +263,10 @@ def test_group_option(group) bundle "outdated --groups" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.5 3.0 = 2.3.5 development, test - duradura 7.0 8.0 = 7.0 development, test - terranova 8 9 = 8 default + Gem Current Latest Requested Groups + activesupport 2.3.5 3.0 = 2.3.5 development, test + duradura 7.0 8.0 = 7.0 development, test + terranova 8 9 = 8 default TABLE expect(out).to end_with(expected_output) @@ -289,8 +289,8 @@ def test_group_option(group) bundle "outdated --local" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.4 2.3.5 = 2.3.4 default + Gem Current Latest Requested Groups + activesupport 2.3.4 2.3.5 = 2.3.4 default TABLE expect(out).to end_with(expected_output) @@ -351,7 +351,7 @@ def test_group_option(group) bundle "outdated foo" expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip - Gem Locked Latest Requested Groups + Gem Current Latest Requested Groups foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default TABLE @@ -381,8 +381,8 @@ def test_group_option(group) bundle "outdated --pre" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - activesupport 2.3.5 3.0.0.beta = 2.3.5 default + Gem Current Latest Requested Groups + activesupport 2.3.5 3.0.0.beta = 2.3.5 default TABLE expect(out).to end_with(expected_output) @@ -404,7 +404,7 @@ def test_group_option(group) bundle "outdated" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups + Gem Current Latest Requested Groups activesupport 3.0.0.beta.1 3.0.0.beta.2 = 3.0.0.beta.1 default TABLE @@ -424,8 +424,8 @@ def test_group_option(group) bundle :outdated, filter_strict_option => true expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - weakling 0.0.3 0.0.5 ~> 0.0.1 default + Gem Current Latest Requested Groups + weakling 0.0.3 0.0.5 ~> 0.0.1 default TABLE expect(out).to end_with(expected_output) @@ -458,8 +458,8 @@ def test_group_option(group) bundle :outdated, filter_strict_option => true, "filter-patch" => true expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - weakling 0.0.3 0.0.5 >= 0.0.1 default + Gem Current Latest Requested Groups + weakling 0.0.3 0.0.5 >= 0.0.1 default TABLE expect(out).to end_with(expected_output) @@ -480,8 +480,8 @@ def test_group_option(group) bundle :outdated, filter_strict_option => true, "filter-minor" => true expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - weakling 0.0.3 0.1.5 >= 0.0.1 default + Gem Current Latest Requested Groups + weakling 0.0.3 0.1.5 >= 0.0.1 default TABLE expect(out).to end_with(expected_output) @@ -502,8 +502,8 @@ def test_group_option(group) bundle :outdated, filter_strict_option => true, "filter-major" => true expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - weakling 0.0.3 1.1.5 >= 0.0.1 default + Gem Current Latest Requested Groups + weakling 0.0.3 1.1.5 >= 0.0.1 default TABLE expect(out).to end_with(expected_output) @@ -616,8 +616,8 @@ def test_group_option(group) bundle "outdated" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - laduradura 5.15.2 5.15.3 = 5.15.2 default + Gem Current Latest Requested Groups + laduradura 5.15.2 5.15.3 = 5.15.2 default TABLE expect(out).to end_with(expected_output) @@ -817,10 +817,10 @@ def test_group_option(group) bundle "outdated --patch --filter-patch" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - major 1.0.0 1.0.1 >= 0 default - minor 1.0.0 1.0.1 >= 0 default - patch 1.0.0 1.0.1 >= 0 default + Gem Current Latest Requested Groups + major 1.0.0 1.0.1 >= 0 default + minor 1.0.0 1.0.1 >= 0 default + patch 1.0.0 1.0.1 >= 0 default TABLE expect(out).to end_with(expected_output) @@ -830,9 +830,9 @@ def test_group_option(group) bundle "outdated --minor --filter-minor" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - major 1.0.0 1.1.0 >= 0 default - minor 1.0.0 1.1.0 >= 0 default + Gem Current Latest Requested Groups + major 1.0.0 1.1.0 >= 0 default + minor 1.0.0 1.1.0 >= 0 default TABLE expect(out).to end_with(expected_output) @@ -884,9 +884,9 @@ def test_group_option(group) bundle "outdated --patch --update-strict --filter-patch" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - bar 2.0.3 2.0.5 - foo 1.4.3 1.4.4 >= 0 default + Gem Current Latest Requested Groups + bar 2.0.3 2.0.5 + foo 1.4.3 1.4.4 >= 0 default TABLE expect(out).to end_with(expected_output) @@ -917,8 +917,8 @@ def test_group_option(group) bundle "outdated --only-explicit" expected_output = <<~TABLE.strip - Gem Locked Latest Requested Groups - weakling 0.2 0.3 >= 0 default + Gem Current Latest Requested Groups + weakling 0.2 0.3 >= 0 default TABLE expect(out).to end_with(expected_output) diff --git a/spec/other/platform_spec.rb b/spec/other/platform_spec.rb index 30bacfccd1b..051c5559807 100644 --- a/spec/other/platform_spec.rb +++ b/spec/other/platform_spec.rb @@ -1187,7 +1187,7 @@ def should_be_patchlevel_fixnum bundle "outdated" expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip - Gem Locked Latest Requested Groups + Gem Current Latest Requested Groups activesupport 2.3.5 3.0 = 2.3.5 default foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default TABLE @@ -1214,7 +1214,7 @@ def should_be_patchlevel_fixnum bundle "outdated" expected_output = <<~TABLE.gsub("x", "\\\h").tr(".", "\.").strip - Gem Locked Latest Requested Groups + Gem Current Latest Requested Groups activesupport 2.3.5 3.0 = 2.3.5 default foo 1.0 xxxxxxx 1.0 xxxxxxx >= 0 default TABLE