sconb 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.travis.yml +8 -0
- data/README.md +10 -4
- data/lib/sconb/version.rb +1 -1
- data/lib/sconb.rb +7 -3
- data/sconb.gemspec +1 -0
- data/spec/sconb_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed851f7d1f6dee675df9cb3f6f54db7390b4842d
|
4
|
+
data.tar.gz: 31fbd7a45d6c75a41dc07f623ccf394217ed3336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0edb1530624633d53f4a5b06c75c201948755679237272f0b665dd2027bd90c0bb646bc8cbba2f150c6f4f500e8645e585f2a665d3dfd7782dcf78c3a7ed7a1d
|
7
|
+
data.tar.gz: ae9f091236ce84509063ab6d67b0d5a346f3e4b55ca11cda016ceb01e30be6237e22a00cabe1bd388f6e17fdd26e91f6bfd7c2afb8ec0d1742c945c81129efc1
|
data/.coveralls.yml
ADDED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Sconb
|
1
|
+
# Sconb [![Gem Version](https://badge.fury.io/rb/sconb.svg)](http://badge.fury.io/rb/sconb) [![Build Status](https://travis-ci.org/k1LoW/sconb.svg?branch=master)](https://travis-ci.org/k1LoW/sconb) [![Coverage Status](https://coveralls.io/repos/k1LoW/sconb/badge.png)](https://coveralls.io/r/k1LoW/sconb) [![Dependency Status](https://gemnasium.com/k1LoW/sconb.svg)](https://gemnasium.com/k1LoW/sconb)
|
2
2
|
|
3
3
|
Ssh CONfig Buckup tool.
|
4
4
|
|
@@ -36,17 +36,23 @@ Install it yourself as:
|
|
36
36
|
|
37
37
|
## Advanced Tips
|
38
38
|
|
39
|
-
|
39
|
+
in like [.ssh/config](spec/config_test_multi)
|
40
|
+
|
41
|
+
### Filter host
|
40
42
|
|
41
43
|
Dump github.com config only.
|
42
44
|
|
43
|
-
$ sconb dump
|
45
|
+
$ sconb dump github.com > github.json
|
44
46
|
|
45
47
|
And append github.com config to .ssh/config
|
46
48
|
|
47
49
|
$ sconb restore < github.json >> ~/.ssh/config
|
48
50
|
|
49
|
-
|
51
|
+
Dump github.com and gist configs.
|
52
|
+
|
53
|
+
$ sconb dump gis?t > github_gist.json
|
54
|
+
|
55
|
+
### Merge config with jq
|
50
56
|
|
51
57
|
$ jq -s '.[0] + .[1]' a.json b.json | sconb restore > ~/.ssh/config
|
52
58
|
|
data/lib/sconb/version.rb
CHANGED
data/lib/sconb.rb
CHANGED
@@ -10,7 +10,8 @@ module Sconb
|
|
10
10
|
method_option :all, :type => :boolean, :aliases => '-a', :default => false, :banner => 'dump .ssh/config and private keys.'
|
11
11
|
method_option :config, :type => :string, :aliases => '-c', :default => '~/.ssh/config', :banner => '.ssh/config path'
|
12
12
|
desc "dump > dump.json", "Dump .ssh/config to JSON"
|
13
|
-
def dump()
|
13
|
+
def dump(regexp_str = '.*')
|
14
|
+
regexp = Regexp.new regexp_str
|
14
15
|
path = options[:config]
|
15
16
|
file = File.expand_path(path)
|
16
17
|
configs = {}
|
@@ -34,7 +35,8 @@ module Sconb
|
|
34
35
|
if key.downcase == 'host'
|
35
36
|
negative_hosts, positive_hosts = value.to_s.split(/\s+/).partition { |h| h.start_with?('!') }
|
36
37
|
positive_hosts.each do | host |
|
37
|
-
next if host == '*'
|
38
|
+
next if host == '*'
|
39
|
+
next unless host.match regexp
|
38
40
|
config = config_load(path, host)
|
39
41
|
|
40
42
|
allconfig.each do |key, value|
|
@@ -48,7 +50,9 @@ module Sconb
|
|
48
50
|
|
49
51
|
# Match
|
50
52
|
if key.downcase == 'match'
|
51
|
-
|
53
|
+
match_key = key + ' ' + value
|
54
|
+
next unless match_key.match regexp
|
55
|
+
configs[match_key] = config_load(path, value)
|
52
56
|
end
|
53
57
|
|
54
58
|
end
|
data/sconb.gemspec
CHANGED
@@ -23,5 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "coveralls"
|
26
27
|
spec.add_dependency "thor"
|
27
28
|
end
|
data/spec/sconb_spec.rb
CHANGED
@@ -59,6 +59,37 @@ OUT
|
|
59
59
|
OUT
|
60
60
|
end
|
61
61
|
|
62
|
+
it "should convert from multi config to JSON with filter" do
|
63
|
+
expect(capture(:stdout) {
|
64
|
+
Sconb::CLI.new.invoke(:dump, ['gis?t'], {config: File.expand_path('../config_test_multi', __FILE__)})
|
65
|
+
}).to eq <<OUT
|
66
|
+
{
|
67
|
+
"github.com": {
|
68
|
+
"Host": "github.com",
|
69
|
+
"User": "git",
|
70
|
+
"Port": "22",
|
71
|
+
"Hostname": "github.com",
|
72
|
+
"IdentityFile": [
|
73
|
+
"spec/github_rsa"
|
74
|
+
],
|
75
|
+
"TCPKeepAlive": "yes",
|
76
|
+
"IdentitiesOnly": "yes"
|
77
|
+
},
|
78
|
+
"gist": {
|
79
|
+
"Host": "gist",
|
80
|
+
"User": "git",
|
81
|
+
"Port": "22",
|
82
|
+
"Hostname": "gist.github.com",
|
83
|
+
"IdentityFile": [
|
84
|
+
"spec/github_rsa"
|
85
|
+
],
|
86
|
+
"TCPKeepAlive": "yes",
|
87
|
+
"IdentitiesOnly": "yes"
|
88
|
+
}
|
89
|
+
}
|
90
|
+
OUT
|
91
|
+
end
|
92
|
+
|
62
93
|
it "should convert from .ssh/config to JSON with private keys" do
|
63
94
|
expect(capture(:stdout) {
|
64
95
|
Sconb::CLI.new.invoke(:dump, [], {config: File.expand_path('../config_test', __FILE__), all: true})
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sconb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: thor
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,8 +116,10 @@ executables:
|
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
104
118
|
files:
|
119
|
+
- ".coveralls.yml"
|
105
120
|
- ".gitignore"
|
106
121
|
- ".rspec"
|
122
|
+
- ".travis.yml"
|
107
123
|
- Gemfile
|
108
124
|
- LICENSE.txt
|
109
125
|
- README.md
|