Class: BuildOptions Private
Overview
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.
Options for a formula build.
Instance Method Summary collapse
-
#any_args_or_options? ⇒ Boolean
private
True if the build has any arguments or options specified.
-
#bottle? ⇒ Boolean
private
True if a Formula is being built as a bottle (i.e. binary package).
-
#head? ⇒ Boolean
private
True if a Formula is being built with Formula.head instead of Formula.stable.
-
#initialize(args, options) ⇒ BuildOptions
constructor
private
A new instance of BuildOptions.
-
#stable? ⇒ Boolean
private
True if a Formula is being built with Formula.stable instead of Formula.head.
- #unused_options ⇒ Object private
- #used_options ⇒ Object private
-
#with?(val) ⇒ Boolean
private
True if a Formula is being built with a specific option.
-
#without?(val) ⇒ Boolean
private
True if a Formula is being built without a specific option.
Constructor Details
#initialize(args, options) ⇒ BuildOptions
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.
Returns a new instance of BuildOptions.
6 7 8 9 |
# File 'build_options.rb', line 6 def initialize(args, ) @args = args @options = end |
Instance Method Details
#any_args_or_options? ⇒ 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.
True if the build has any arguments or options specified.
95 96 97 |
# File 'build_options.rb', line 95 def !@args.empty? || !@options.empty? end |
#bottle? ⇒ 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.
True if a Formula is being built as a bottle (i.e. binary package).
58 59 60 |
# File 'build_options.rb', line 58 def bottle? include? "build-bottle" end |
#head? ⇒ 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.
True if a Formula is being built with Formula.head instead of Formula.stable.
Examples
args << "--some-new-stuff" if build.head?
If there are multiple conditional arguments use a block instead of lines.
if build.head?
args << "--i-want-pizza"
args << "--and-a-cold-beer" if build.with? "cold-beer"
end
78 79 80 |
# File 'build_options.rb', line 78 def head? include? "HEAD" end |
#stable? ⇒ 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.
True if a Formula is being built with Formula.stable instead of Formula.head. This is the default.
Example
args << "--some-beta" if build.head?
90 91 92 |
# File 'build_options.rb', line 90 def stable? !head? end |
#unused_options ⇒ Object
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.
103 104 105 |
# File 'build_options.rb', line 103 def @options - @args end |
#used_options ⇒ Object
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.
99 100 101 |
# File 'build_options.rb', line 99 def @options & @args end |
#with?(val) ⇒ 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.
True if a Formula is being built with a specific option.
Examples
args << "--i-want-spam" if build.with? "spam"
args << "--qt-gui" if build.with? "qt" # "--with-qt" ==> build.with? "qt"
If a formula presents a user with a choice, but the choice must be fulfilled:
if build.with? "example2"
args << "--with-example2"
else
args << "--with-example1"
end
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'build_options.rb', line 32 def with?(val) option_names = val.respond_to?(:option_names) ? val.option_names : [val] option_names.any? do |name| if option_defined? "with-#{name}" include? "with-#{name}" elsif option_defined? "without-#{name}" !include? "without-#{name}" else false end end end |
#without?(val) ⇒ 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.
True if a Formula is being built without a specific option.
Example
args << "--no-spam-plz" if build.without? "spam"
53 54 55 |
# File 'build_options.rb', line 53 def without?(val) !with?(val) end |