Class: FPM::Cookery::Shellout

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/cookery/shellout.rb

Defined Under Namespace

Classes: CommandFailed

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, *args) ⇒ Shellout

Returns a new instance of Shellout.



20
21
22
# File 'lib/fpm/cookery/shellout.rb', line 20

def initialize(command, *args)
  @command = command.to_s % args
end

Class Method Details

.git_config_get(key) ⇒ Object



16
17
18
# File 'lib/fpm/cookery/shellout.rb', line 16

def self.git_config_get(key)
  new('git config --get %s', key).run.chomp
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
# File 'lib/fpm/cookery/shellout.rb', line 24

def run
  status, stdout, stderr = systemu(@command)

  if status.success?
    stdout
  else
    raise CommandFailed.new("Shellout command failed: #{@command}", stderr)
  end
end