Class: Train::Transports::Mock::Connection
- Inherits:
-
BaseConnection
- Object
- BaseConnection
- Train::Transports::Mock::Connection
show all
- Defined in:
- lib/train/transports/mock.rb,
lib/train/transports/mock.rb,
lib/train/transports/mock.rb,
lib/train/transports/mock.rb
Defined Under Namespace
Classes: Command, File, OS
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(conf = nil) ⇒ Connection
Returns a new instance of Connection.
61
62
63
64
65
66
67
|
# File 'lib/train/transports/mock.rb', line 61
def initialize(conf = nil)
@conf = conf || {}
@files = {}
@os = OS.new(self, family: 'unknown')
@commands = {}
trace_calls if @conf[:verbose]
end
|
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
58
59
60
|
# File 'lib/train/transports/mock.rb', line 58
def commands
@commands
end
|
#files ⇒ Object
Returns the value of attribute files.
58
59
60
|
# File 'lib/train/transports/mock.rb', line 58
def files
@files
end
|
#os ⇒ Object
Returns the value of attribute os.
59
60
61
|
# File 'lib/train/transports/mock.rb', line 59
def os
@os
end
|
Instance Method Details
#file(path) ⇒ Object
83
84
85
|
# File 'lib/train/transports/mock.rb', line 83
def file(path)
@files[path] ||= File.new(self, path)
end
|
#mock_command(cmd, stdout = nil, stderr = nil, exit_status = 0) ⇒ Object
73
74
75
|
# File 'lib/train/transports/mock.rb', line 73
def mock_command(cmd, stdout = nil, stderr = nil, exit_status = 0)
@commands[cmd] = Command.new(stdout || '', stderr || '', exit_status)
end
|
#mock_os(value) ⇒ Object
69
70
71
|
# File 'lib/train/transports/mock.rb', line 69
def mock_os(value)
@os = OS.new(self, value)
end
|
#run_command(cmd) ⇒ Object
77
78
79
80
81
|
# File 'lib/train/transports/mock.rb', line 77
def run_command(cmd)
@commands[cmd] ||
@commands[Digest::SHA256.hexdigest cmd] ||
mock_command(cmd)
end
|
#to_s ⇒ Object
87
88
89
|
# File 'lib/train/transports/mock.rb', line 87
def to_s
'Mock Connection'
end
|