ssh-host-lister 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/ssh_config/entry.rb +1 -1
- data/lib/ssh_config/loader.rb +27 -23
- data/ssh-host-lister.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 990e9e914a0b7bfef0cc9faa050facc6095a33a8b07ff25a753b7f2b57e14190
|
4
|
+
data.tar.gz: a5e711f556c084e8fd5c480910c72289ef0c4ba571a8b4247063f6fc2418882e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf891ba73c69f18f292c0e7310216d7de8704bca875eb9edd17a52e79898466fe1223701cf72ba2a024cefde31247ddc6dac0f30578fbcdbd09711ca466ea4c
|
7
|
+
data.tar.gz: 451f13069375f981e1278c4dcdf323af7e3e2c9985ab2194021ebcebd5f3a4a583df992a6bc8054748dc37aa482b8aeed0fe4054fd76935ac75a0ebad4542a76
|
data/lib/ssh_config/entry.rb
CHANGED
data/lib/ssh_config/loader.rb
CHANGED
@@ -5,42 +5,46 @@ module SshConfig
|
|
5
5
|
# For loading an ssh_config(5) file.
|
6
6
|
class Loader
|
7
7
|
def parse(str)
|
8
|
-
|
8
|
+
parse_lines(str.to_str.split(/[\n\r]+/))
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
.
|
13
|
-
.
|
11
|
+
def parse_lines(strings)
|
12
|
+
Array(strings).map(&:to_str).each do |line|
|
13
|
+
p_include(Regexp.last_match(1)) if line =~ /^\s*Include\s+(.*)/
|
14
|
+
p_host(Regexp.last_match(1)) if line =~ /^\s*Host\s+(.*)/
|
15
|
+
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
+
results
|
18
|
+
end
|
17
19
|
|
18
|
-
|
20
|
+
def results
|
21
|
+
@results ||= {}
|
19
22
|
end
|
20
|
-
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
def
|
24
|
+
private
|
25
|
+
|
26
|
+
def p_host(arg)
|
25
27
|
hosts = arg
|
26
28
|
.split(/\s+/)
|
27
29
|
.reject { |host| host =~ /^\d|%|\*/ }
|
28
30
|
|
29
|
-
|
30
|
-
entry = Entry.new(hosts)
|
31
|
-
entry.distinct_names.each { |host| results[host] = entry }
|
31
|
+
add_entry(Entry.new(hosts)) unless hosts.empty?
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
34
|
+
def p_include(glob)
|
35
|
+
old_dir = Dir.pwd
|
36
|
+
begin
|
37
|
+
Dir.chdir File.expand_path('~/.ssh')
|
38
|
+
Dir[glob.chomp].each do |fname|
|
39
|
+
parse(File.read(fname))
|
40
|
+
end
|
41
|
+
ensure
|
42
|
+
Dir.chdir old_dir
|
43
|
+
end
|
36
44
|
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
attr_writer :entry
|
41
|
-
|
42
|
-
def entry
|
43
|
-
@entry ||= nil
|
46
|
+
def add_entry(entry)
|
47
|
+
entry.distinct_names.each { |host| results[host] = entry }
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
data/ssh-host-lister.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssh-host-lister
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Höltje
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.7.2
|
201
201
|
signing_key:
|
202
202
|
specification_version: 4
|
203
203
|
summary: Lists unique, short host names ssh_config(5)
|