Class: Cumuli::CLI::RemoteRakeCommand
- Inherits:
-
Object
- Object
- Cumuli::CLI::RemoteRakeCommand
- Defined in:
- lib/cumuli/cli/remote_rake_command.rb
Constant Summary collapse
- DIR_ENV =
'DIR='
- COMMAND_ENV =
'COMMAND='
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
Instance Method Summary collapse
- #command ⇒ Object
- #dir ⇒ Object
- #extract_env(env_var) ⇒ Object
- #get_passed_command ⇒ Object
-
#initialize(argv) ⇒ RemoteRakeCommand
constructor
A new instance of RemoteRakeCommand.
- #perform ⇒ Object
- #raw_command ⇒ Object
Constructor Details
#initialize(argv) ⇒ RemoteRakeCommand
Returns a new instance of RemoteRakeCommand.
9 10 11 12 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 9 def initialize(argv) puts "argv: #{argv.inspect}" @argv = argv end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
4 5 6 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 4 def argv @argv end |
Instance Method Details
#command ⇒ Object
32 33 34 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 32 def command Commander.new(raw_command).build end |
#dir ⇒ Object
19 20 21 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 19 def dir extract_env(DIR_ENV) end |
#extract_env(env_var) ⇒ Object
14 15 16 17 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 14 def extract_env(env_var) found_arg = argv.detect{|arg| arg.include?(env_var)} found_arg && found_arg.gsub(env_var, '') end |
#get_passed_command ⇒ Object
27 28 29 30 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 27 def get_passed_command matched = argv.first.match(/\[(.*)\]/) (matched && matched[1]) || argv.first end |
#perform ⇒ Object
36 37 38 39 40 41 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 36 def perform Dir.chdir(dir) do puts "running #{command}, at #{dir}" Terminal.new(command).spawn end end |
#raw_command ⇒ Object
23 24 25 |
# File 'lib/cumuli/cli/remote_rake_command.rb', line 23 def raw_command extract_env(COMMAND_ENV) || get_passed_command end |