Class: Devup::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/devup/shell.rb

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pwd:, logger:) ⇒ Shell

Returns a new instance of Shell.



7
8
9
10
# File 'lib/devup/shell.rb', line 7

def initialize(pwd:, logger:)
  @pwd = pwd
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



5
6
7
# File 'lib/devup/shell.rb', line 5

def logger
  @logger
end

#pwdObject (readonly)

Returns the value of attribute pwd.



5
6
7
# File 'lib/devup/shell.rb', line 5

def pwd
  @pwd
end

Instance Method Details

#exec(cmd) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/devup/shell.rb', line 19

def exec(cmd)
  logger.debug "$ #{cmd}"

  output, error, status = Open3.capture3(cmd + ";")

  logger.error(error) unless status.success?

  Result.new(output, status.success?)
end