Class: Cardio::Command::RakeCommand
- Inherits:
-
CommandBase
- Object
- CommandBase
- Cardio::Command::RakeCommand
- Defined in:
- card/lib/cardio/command/rake_command.rb
Overview
enhance standard rake command with some decko/card -specific options
Instance Method Summary collapse
-
#commands ⇒ Object
-
#escape_args(args) ⇒ Object
-
#initialize(gem, command, args = []) ⇒ RakeCommand
constructor
A new instance of RakeCommand.
-
#run ⇒ Object
Methods inherited from CommandBase
#exit_with_child_status, #split_args
Constructor Details
#initialize(gem, command, args = []) ⇒ RakeCommand
Returns a new instance of RakeCommand.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'card/lib/cardio/command/rake_command.rb', line 8 def initialize gem, command, args=[] @command = command @task = "#{gem}:#{command}" @args = [args].flatten # 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
33 34 35 36 37 38 39 40 41 42 |
# File 'card/lib/cardio/command/rake_command.rb', line 33 def commands task_cmd = "bundle exec rake #{@task}" task_cmd += " -- #{escape_args(@args).join ' '}" unless @args.empty? puts task_cmd return [task_cmd] if !@envs || @envs.empty? # @envs.map do |env| # "env RAILS_ENV=#{env} #{task_cmd}" # end end |
#escape_args(args) ⇒ Object
44 45 46 47 48 |
# File 'card/lib/cardio/command/rake_command.rb', line 44 def escape_args args args.map do |arg| arg.start_with?("-") ? arg : arg.shellescape end end |
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'card/lib/cardio/command/rake_command.rb', line 21 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 |