Module: Sconb::SSHConfig
- Defined in:
- lib/sconb/ssh_config.rb
Class Method Summary collapse
- .load(path, regexp_str = '.*', options = []) ⇒ Object
- .parse(content, regexp_str = '.*', options = []) ⇒ Object
Class Method Details
.load(path, regexp_str = '.*', options = []) ⇒ Object
4 5 6 7 8 |
# File 'lib/sconb/ssh_config.rb', line 4 def load(path, regexp_str = '.*', = []) file = File.(path) content = File.readable?(file) ? File.open(file).read : nil parse(content, regexp_str, ) end |
.parse(content, regexp_str = '.*', options = []) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sconb/ssh_config.rb', line 10 def parse(content, regexp_str = '.*', = []) @regexp = Regexp.new(regexp_str) @options = @content = content @configs = {} return @configs if content.nil? @allconfig = Net::SSH::Config.parse_with_key(@content, '*', @options) @configs['*'] = @allconfig unless @allconfig.size <= 1 @content.each_line do |line| parse_line(line) end @configs end |