Module: BareTest::Formatter

Included in:
Run::CLI, Run::XML
Defined in:
lib/baretest/formatter.rb

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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject (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.initialize_options
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_optionsObject

Initialize some instance variables needed for the DSL.



25
26
27
28
29
30
# File 'lib/baretest/formatter.rb', line 25

def initialize_options # :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