Class: Cardio::Command::RakeCommand
Overview
enhance standard rake command with some decko/card -specific options
Instance Method Summary
collapse
Methods inherited from CommandBase
#exit_with_child_status, #split_args
Constructor Details
#initialize(gem, command, args = []) ⇒ RakeCommand
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/cardio/command/rake_command.rb', line 8
def initialize gem, command, args=[]
super()
@command = command
@task = "#{gem}:#{command}"
@args = [args].flatten
end
|
Instance Method Details
#commands ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cardio/command/rake_command.rb', line 34
def commands
task_cmd = "bundle exec rake #{@task}"
task_cmd += " -- #{escape_args(@args).join ' '}" unless @args.empty?
puts task_cmd.yellow
[task_cmd] if !@envs || @envs.empty?
end
|
#escape_args(args) ⇒ Object
45
46
47
48
49
|
# File 'lib/cardio/command/rake_command.rb', line 45
def escape_args args
args.map do |arg|
arg.start_with?("-") ? arg : arg.shellescape
end
end
|
#run ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/cardio/command/rake_command.rb', line 22
def run
commands.each do |cmd|
result = `#{cmd}`
process = $CHILD_STATUS
puts result
exit process.exitstatus unless process.success?
end
end
|