Debian Codegraph @

lib/bundler/cli/fund.rb

raw
1 # frozen_string_literal: true
2
3 module Bundler
4 class CLI::Fund
5 attr_reader :options
6
7 def initialize(options)
8 @options = options
9 end
10
11 def run
12 Bundler.definition.validate_runtime!
13
14 groups = Array(options[:group]).map(&:to_sym)
15
16 deps = if groups.any?
17 Bundler.definition.dependencies_for(groups)
18 else
19 Bundler.definition.requested_dependencies
20 end
21
22 fund_info = deps.each_with_object([]) do |dep, arr|
23 spec = Bundler.definition.specs[dep.name].first
24 if spec.metadata.key?("funding_uri")
25 arr << "* #{spec.name} (#{spec.version})\n Funding: #{spec.metadata["funding_uri"]}"
26 end
27 end
28
29 if fund_info.empty?
30 Bundler.ui.info "None of the installed gems you directly depend on are looking for funding."
31 else
32 Bundler.ui.info fund_info.join("\n")
33 end
34 end
35 end
36 end