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 = {}) ⇒ 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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'bundle/dsl.rb', line 43 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.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'bundle/dsl.rb', line 136 def method_missing(method_name, *args, **, &block) 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.
37 38 39 |
# File 'bundle/dsl.rb', line 37 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.
34 35 36 |
# File 'bundle/dsl.rb', line 34 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.
40 41 42 |
# File 'bundle/dsl.rb', line 40 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.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'bundle/dsl.rb', line 98 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.
128 129 130 |
# File 'bundle/dsl.rb', line 128 def self.sanitize_cask_name(name) 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.
118 119 120 121 122 123 124 125 |
# File 'bundle/dsl.rb', line 118 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.
72 73 74 75 |
# File 'bundle/dsl.rb', line 72 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.
78 79 80 81 82 83 84 |
# File 'bundle/dsl.rb', line 78 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.
67 68 69 |
# File 'bundle/dsl.rb', line 67 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.
62 63 64 |
# File 'bundle/dsl.rb', line 62 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.
162 163 164 |
# File 'bundle/dsl.rb', line 162 def respond_to_missing?(method_name, include_private = false) Homebrew::Bundle.extension(method_name).present? || super end |
#tap(name, clone_target = nil, 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.
87 88 89 90 91 |
# File 'bundle/dsl.rb', line 87 def tap(name, clone_target = nil, = {}) [:clone_target] = clone_target name = Homebrew::Bundle::Dsl.sanitize_tap_name(name) @entries << Entry.new(:tap, name, ) end |