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.



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

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.



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

def commands
  @commands
end

#directoryObject (readonly)

Returns the value of attribute directory.



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

def directory
  @directory
end

Instance Method Details

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



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

def run(command, stdin: nil, env: {}, options: {})
  exec_non_interactive(raw_command: command, stdin: stdin, raw_env: env, options: options).tap do |executed_command|
    commands << executed_command
  end
end

#run_interactive(command, env: {}, options: {}, &block) ⇒ Object



35
36
37
38
39
# File 'lib/jet_black/session.rb', line 35

def run_interactive(command, env: {}, options: {}, &block)
  exec_interactive(raw_command: command, raw_env: env, options: options, block: block).tap do |executed_command|
    commands << executed_command
  end
end