Module: BareTest::Formatter
Overview
Extend Formatters that have custom options with this module to gain convenience methods to define the custom options. See Command’s documentation for more information.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Provides access to the command/options/arguments related information.
Class Method Summary collapse
-
.extended(obj) ⇒ Object
Invoke Formatter#initialize_options.
Instance Method Summary collapse
-
#env_option(*args) ⇒ Object
Use an env-variable and map it to an option.
-
#initialize_options ⇒ Object
Initialize some instance variables needed for the DSL.
-
#option(*args) ⇒ Object
Define a formatter-specific option.
-
#option_defaults(defaults = {}) ⇒ Object
Define default values for options.
-
#text(*args) ⇒ Object
Inject a piece of text into the helptext.
Instance Attribute Details
#command ⇒ Object (readonly)
Provides access to the command/options/arguments related information.
22 23 24 |
# File 'lib/baretest/formatter.rb', line 22 def command @command end |
Class Method Details
.extended(obj) ⇒ Object
Invoke Formatter#initialize_options
17 18 19 |
# File 'lib/baretest/formatter.rb', line 17 def self.extended(obj) # :nodoc: obj. end |
Instance Method Details
#env_option(*args) ⇒ Object
Use an env-variable and map it to an option. Example:
env_option :indent, "INDENT"
48 49 50 |
# File 'lib/baretest/formatter.rb', line 48 def env_option(*args) @command[:elements] << [:env_option, args] end |
#initialize_options ⇒ Object
Initialize some instance variables needed for the DSL.
25 26 27 28 29 30 |
# File 'lib/baretest/formatter.rb', line 25 def # :nodoc: @command = { :option_defaults => {}, :elements => [], } end |
#option(*args) ⇒ Object
Define a formatter-specific option. See Command::Definition#option
54 55 56 |
# File 'lib/baretest/formatter.rb', line 54 def option(*args) @command[:elements] << [:option, args] end |
#option_defaults(defaults = {}) ⇒ Object
Define default values for options. Example:
option_defaults :colors => false,
:indent => 3
36 37 38 |
# File 'lib/baretest/formatter.rb', line 36 def option_defaults(defaults={}) @command[:option_defaults].update(defaults) end |
#text(*args) ⇒ Object
Inject a piece of text into the helptext.
41 42 43 |
# File 'lib/baretest/formatter.rb', line 41 def text(*args) @command[:elements] << [:text, args] end |