Class: Homebrew::Cmd::GistLogs Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::GistLogs
- Includes:
- Install
- Defined in:
- cmd/gist-logs.rb,
sorbet/rbi/dsl/homebrew/cmd/gist_logs.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
Class Method Summary collapse
-
.truncate_text_to_approximate_size(str, max_bytes, options = {}) ⇒ String
private
Truncates a text string to fit within a byte size constraint, preserving character encoding validity.
Instance Method Summary collapse
- #args ⇒ Homebrew::Cmd::GistLogs::Args private
- #run ⇒ void private
Methods included from Install
ask_casks, ask_formulae, check_cc_argv, check_prefix, fetch_formulae, formula_installers, global_post_install, install_formula, install_formula?, install_formulae, perform_build_from_source_checks, perform_preinstall_checks_once, print_dry_run_dependencies
Methods included from Utils::Output::Mixin
#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Class Method Details
.truncate_text_to_approximate_size(str, max_bytes, options = {}) ⇒ 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.
Truncates a text string to fit within a byte size constraint, preserving character encoding validity. The returned string will be not much longer than the specified max_bytes, though the exact shortfall or overrun may vary.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'cmd/gist-logs.rb', line 47 def self.truncate_text_to_approximate_size(str, max_bytes, = {}) front_weight = .fetch(:front_weight, 0.5) raise "opts[:front_weight] must be between 0.0 and 1.0" if front_weight < 0.0 || front_weight > 1.0 return str if str.bytesize <= max_bytes glue = "\n[...snip...]\n" max_bytes_in = [max_bytes - glue.bytesize, 1].max bytes = str.dup.force_encoding("BINARY") glue_bytes = glue.encode("BINARY") n_front_bytes = (max_bytes_in * front_weight).floor n_back_bytes = max_bytes_in - n_front_bytes if n_front_bytes.zero? front = bytes[1..0] back = bytes[-max_bytes_in..] elsif n_back_bytes.zero? front = bytes[0..(max_bytes_in - 1)] back = bytes[1..0] else front = bytes[0..(n_front_bytes - 1)] back = bytes[-n_back_bytes..] end out = T.must(front) + glue_bytes + T.must(back) out.force_encoding("UTF-8") out.encode!("UTF-16", invalid: :replace) out.encode!("UTF-8") out end |
Instance Method Details
#args ⇒ Homebrew::Cmd::GistLogs::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/cmd/gist_logs.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.
34 35 36 37 38 39 40 |
# File 'cmd/gist-logs.rb', line 34 def run Install.perform_preinstall_checks_once(all_fatal: true) Install.perform_build_from_source_checks(all_fatal: true) return unless (formula = args.named.to_resolved_formulae.first) gistify_logs(formula) end |