Class: Homebrew::DevCmd::UpdatePortableRuby Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::UpdatePortableRuby
- Defined in:
- dev-cmd/update-portable-ruby.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/update_portable_ruby.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
- #args ⇒ Homebrew::DevCmd::UpdatePortableRuby::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
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
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::UpdatePortableRuby::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_portable_ruby.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.
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 64 65 66 67 68 69 70 71 |
# File 'dev-cmd/update-portable-ruby.rb', line 27 def run formula = Homebrew.with_no_api_env { Formulary.factory("portable-ruby") } version = formula.version.to_s pkg_version = formula.pkg_version.to_s vendor_dir = HOMEBREW_LIBRARY_PATH/"vendor" write_file(vendor_dir/"portable-ruby-version", "#{pkg_version}\n") write_file(HOMEBREW_LIBRARY_PATH/".ruby-version", "#{version}\n") formula.bottle_specification.checksums.each do |checksum| tag_symbol = checksum.fetch("tag") tag = Utils::Bottles::Tag.from_symbol(tag_symbol) os = tag.linux? ? "linux" : "darwin" path = vendor_dir/"portable-ruby-#{tag.standardized_arch}-#{os}" write_file(path, "ruby_TAG=#{tag_symbol}\nruby_SHA=#{checksum.fetch("digest")}\n") end return if args.skip_vendor_install? if args.dry_run? ohai "brew vendor-install ruby" ohai "Would update #{HOMEBREW_LIBRARY_PATH/"utils/ruby.sh"} and #{HOMEBREW_LIBRARY_PATH/"Gemfile.lock"} " \ "with the bundler version shipped by portable-ruby #{pkg_version}." return end ohai "brew vendor-install ruby" safe_system HOMEBREW_BREW_FILE, "vendor-install", "ruby" bundler_dir = Pathname.glob(vendor_dir/"portable-ruby/#{pkg_version}/lib/ruby/gems/*/gems/bundler-*").first odie "Cannot find vendored bundler for portable-ruby #{pkg_version}." if bundler_dir.nil? bundler_version = bundler_dir.basename.to_s.delete_prefix("bundler-") ruby_sh = HOMEBREW_LIBRARY_PATH/"utils/ruby.sh" original = ruby_sh.read updated = original.sub(/(?<=^export HOMEBREW_BUNDLER_VERSION=")[^"]+/, bundler_version) if original != updated ohai "Writing #{ruby_sh}" ruby_sh.atomic_write(updated) end ohai "brew vendor-gems --no-commit --update=--ruby,--bundler=#{bundler_version}" safe_system HOMEBREW_BREW_FILE, "vendor-gems", "--no-commit", "--update=--ruby,--bundler=#{bundler_version}" end |