Class: JetBlack::Session

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jet_black/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options: {}) ⇒ Session

Returns a new instance of Session.



21
22
23
24
25
26
# File 'lib/jet_black/session.rb', line 21

def initialize(options: {})
  @commands = []
  @session_options = options
  @directory = File.realpath(Dir.mktmpdir("jet_black"))
  @file_helper = FileHelper.new(directory)
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



19
20
21
# File 'lib/jet_black/session.rb', line 19

def commands
  @commands
end

#directoryObject (readonly)

Returns the value of attribute directory.



19
20
21
# File 'lib/jet_black/session.rb', line 19

def directory
  @directory
end

Instance Method Details

#run(command, stdin: nil, env: {}, options: {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/jet_black/session.rb', line 28

def run(command, stdin: nil, env: {}, options: {})
  combined_options = session_options.merge(options)
  executed_command = exec_command(command, stdin, env, combined_options)
  commands << executed_command
  executed_command
end