ssh-host-lister 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +16 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +0 -0
- data/.ruby-version +1 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/Guardfile +29 -0
- data/LICENSE.txt +21 -0
- data/README.md +10 -0
- data/Rakefile +9 -0
- data/bin/setup +6 -0
- data/exe/ssh_config_list +10 -0
- data/lib/ssh_config.rb +23 -0
- data/lib/ssh_config/entry.rb +30 -0
- data/lib/ssh_config/loader.rb +46 -0
- data/ssh-host-lister.gemspec +33 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c92d26bb06fde82baed4894150e4356a4f47015
|
4
|
+
data.tar.gz: 3d4d6059a5160a7a5af5fa128716b1690ef1d4fb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 94e1a91a95cf75a1dc40f3b7a13cd9de427594d97377c14b35bde6b5b513d79d3dbe5d7e015333b0c7a58d3d2f883a0afcd95ea5b272d16d894c7db5f0921240
|
7
|
+
data.tar.gz: ab4f07f82a608fd52320622842f0108a4db71424bb66207054defcc59daa83a3dee855dda0fb6f4b627560e4ecc43f10e5e068a3461f6ca254c401fd2f454ad4
|
data/.editorconfig
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# EditorConfig: http://EditorConfig.org
|
2
|
+
|
3
|
+
root = true
|
4
|
+
|
5
|
+
[*]
|
6
|
+
charset = utf-8
|
7
|
+
end_of_line = lf
|
8
|
+
insert_final_newline = true
|
9
|
+
trim_trailing_whitespace = true
|
10
|
+
|
11
|
+
[*.md]
|
12
|
+
max_line_length = 72
|
13
|
+
|
14
|
+
[*.rb,*.yml]
|
15
|
+
indent_style = space
|
16
|
+
indent_size = 2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
DisplayCopNames: true
|
4
|
+
|
5
|
+
Style/MultilineMethodCallIndentation:
|
6
|
+
EnforcedStyle: 'indented'
|
7
|
+
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Exclude:
|
10
|
+
- 'spec/**/*'
|
11
|
+
|
12
|
+
Metrics/LineLength:
|
13
|
+
Exclude:
|
14
|
+
- 'spec/**/*'
|
15
|
+
- '*.gemspec'
|
16
|
+
|
17
|
+
inherit_from: '.rubocop_todo.yml'
|
data/.rubocop_todo.yml
ADDED
File without changes
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
group :red_green_refactor, halt_on_fail: true do
|
5
|
+
guard(
|
6
|
+
:rspec,
|
7
|
+
cmd: 'bundle exec rspec --order defined --format doc',
|
8
|
+
all_on_start: true,
|
9
|
+
all_after_pass: true
|
10
|
+
) do
|
11
|
+
require 'guard/rspec/dsl'
|
12
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
13
|
+
|
14
|
+
dsl.rspec.tap do |rspec|
|
15
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
16
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
17
|
+
watch(rspec.spec_files)
|
18
|
+
end
|
19
|
+
|
20
|
+
dsl.ruby.tap do |ruby|
|
21
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
guard :rubocop do
|
26
|
+
watch(/.+\.rb$/)
|
27
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
28
|
+
end
|
29
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Christian Höltje
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/docwhat/ssh-host-lister.svg?branch=master)](https://travis-ci.org/docwhat/ssh-host-lister)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/docwhat/ssh-host-lister/badges/gpa.svg)](https://codeclimate.com/github/docwhat/ssh-host-lister)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/docwhat/ssh-host-lister/badges/coverage.svg)](https://codeclimate.com/github/docwhat/ssh-host-lister/coverage)
|
4
|
+
[![Issue Count](https://codeclimate.com/github/docwhat/ssh-host-lister/badges/issue_count.svg)](https://codeclimate.com/github/docwhat/ssh-host-lister)
|
5
|
+
|
6
|
+
|
7
|
+
# ssh-host-lister
|
8
|
+
|
9
|
+
The command `ssh-host-lister` is designed to make doing completion via
|
10
|
+
[FZF](https://github.com/junegunn/fzf) much smarter.
|
data/Rakefile
ADDED
data/bin/setup
ADDED
data/exe/ssh_config_list
ADDED
data/lib/ssh_config.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ssh_config/loader.rb'
|
4
|
+
|
5
|
+
# A module for listing out ssh_config(5)
|
6
|
+
module SshConfig
|
7
|
+
module_function
|
8
|
+
|
9
|
+
def default_loader
|
10
|
+
@default_loader ||= Loader.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_defaults
|
14
|
+
{}.tap do |result|
|
15
|
+
%w(/etc/ssh/ssh_config ~/.ssh/config)
|
16
|
+
.map { |path| File.expand_path path }
|
17
|
+
.select { |path| File.readable? path }
|
18
|
+
.each do |path|
|
19
|
+
result.merge! default_loader.parse(File.read(path))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SshConfig
|
4
|
+
# SshHost represents a single Host entry in an ssh_config(5)
|
5
|
+
class Entry
|
6
|
+
attr_reader :user
|
7
|
+
|
8
|
+
def initialize(*names)
|
9
|
+
@names = Array(names).flatten.map { |name| String(name) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def distinct_names
|
13
|
+
@distinct_names ||= begin
|
14
|
+
no_ips = @names
|
15
|
+
.sort(&:count)
|
16
|
+
.reject { |name| name =~ /\A\d+\.\d+\.\d+\.\d+\Z/ }
|
17
|
+
|
18
|
+
no_ips
|
19
|
+
.reject do |name|
|
20
|
+
parts = name.split('.')
|
21
|
+
parts.count != 1 && no_ips.include?(parts.first)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def user=(val)
|
27
|
+
@user = String(val)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ssh_config/entry'
|
3
|
+
|
4
|
+
module SshConfig
|
5
|
+
# For loading an ssh_config(5) file.
|
6
|
+
class Loader
|
7
|
+
def parse(str)
|
8
|
+
pr = ParseRun.new
|
9
|
+
|
10
|
+
str
|
11
|
+
.to_str
|
12
|
+
.split(/[\n\r]+/)
|
13
|
+
.each do |line|
|
14
|
+
|
15
|
+
pr.parse_host(Regexp.last_match(1)) if line =~ /^\s*Host\s+(.*)/
|
16
|
+
end
|
17
|
+
|
18
|
+
pr.results
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Internal method for parsing
|
23
|
+
class ParseRun
|
24
|
+
def parse_host(arg)
|
25
|
+
hosts = arg
|
26
|
+
.split(/\s+/)
|
27
|
+
.reject { |host| host =~ /^\d|%|\*/ }
|
28
|
+
|
29
|
+
return if hosts.empty?
|
30
|
+
entry = Entry.new(hosts)
|
31
|
+
entry.distinct_names.each { |host| results[host] = entry }
|
32
|
+
end
|
33
|
+
|
34
|
+
def results
|
35
|
+
@results ||= {}
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
attr_writer :entry
|
41
|
+
|
42
|
+
def entry
|
43
|
+
@entry ||= nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'ssh-host-lister'
|
6
|
+
spec.version = '0.1.0'
|
7
|
+
spec.authors = ['Christian Höltje']
|
8
|
+
spec.email = ['docwhat@gerf.org']
|
9
|
+
|
10
|
+
spec.summary = 'Lists unique, short host names ssh_config(5)'
|
11
|
+
spec.description = 'Generates a list of host names for ssh_config(5) suitable for shell completion or via fzf.'
|
12
|
+
spec.homepage = 'https://github.com/docwhat/ssh-host-lister'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
spec.required_ruby_version = '>= 2.3'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rake', '~> 11.3'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'reek', '~> 4.5'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.47.1'
|
29
|
+
|
30
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
31
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
32
|
+
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ssh-host-lister
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Höltje
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: reek
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.47.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.47.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.14'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.14'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.7'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.7'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.2'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.2'
|
125
|
+
description: Generates a list of host names for ssh_config(5) suitable for shell completion
|
126
|
+
or via fzf.
|
127
|
+
email:
|
128
|
+
- docwhat@gerf.org
|
129
|
+
executables:
|
130
|
+
- ssh_config_list
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".editorconfig"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".rubocop.yml"
|
138
|
+
- ".rubocop_todo.yml"
|
139
|
+
- ".ruby-version"
|
140
|
+
- ".travis.yml"
|
141
|
+
- Gemfile
|
142
|
+
- Guardfile
|
143
|
+
- LICENSE.txt
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- bin/setup
|
147
|
+
- exe/ssh_config_list
|
148
|
+
- lib/ssh_config.rb
|
149
|
+
- lib/ssh_config/entry.rb
|
150
|
+
- lib/ssh_config/loader.rb
|
151
|
+
- ssh-host-lister.gemspec
|
152
|
+
homepage: https://github.com/docwhat/ssh-host-lister
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '2.3'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.6.11
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: Lists unique, short host names ssh_config(5)
|
176
|
+
test_files: []
|