Class: Perfume::Shell::SystemCall

Inherits:
Base
  • Object
show all
Defined in:
lib/perfume/shell/system_call.rb

Overview

Public: Simple system call. Use it when you need to just execute something, eventually silently and you don’t care about the result. Uses ‘system` under the hood. Feel free to inherit from this class, example:

class GitCommit < Perfume::Shell::SystemCall
  args :message

  def cmd
    'git commit -m #{@message.inspect}'
  end
end

Instance Method Summary collapse

Methods inherited from Base

#before, #init, #log, #to_s

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
# File 'lib/perfume/shell/system_call.rb', line 22

def call
  Dir.chdir(@root.to_s) do
    before
    log.debug("Executing shell command", cmd: cmd, root: @root.to_s)
    system([ cmd, !!@quiet ? ' &>/dev/null' : nil ].compact.join(' '))
    fail! unless $?.to_i == 0
  end
end

#defaultsObject



18
19
20
# File 'lib/perfume/shell/system_call.rb', line 18

def defaults
  super.merge(quiet: false)
end