aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
authorEric Mueller <nevinera@gmail.com>2023-11-15 19:45:39 -0800
committergit <svn-admin@ruby-lang.org>2023-11-23 18:03:16 +0000
commita54c98a29f2086d46c95bc15e77dade7dcd18bba (patch)
treec39d55c1c8b7633b43887739b93c16e4a974d254 /lib/bundler
parent11d7c75fb33138e9ecadcf222286897826aa0a36 (diff)
downloadruby-a54c98a29f2086d46c95bc15e77dade7dcd18bba.tar.gz
[rubygems/rubygems] Factor group-filtering to a private method to reduce repetition
We're about to expand the repeated bit of code, so drying it up a little is warranted. https://github.com/rubygems/rubygems/commit/e69c658be6
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/cli/outdated.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 68c701aefb..6c05860854 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -102,23 +102,16 @@ module Bundler
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|
- contains_group = groups.split(", ").include?(options[:group])
- next unless options[:groups] || contains_group
-
- gems
- end.compact
-
- if options[:parseable]
- print_gems(relevant_outdated_gems)
- else
- print_gems_table(relevant_outdated_gems)
- end
- elsif options[:parseable]
- print_gems(outdated_gems)
+ relevant_outdated_gems = if options_include_groups
+ by_group(outdated_gems, :filter => options[:group])
else
- print_gems_table(outdated_gems)
+ outdated_gems
+ end
+
+ if options[:parseable]
+ print_gems(relevant_outdated_gems)
+ else
+ print_gems_table(relevant_outdated_gems)
end
exit 1
@@ -162,6 +155,13 @@ module Bundler
active_specs.last
end
+ def by_group(gems, filter: nil)
+ gems.group_by {|g| g[:groups] }.sort.flat_map do |groups_string, grouped_gems|
+ next if filter && !groups_string.split(", ").include?(filter)
+ grouped_gems
+ end.compact
+ end
+
def print_gems(gems_list)
gems_list.each do |gem|
print_gem(