Class: Homebrew::DevCmd::UpdateSponsors Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::UpdateSponsors
- Includes:
- SystemCommand::Mixin
- Defined in:
- dev-cmd/update-sponsors.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/update_sponsors.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
Constant Summary collapse
- NAMED_MONTHLY_AMOUNT =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
100
- URL_MONTHLY_AMOUNT =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
1000
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::UpdateSponsors::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::UpdateSponsors::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/update_sponsors.rbi', line 10 def args; end |
#run ⇒ void
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.
25 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 |
# File 'dev-cmd/update-sponsors.rb', line 25 def run named_sponsors = [] logo_sponsors = [] largest_monthly_amount = T.let(0, Integer) GitHub.sponsorships("Homebrew").each do |s| largest_monthly_amount = [s[:monthly_amount], s[:closest_tier_monthly_amount]].max if largest_monthly_amount >= NAMED_MONTHLY_AMOUNT named_sponsors << "[#{sponsor_name(s)}](#{sponsor_url(s)})" end next if largest_monthly_amount < URL_MONTHLY_AMOUNT logo_sponsors << "[![#{sponsor_name(s)}](#{sponsor_logo(s)})](#{sponsor_url(s)})" end odie "No sponsorships amounts found! Ensure you have sufficient permissions!" if largest_monthly_amount.zero? named_sponsors << "many other users and organisations via [GitHub Sponsors](https://github.com/sponsors/Homebrew)" readme = HOMEBREW_REPOSITORY/"README.md" content = readme.read content.gsub!(/(Homebrew is generously supported by) .*\Z/m, "\\1 #{named_sponsors.to_sentence}.\n") content << "\n#{logo_sponsors.join}\n" if logo_sponsors.presence File.write(readme, content) diff = system_command "git", args: [ "-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "README.md" ] if diff.status.success? ofail "No changes to list of sponsors." else puts "List of sponsors updated in the README." end end |