Skip to content

Commit

Permalink
Vastly simplify this calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Sep 17, 2020
1 parent cb3fe13 commit fc6b8d8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bundler/lib/bundler/cli/common.rb
Expand Up @@ -15,12 +15,16 @@ def self.print_post_install_message(name, msg)
end

def self.output_fund_metadata_summary(gems_seeking_funding)
gem_names = gems_seeking_funding.keys
current_dependencies = Bundler.definition.current_dependencies.map(&:name)
direct_gems_seeking_funding = gem_names.reject {|g| !current_dependencies.include?(g) }
return if direct_gems_seeking_funding.empty?
current_specs = Bundler.definition.specs

count = current_dependencies.count do |dep|
return 0 if (dep = current_specs[dep].first).nil?
dep.metadata.key?("funding_uri")
end

return if count.zero?

count = direct_gems_seeking_funding.length
intro = count > 1 ? "#{count} gems you directly depend on are" : "#{count} gem you directly depend on is"
message = "#{intro} looking for funding.\n Run `bundle fund` for details"
Bundler.ui.info message
Expand Down

0 comments on commit fc6b8d8

Please sign in to comment.