Module: Sconb::SSHConfig

Defined in:
lib/sconb/ssh_config.rb

Class Method Summary collapse

Class Method Details

.load(path, regexp_str = '.*', options = []) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sconb/ssh_config.rb', line 4

def load(path, regexp_str = '.*', options = [])
  @path = path
  @regexp = Regexp.new(regexp_str)
  @options = options
  file = File.expand_path(@path)
  @configs = {}
  return @configs unless File.readable?(file)

  @allconfig = Net::SSH::Config.load_with_key(@path, '*', @options)
  @configs['*'] = @allconfig unless @allconfig.size <= 1
  IO.foreach(file) do |line|
    parse(line)
  end
  @configs
end