mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 14:05:02 +02:00
[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.
e69c658be6
This commit is contained in:
parent
11d7c75fb3
commit
a54c98a29f
1 changed files with 16 additions and 16 deletions
|
@ -102,23 +102,16 @@ module Bundler
|
||||||
Bundler.ui.info(nothing_outdated_message)
|
Bundler.ui.info(nothing_outdated_message)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if options_include_groups
|
relevant_outdated_gems = if options_include_groups
|
||||||
relevant_outdated_gems = outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
|
by_group(outdated_gems, :filter => options[:group])
|
||||||
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)
|
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -162,6 +155,13 @@ module Bundler
|
||||||
active_specs.last
|
active_specs.last
|
||||||
end
|
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)
|
def print_gems(gems_list)
|
||||||
gems_list.each do |gem|
|
gems_list.each do |gem|
|
||||||
print_gem(
|
print_gem(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue