Class: FeduxOrgStdlib::Rake::ShellTask
- Defined in:
- lib/fedux_org_stdlib/rake/shell_task.rb
Overview
Shell Task
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#use_bundler ⇒ Object
readonly
Returns the value of attribute use_bundler.
Attributes inherited from Task
#description, #name, #verbose, #verbose (true)
Instance Method Summary collapse
-
#initialize(command:, use_bundler: false, **args) ⇒ ShellTask
constructor
Create a new shell task.
- #run_task(_verbose) ⇒ Object
Methods inherited from Task
Constructor Details
#initialize(command:, use_bundler: false, **args) ⇒ ShellTask
Create a new shell task
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fedux_org_stdlib/rake/shell_task.rb', line 31 def initialize( command:, use_bundler: false, **args ) super(**args) @use_bundler = use_bundler @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
15 16 17 |
# File 'lib/fedux_org_stdlib/rake/shell_task.rb', line 15 def command @command end |
#use_bundler ⇒ Object (readonly)
Returns the value of attribute use_bundler.
19 20 21 |
# File 'lib/fedux_org_stdlib/rake/shell_task.rb', line 19 def use_bundler @use_bundler end |
Instance Method Details
#run_task(_verbose) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/fedux_org_stdlib/rake/shell_task.rb', line 43 def run_task(_verbose) logger.warn 'Gemfile does not exist. Running bundler will fail. I am going to run the command without `bundle exec`.' unless gemfile_exists? cmd = [] cmd << 'bundle exec' if use_bundler && gemfile_exists? cmd << command sh Erubis::Eruby.new(cmd.join(' ')).result(instance_binding) end |