sconb 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sconb/ext/net/ssh/config.rb +3 -4
- data/lib/sconb/ssh_config.rb +14 -10
- data/lib/sconb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce50a910176ca5f5dbd57e32d2bfc18cfe882f3e
|
4
|
+
data.tar.gz: 2c05c98bf6f70c777d3893f020642444bebaa07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c28afe40de5c5089c6a10d5f1603c7370c0231dc891c25e54d783aeaecc9d390c94ab4e536a9a7ff0cce33158a5850ee243d3e993b357109f52cf70c633693a7
|
7
|
+
data.tar.gz: f19acd9534c333f70313eced8c4c9b16fdfcb60feb9b2037675a818f4691b0004dd664b7f1bc7b251b36d914e807569c81f82e55e17c881dfe77681ab8de072e
|
@@ -4,16 +4,15 @@ module Net
|
|
4
4
|
class << self
|
5
5
|
# Original code is Net::SSH::Config.load (https://github.com/net-ssh/net-ssh/blob/master/LICENSE.txt)
|
6
6
|
# rubocop:disable all
|
7
|
-
def
|
7
|
+
def parse_with_key(content, host, options)
|
8
8
|
settings = {}
|
9
|
-
|
10
|
-
return settings unless File.readable?(file)
|
9
|
+
return settings unless content
|
11
10
|
|
12
11
|
globals = {}
|
13
12
|
matched_host = nil
|
14
13
|
multi_host = []
|
15
14
|
seen_host = false
|
16
|
-
|
15
|
+
content.each_line do |line|
|
17
16
|
next if line =~ /^\s*(?:#.*)?$/
|
18
17
|
|
19
18
|
if line =~ /^\s*(\S+)\s*=(.*)$/
|
data/lib/sconb/ssh_config.rb
CHANGED
@@ -2,24 +2,28 @@ module Sconb
|
|
2
2
|
module SSHConfig
|
3
3
|
class << self
|
4
4
|
def load(path, regexp_str = '.*', options = [])
|
5
|
-
|
5
|
+
file = File.expand_path(path)
|
6
|
+
content = File.readable?(file) ? File.open(file).read : nil
|
7
|
+
parse(content, regexp_str, options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse(content, regexp_str = '.*', options = [])
|
6
11
|
@regexp = Regexp.new(regexp_str)
|
7
12
|
@options = options
|
8
|
-
|
13
|
+
@content = content
|
9
14
|
@configs = {}
|
10
|
-
return @configs
|
11
|
-
|
12
|
-
@allconfig = Net::SSH::Config.load_with_key(@path, '*', @options)
|
15
|
+
return @configs if content.nil?
|
16
|
+
@allconfig = Net::SSH::Config.parse_with_key(@content, '*', @options)
|
13
17
|
@configs['*'] = @allconfig unless @allconfig.size <= 1
|
14
|
-
|
15
|
-
|
18
|
+
@content.each_line do |line|
|
19
|
+
parse_line(line)
|
16
20
|
end
|
17
21
|
@configs
|
18
22
|
end
|
19
23
|
|
20
24
|
private
|
21
25
|
|
22
|
-
def
|
26
|
+
def parse_line(line)
|
23
27
|
return if line =~ /^\s*(?:#.*)?$/
|
24
28
|
if line =~ /^\s*(\S+)\s*=(.*)$/
|
25
29
|
key = Regexp.last_match[1]
|
@@ -35,7 +39,7 @@ module Sconb
|
|
35
39
|
positive_hosts.each do |host|
|
36
40
|
next if host == '*'
|
37
41
|
next unless host.match @regexp
|
38
|
-
config = Net::SSH::Config.
|
42
|
+
config = Net::SSH::Config.parse_with_key(@content, host, @options)
|
39
43
|
|
40
44
|
@allconfig.each do |k, _v|
|
41
45
|
next unless config.key? k
|
@@ -50,7 +54,7 @@ module Sconb
|
|
50
54
|
if key.downcase == 'match'
|
51
55
|
match_key = key + ' ' + value
|
52
56
|
return unless match_key.match @regexp
|
53
|
-
@configs[match_key] = Net::SSH::Config.
|
57
|
+
@configs[match_key] = Net::SSH::Config.parse_with_key(@content, value, @options)
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
data/lib/sconb/version.rb
CHANGED