Class: Inspec::Resources::SshConfig
- Inherits:
-
Object
- Object
- Inspec::Resources::SshConfig
show all
- Includes:
- FileReader
- Defined in:
- lib/inspec/resources/ssh_config.rb
Instance Method Summary
collapse
Methods included from FileReader
#read_file_content
Constructor Details
#initialize(conf_path = nil, type = nil) ⇒ SshConfig
Returns a new instance of SshConfig.
22
23
24
25
26
27
|
# File 'lib/inspec/resources/ssh_config.rb', line 22
def initialize(conf_path = nil, type = nil)
@conf_path = conf_path || ssh_config_file("ssh_config")
typename = (@conf_path.include?("sshd") ? "Server" : "Client")
@type = type || "SSH #{typename} configuration #{conf_path}"
read_content
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/inspec/resources/ssh_config.rb', line 45
def method_missing(name)
param = read_params[name.to_s.downcase]
return nil if param.nil?
return param[0] if param.length == 1
param
end
|
Instance Method Details
#content ⇒ Object
29
30
31
|
# File 'lib/inspec/resources/ssh_config.rb', line 29
def content
read_content
end
|
#convert_hash(hash) ⇒ Object
39
40
41
42
43
|
# File 'lib/inspec/resources/ssh_config.rb', line 39
def convert_hash(hash)
new_hash = {}
hash.each { |k, v| new_hash[k.downcase] ||= v }
new_hash
end
|
#params(*opts) ⇒ Object
33
34
35
36
37
|
# File 'lib/inspec/resources/ssh_config.rb', line 33
def params(*opts)
opts.inject(read_params) do |res, nxt|
res.respond_to?(:key) ? res[nxt] : nil
end
end
|
#resource_id ⇒ Object
57
58
59
|
# File 'lib/inspec/resources/ssh_config.rb', line 57
def resource_id
@conf_path || "SSH Configuration"
end
|
#to_s ⇒ Object
53
54
55
|
# File 'lib/inspec/resources/ssh_config.rb', line 53
def to_s
"SSH Configuration"
end
|