Module: Hussh
- Defined in:
- lib/hussh.rb,
lib/hussh/channel.rb,
lib/hussh/session.rb,
lib/hussh/version.rb,
lib/hussh/configuration.rb
Defined Under Namespace
Classes: Channel, Configuration, Session
Constant Summary
collapse
- VERSION =
'0.2.1'
- @@recordings_directory =
'fixtures/hussh'
Class Method Summary
collapse
Class Method Details
.allow_connections! ⇒ Object
50
51
52
|
# File 'lib/hussh.rb', line 50
def self.allow_connections!
@@allow_connections = true
end
|
.allow_connections? ⇒ Boolean
46
47
48
|
# File 'lib/hussh.rb', line 46
def self.allow_connections?
@@allow_connections ||= false
end
|
.clear_recorded_responses ⇒ Object
98
99
100
|
# File 'lib/hussh.rb', line 98
def self.clear_recorded_responses
@@recorded_responses = {}
end
|
.clear_stubbed_responses ⇒ Object
110
111
112
|
# File 'lib/hussh.rb', line 110
def self.clear_stubbed_responses
@@stubbed_responses = {}
end
|
.commands_run ⇒ Object
66
67
68
|
# File 'lib/hussh.rb', line 66
def self.commands_run
@@commands_run ||= []
end
|
.configuration ⇒ Object
62
63
64
|
# File 'lib/hussh.rb', line 62
def self.configuration
@@configuration ||= Configuration.new
end
|
58
59
60
|
# File 'lib/hussh.rb', line 58
def self.configure
yield configuration
end
|
.disallow_connections ⇒ Object
54
55
56
|
# File 'lib/hussh.rb', line 54
def self.disallow_connections
@@allow_connections = false
end
|
.has_recording? ⇒ Boolean
74
75
76
|
# File 'lib/hussh.rb', line 74
def self.has_recording?
!!@@recorded_responses
end
|
.load_recording(name) ⇒ Object
78
79
80
81
82
83
84
85
86
|
# File 'lib/hussh.rb', line 78
def self.load_recording(name)
@@recording_path = self.path_for_recording(name)
@@recording_changed = false
if File.exist?(@@recording_path)
@@recorded_responses = YAML.load_file(@@recording_path)
else
self.clear_recorded_responses
end
end
|
.path_for_recording(name) ⇒ Object
115
116
117
|
# File 'lib/hussh.rb', line 115
def self.path_for_recording(name)
"#{@@recordings_directory}/#{name}.yaml"
end
|
.recording_changed! ⇒ Object
106
107
108
|
# File 'lib/hussh.rb', line 106
def self.recording_changed!
@@recording_changed = true
end
|
.recording_changed? ⇒ Boolean
102
103
104
|
# File 'lib/hussh.rb', line 102
def self.recording_changed?
@@recording_changed
end
|
.save_recording_if_changed ⇒ Object
88
89
90
91
92
93
94
95
96
|
# File 'lib/hussh.rb', line 88
def self.save_recording_if_changed
return if !self.recording_changed?
@@recording_path ||= self.path_for_recording(name)
if !File.exist?(@@recording_path)
FileUtils.mkdir_p(File.dirname(@@recording_path))
end
File.write(@@recording_path, @@recorded_responses.to_yaml)
@@recording_changed = false
end
|