class FeduxOrgStdlib::Rake::ShellTask

Shell Task

@see Rakefile

Attributes

command[R]

@!attribute [r] command

The command to be executed
use_bundler[R]

@!attribute [r] use_bundler

Use bundler to run command

Public Class Methods

new( command:, use_bundler: false, **args ) click to toggle source

Create a new shell task

@param [String] command

The command to be executed

@param [true,false] use_bundler

Should the command be prefixed with `bundle exec`

@see Task

For other arguments accepted
Calls superclass method
# 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

Public Instance Methods

run_task(_verbose) click to toggle source

@private

# 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

Private Instance Methods

gemfile_exists?() click to toggle source
# File lib/fedux_org_stdlib/rake/shell_task.rb, line 55
def gemfile_exists?
  !Dir.glob('Gemfile').blank?
end