Class: VagrantPlugins::DevCommands::Model::Command
- Inherits:
-
Object
- Object
- VagrantPlugins::DevCommands::Model::Command
- Defined in:
- lib/vagrant/devcommands/model/command.rb
Overview
Definition of an executable command
Constant Summary collapse
- PARAM_PARSER =
VagrantPlugins::DevCommands::ParamParser
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#tty ⇒ Object
readonly
Returns the value of attribute tty.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
-
#initialize(spec) ⇒ Command
constructor
A new instance of Command.
- #run_script(argv) ⇒ Object
Constructor Details
#initialize(spec) ⇒ Command
Returns a new instance of Command.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vagrant/devcommands/model/command.rb', line 12 def initialize(spec) @name = spec[:name] @flags = spec[:flags] || {} @parameters = spec[:parameters] || {} @script = spec[:script] @tty = spec[:tty] == true @machine = spec[:machine] @desc = spec[:desc] @help = spec[:help] @usage = spec[:usage] end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def desc @desc end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def flags @flags end |
#help ⇒ Object (readonly)
Returns the value of attribute help.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def help @help end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def machine @machine end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def name @name end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def parameters @parameters end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def script @script end |
#tty ⇒ Object (readonly)
Returns the value of attribute tty.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def tty @tty end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
10 11 12 |
# File 'lib/vagrant/devcommands/model/command.rb', line 10 def usage @usage end |
Instance Method Details
#run_script(argv) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant/devcommands/model/command.rb', line 26 def run_script(argv) param_parser = PARAM_PARSER.new params = param_parser.parse!(self, argv) script = @script script = eval_script_proc(script, params) if script.is_a?(Proc) (script % params).strip end |