Class: BoPeep::Context
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#playlist ⇒ Object
readonly
Returns the value of attribute playlist.
Attributes inherited from Config
#default_user, #hosts, #variables_sets
Instance Method Summary collapse
- #copy(config) ⇒ Object
-
#initialize(argv) ⇒ Context
constructor
A new instance of Context.
- #on_failure_command ⇒ Object
- #parse_options! ⇒ Object
Methods inherited from Config
#[], #variables, #variables_set_defined?
Constructor Details
#initialize(argv) ⇒ Context
Returns a new instance of Context.
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 |
# File 'lib/bopeep.rb', line 1541 def initialize(argv) @argv = argv @playlist = Playlist.new(self) @parser = OptionParser.new @parser.on("-t", "--target HOSTS", Array, "hosts to use") do |hosts_data| hosts_data.each { |host_data| hosts.add(host_data) } end @parser.on("-f", "--filter key=value", String, "filters to apply to hosts") do |filter| key, value = filter.split("=", 2) @hosts.filters[key] = value end super() @hosts = @hosts.lazy end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
1536 1537 1538 |
# File 'lib/bopeep.rb', line 1536 def argv @argv end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
1537 1538 1539 |
# File 'lib/bopeep.rb', line 1537 def filters @filters end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
1538 1539 1540 |
# File 'lib/bopeep.rb', line 1538 def parser @parser end |
#playlist ⇒ Object (readonly)
Returns the value of attribute playlist.
1539 1540 1541 |
# File 'lib/bopeep.rb', line 1539 def playlist @playlist end |
Instance Method Details
#copy(config) ⇒ Object
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 |
# File 'lib/bopeep.rb', line 1565 def copy(config) config.hosts.each do |host| hosts.add(host) end self.on_failure_command = config.on_failure_command config.variables_sets.each do |variables_name| variables(variables_name) do |variables_object| variables_object.copy config.instance_variable_get("@#{variables_name}") end end end |
#on_failure_command ⇒ Object
1579 1580 1581 1582 1583 1584 1585 1586 |
# File 'lib/bopeep.rb', line 1579 def on_failure_command case @on_failure_command when String Object.const_get(@on_failure_command) else @on_failure_command end end |
#parse_options! ⇒ Object
1561 1562 1563 |
# File 'lib/bopeep.rb', line 1561 def @parser.parse(@argv) end |