Class: JetBlack::Session
- Inherits:
-
Object
- Object
- JetBlack::Session
- Extended by:
- Forwardable
- Defined in:
- lib/jet_black/session.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
-
#initialize(options: {}) ⇒ Session
constructor
A new instance of Session.
- #run(command, stdin: nil, env: {}, options: {}) ⇒ Object
- #run_interactive(command, env: {}, options: {}, &block) ⇒ Object
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 = @directory = File.realpath(Dir.mktmpdir("jet_black")) @file_helper = FileHelper.new(directory) end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
20 21 22 |
# File 'lib/jet_black/session.rb', line 20 def commands @commands end |
#directory ⇒ Object (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: ).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: , block: block).tap do |executed_command| commands << executed_command end end |