Class: Homebrew::Bundle::Dsl Private
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: Entry
Constant Summary collapse
- HOMEBREW_TAP_ARGS_REGEX =
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.
%r{^([\w-]+)/(homebrew-)?([\w-]+)$}- HOMEBREW_CORE_FORMULA_REGEX =
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.
%r{^homebrew/homebrew/([\w+-.@]+)$}i- HOMEBREW_TAP_FORMULA_REGEX =
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.
%r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}
Instance Attribute Summary collapse
- #cask_arguments ⇒ Hash{Symbol => T.untyped} readonly private
- #entries ⇒ Array<Entry> readonly private
- #input ⇒ String readonly private
Class Method Summary collapse
- .sanitize_brew_name(name) ⇒ String private
- .sanitize_cask_name(name) ⇒ String private
- .sanitize_tap_name(name) ⇒ String private
Instance Method Summary collapse
- #brew(name, options = {}) ⇒ void private
- #cask(name, options = {}) ⇒ void private
- #cask_args(args) ⇒ void private
- #initialize(path) ⇒ void constructor private
- #method_missing(method_name, *args, **options, &block) ⇒ T.untyped private
- #process ⇒ void private
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean private
- #tap(name, clone_target = nil, options = {}, **keyword_options) ⇒ void private
Constructor Details
#initialize(path) ⇒ 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.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'bundle/dsl.rb', line 47 def initialize(path) @path = path path_read = path.read raise "path_read is nil" unless path_read @input = T.let(path_read, String) @entries = T.let([], T::Array[Entry]) @cask_arguments = T.let({}, T::Hash[Symbol, T.untyped]) begin process # Want to catch all exceptions for e.g. syntax errors. rescue Exception => e # rubocop:disable Lint/RescueException error_msg = "Invalid Brewfile: #{e.}" raise RuntimeError, error_msg, e.backtrace end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **options, &block) ⇒ T.untyped
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.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'bundle/dsl.rb', line 149 def method_missing(method_name, *args, **, &block) require "bundle/extensions" extension = Homebrew::Bundle.extension(method_name) return super if extension.nil? raise ArgumentError, "blocks are not supported for #{method_name}" if block # Extension DSL entries follow the existing Brewfile calling convention: # a required name plus an optional options hash, passed positionally, # with keywords, or both. unless (1..2).cover?(args.length) raise ArgumentError, "wrong number of arguments (given #{args.length}, expected 1..2)" end = {} if args.length == 2 = args[1] unless .is_a? Hash raise ArgumentError, "options(#{.inspect}) should be a Hash object" end end @entries << extension.entry(args.first, .merge()) end |
Instance Attribute Details
#cask_arguments ⇒ Hash{Symbol => T.untyped} (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.
41 42 43 |
# File 'bundle/dsl.rb', line 41 def cask_arguments @cask_arguments end |
#entries ⇒ Array<Entry> (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.
38 39 40 |
# File 'bundle/dsl.rb', line 38 def entries @entries end |
#input ⇒ String (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.
44 45 46 |
# File 'bundle/dsl.rb', line 44 def input @input end |
Class Method Details
.sanitize_brew_name(name) ⇒ 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.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'bundle/dsl.rb', line 110 def self.sanitize_brew_name(name) name = name.downcase if name =~ HOMEBREW_CORE_FORMULA_REGEX sanitized_name = Regexp.last_match(1) raise "sanitized_name is nil" unless sanitized_name sanitized_name elsif name =~ HOMEBREW_TAP_FORMULA_REGEX user = Regexp.last_match(1) repo = Regexp.last_match(2) name = Regexp.last_match(3) raise "repo is nil" unless repo "#{user}/#{repo.sub("homebrew-", "")}/#{name}" else name end end |
.sanitize_cask_name(name) ⇒ 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.
140 141 142 143 |
# File 'bundle/dsl.rb', line 140 def self.sanitize_cask_name(name) require "utils" Utils.name_from_full_name(name).downcase end |
.sanitize_tap_name(name) ⇒ 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.
130 131 132 133 134 135 136 137 |
# File 'bundle/dsl.rb', line 130 def self.sanitize_tap_name(name) name = name.downcase if name =~ HOMEBREW_TAP_ARGS_REGEX "#{Regexp.last_match(1)}/#{Regexp.last_match(3)}" else name end end |
Instance Method Details
#brew(name, options = {}) ⇒ 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.
76 77 78 79 |
# File 'bundle/dsl.rb', line 76 def brew(name, = {}) name = Homebrew::Bundle::Dsl.sanitize_brew_name(name) @entries << Entry.new(:brew, name, ) end |
#cask(name, options = {}) ⇒ 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.
82 83 84 85 86 87 88 |
# File 'bundle/dsl.rb', line 82 def cask(name, = {}) [:full_name] = name name = Homebrew::Bundle::Dsl.sanitize_cask_name(name) [:args] = @cask_arguments.merge T.cast(.fetch(:args, {}), T::Hash[Symbol, NestedEntryOptionValue]) @entries << Entry.new(:cask, name, ) end |
#cask_args(args) ⇒ 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.
71 72 73 |
# File 'bundle/dsl.rb', line 71 def cask_args(args) @cask_arguments.merge!(args) end |
#process ⇒ 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.
66 67 68 |
# File 'bundle/dsl.rb', line 66 def process instance_eval(@input, @path.to_s) end |
#respond_to_missing?(method_name, include_private = false) ⇒ 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.
176 177 178 179 |
# File 'bundle/dsl.rb', line 176 def respond_to_missing?(method_name, include_private = false) require "bundle/extensions" !Homebrew::Bundle.extension(method_name).nil? || super end |
#tap(name, clone_target = nil, options = {}, **keyword_options) ⇒ 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.
98 99 100 101 102 103 |
# File 'bundle/dsl.rb', line 98 def tap(name, clone_target = nil, = {}, **) .merge!() [:clone_target] = clone_target name = Homebrew::Bundle::Dsl.sanitize_tap_name(name) @entries << Entry.new(:tap, name, ) end |