Class: Warg::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, playlist) ⇒ Context
constructor
A new instance of Context.
- #parse_options! ⇒ Object
Methods inherited from Config
#[], #variables, #variables_set_defined?
Constructor Details
#initialize(argv, playlist) ⇒ Context
Returns a new instance of Context.
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 |
# File 'lib/warg.rb', line 1436 def initialize(argv, playlist) @argv = argv @playlist = playlist @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.
1431 1432 1433 |
# File 'lib/warg.rb', line 1431 def argv @argv end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
1432 1433 1434 |
# File 'lib/warg.rb', line 1432 def filters @filters end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
1433 1434 1435 |
# File 'lib/warg.rb', line 1433 def parser @parser end |
#playlist ⇒ Object (readonly)
Returns the value of attribute playlist.
1434 1435 1436 |
# File 'lib/warg.rb', line 1434 def playlist @playlist end |
Instance Method Details
#copy(config) ⇒ Object
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 |
# File 'lib/warg.rb', line 1460 def copy(config) config.hosts.each do |host| hosts.add(host) end 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 |
#parse_options! ⇒ Object
1456 1457 1458 |
# File 'lib/warg.rb', line 1456 def @parser.parse(@argv) end |