Class: Tengine::Support::Config::Definition::Suite
- Inherits:
-
Object
- Object
- Tengine::Support::Config::Definition::Suite
show all
- Includes:
- HasManyChildren
- Defined in:
- lib/tengine/support/config/definition/suite.rb
Instance Method Summary
collapse
#[], #[]=, #accept_visitor, #action, #action?, #add, #child_by_name, #children, #field, #find, #get_value, #group, #ignore, #load, #load_config, #separator, #separator?, #to_hash
Constructor Details
#initialize(hash_or_filepath = nil) ⇒ Suite
Returns a new instance of Suite.
9
10
11
12
13
14
15
|
# File 'lib/tengine/support/config/definition/suite.rb', line 9
def initialize(hash_or_filepath = nil)
build if respond_to?(:build)
case hash_or_filepath
when Hash then load(hash_or_filepath)
when String then load_file(hash_or_filepath)
end
end
|
Instance Method Details
#banner(banner = nil) ⇒ Object
30
31
32
33
|
# File 'lib/tengine/support/config/definition/suite.rb', line 30
def banner(banner = nil)
@banner = banner if banner
@banner
end
|
#load_file(filepath) ⇒ Object
26
27
28
|
# File 'lib/tengine/support/config/definition/suite.rb', line 26
def load_file(filepath)
load(YAML.load_file(filepath))
end
|
#mapping(mapping = nil) ⇒ Object
18
19
20
21
|
# File 'lib/tengine/support/config/definition/suite.rb', line 18
def mapping(mapping = nil)
@mapping = mapping if mapping
@mapping
end
|
#name_array ⇒ Object
47
48
49
|
# File 'lib/tengine/support/config/definition/suite.rb', line 47
def name_array
[]
end
|
#parent ⇒ Object
23
|
# File 'lib/tengine/support/config/definition/suite.rb', line 23
def parent; nil; end
|
#parse!(argv) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/tengine/support/config/definition/suite.rb', line 35
def parse!(argv)
v = Tengine::Support::Config::Definition::OptparseVisitor.new(self)
self.accept_visitor(v)
if load_config = children.detect{|child| child.type == :load_config}
opts = v.option_parser.getopts(argv.dup) if filepath = opts[load_config.__name__.to_s]
load_file(filepath)
end
end
v.option_parser.parse(argv.dup)
end
|
#root ⇒ Object
24
|
# File 'lib/tengine/support/config/definition/suite.rb', line 24
def root; self; end
|