Class: Warg::Context
Defined Under Namespace
Classes: Playlist
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
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.
- #parse_options! ⇒ Object
- #queue!(command) ⇒ Object
- #run! ⇒ Object
Methods inherited from Config
#[], #variables, #variables_set_defined?
Constructor Details
#initialize(argv) ⇒ Context
Returns a new instance of Context.
1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
# File 'lib/warg.rb', line 1381 def initialize(argv) @argv = argv @parser = OptionParser.new @playlist = Playlist.new @parser.on("-t", "--target HOSTS", Array, "hosts to use") do |hosts_data| hosts_data.each { |host_data| hosts.add(host_data) } end super() end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv
1378 1379 1380 |
# File 'lib/warg.rb', line 1378 def argv @argv end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser
1379 1380 1381 |
# File 'lib/warg.rb', line 1379 def parser @parser end |
Instance Method Details
#copy(config) ⇒ Object
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 |
# File 'lib/warg.rb', line 1407 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
1393 1394 1395 |
# File 'lib/warg.rb', line 1393 def @parser.parse(@argv) end |
#queue!(command) ⇒ Object
1397 1398 1399 |
# File 'lib/warg.rb', line 1397 def queue!(command) @playlist.queue(command) end |
#run! ⇒ Object
1401 1402 1403 1404 1405 |
# File 'lib/warg.rb', line 1401 def run! Console.hostname_width = hosts.map { |host| host.address.length }.max @playlist.start end |