Class: Cardio::Commands::RakeCommand
- Defined in:
- lib/cardio/commands/rake_command.rb,
lib/cardio/commands/rake_command/parser.rb
Overview
enhance standard rake command with some decko/card -specific options
Defined Under Namespace
Classes: Parser
Instance Method Summary collapse
- #commands ⇒ Object
-
#initialize(rake_task, args = {}) ⇒ RakeCommand
constructor
A new instance of RakeCommand.
- #run ⇒ Object
Methods inherited from Command
#exit_with_child_status, #split_args
Constructor Details
#initialize(rake_task, args = {}) ⇒ RakeCommand
Returns a new instance of RakeCommand.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cardio/commands/rake_command.rb', line 8 def initialize rake_task, args={} @task = rake_task opts = {} if args.is_a? Array Parser.new(rake_task, opts).parse!(args) else opts = args end @envs = Array(opts[:envs]) end |
Instance Method Details
#commands ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/cardio/commands/rake_command.rb', line 31 def commands task_cmd = "bundle exec rake #{@task}" return [task_cmd] if !@envs || @envs.empty? @envs.map do |env| "env RAILS_ENV=#{env} #{task_cmd}" end end |
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cardio/commands/rake_command.rb', line 19 def run commands.each do |cmd| puts cmd # exit_with_child_status cmd result = `#{cmd}` process = $CHILD_STATUS puts result exit process.exitstatus unless process.success? end end |