Class: Homebrew::DevCmd::FormulaPythonResources Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/formula-python-resources.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/formula_python_resources.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::FormulaPythonResources::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/formula_python_resources.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'dev-cmd/formula-python-resources.rb', line 26

def run
  if args.all?
    raise UsageError, "`--all` cannot be combined with named formulae." if args.named.present?

    formulae = Formula.all
  else
    raise FormulaUnspecifiedError if args.named.blank?
    raise UsageError, "`--tap` requires `--all`." if args.tap

    formulae = args.named.to_formulae
  end

  output = formulae.filter_map do |formula|
    tap_name = formula.tap&.name
    next if args.tap && tap_name != args.tap

    resources = formula.resources.filter_map do |resource|
      url = resource.url
      next unless url&.match?(%r{\Ahttps?://files\.pythonhosted\.org/})

      {
        name: resource.name,
        url:,
      }
    end
    next if resources.empty?

    {
      name:       formula.name,
      tap:        tap_name,
      deprecated: formula.deprecated?,
      disabled:   formula.disabled?,
      resources:  resources.sort_by { |resource| resource.fetch(:name) },
    }
  end

  puts JSON.pretty_generate(output.sort_by { |formula| formula.fetch(:name) })
end