Class: ReporterHub Private
- Includes:
- Utils::Output::Mixin
- Defined in:
- cmd/update-report.rb
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.
Instance Attribute Summary collapse
- #reporters ⇒ Array<Reporter> readonly private
Instance Method Summary collapse
- #add(reporter, auto_update: false) ⇒ void private
- #dump(auto_update: false) ⇒ void private
- #empty? ⇒ Boolean private
- #initialize ⇒ void constructor private
- #select_formula_or_cask(key) ⇒ Array<String> private
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
#initialize ⇒ 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.
784 785 786 787 |
# File 'cmd/update-report.rb', line 784 def initialize @hash = T.let({}, T::Hash[Symbol, T::Array[T.any(String, [String, String])]]) @reporters = T.let([], T::Array[Reporter]) end |
Instance Attribute Details
#reporters ⇒ Array<Reporter> (readonly)
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.
781 782 783 |
# File 'cmd/update-report.rb', line 781 def reporters @reporters end |
Instance Method Details
#add(reporter, auto_update: false) ⇒ 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.
797 798 799 800 801 |
# File 'cmd/update-report.rb', line 797 def add(reporter, auto_update: false) @reporters << reporter report = reporter.report(auto_update:).reject { |_k, v| v.empty? } @hash.update(report) { |_key, oldval, newval| oldval.concat(newval) } end |
#dump(auto_update: false) ⇒ 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.
809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
# File 'cmd/update-report.rb', line 809 def dump(auto_update: false) unless Homebrew::EnvConfig.no_update_report_new? dump_new_formula_report dump_new_cask_report end dump_deleted_formula_report dump_deleted_cask_report outdated_formulae = Formula.installed.select(&:outdated?).map(&:name) outdated_casks = Cask::Caskroom.casks.select(&:outdated?).map(&:token) unless auto_update output_dump_formula_or_cask_report "Outdated Formulae", outdated_formulae output_dump_formula_or_cask_report "Outdated Casks", outdated_casks end return if outdated_formulae.blank? && outdated_casks.blank? outdated_formulae = outdated_formulae.count outdated_casks = outdated_casks.count update_pronoun = if (outdated_formulae + outdated_casks) == 1 "it" else "them" end msg = "" if outdated_formulae.positive? noun = Utils.pluralize("formula", outdated_formulae) msg += "#{Tty.bold}#{outdated_formulae}#{Tty.reset} outdated #{noun}" end if outdated_casks.positive? msg += " and " if msg.present? msg += "#{Tty.bold}#{outdated_casks}#{Tty.reset} outdated #{Utils.pluralize("cask", outdated_casks)}" end return if msg.blank? puts puts "You have #{msg} installed." # If we're auto-updating, don't need to suggest commands that we're perhaps # already running. return if auto_update puts <<~EOS You can upgrade #{update_pronoun} with #{Tty.bold}brew upgrade#{Tty.reset} or list #{update_pronoun} with #{Tty.bold}brew outdated#{Tty.reset}. EOS end |
#empty? ⇒ Boolean
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.
804 805 806 |
# File 'cmd/update-report.rb', line 804 def empty? @hash.empty? end |
#select_formula_or_cask(key) ⇒ Array<String>
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.
790 791 792 793 794 |
# File 'cmd/update-report.rb', line 790 def select_formula_or_cask(key) raise "Unsupported key #{key}" unless [:A, :AC, :D, :DC, :M, :MC, :R, :RC, :T].include?(key) T.cast(@hash.fetch(key, []), T::Array[String]) end |