sconb 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c5e18b93db4b66082d25aa8c270858e572d6bd5
4
- data.tar.gz: 50eb6adc5e2756f97797b33b898ea70e5f570fa4
3
+ metadata.gz: ed851f7d1f6dee675df9cb3f6f54db7390b4842d
4
+ data.tar.gz: 31fbd7a45d6c75a41dc07f623ccf394217ed3336
5
5
  SHA512:
6
- metadata.gz: 2221bdfc63d7912663c82af6181fd0951d4aeff590a6c88b14c1e9e1feb34417af493667f650490ec446502037dfd39563ec78f38529faecb7d8b6127c0b966c
7
- data.tar.gz: f25ff865d164c8b821385e54376f108a9a6baed156e1fcb66ae42629d29399391719a360eac5fb2a12b4487c59e8fb2ece143ecdfa23d6aa97e1f7a673d63cf3
6
+ metadata.gz: 0edb1530624633d53f4a5b06c75c201948755679237272f0b665dd2027bd90c0bb646bc8cbba2f150c6f4f500e8645e585f2a665d3dfd7782dcf78c3a7ed7a1d
7
+ data.tar.gz: ae9f091236ce84509063ab6d67b0d5a346f3e4b55ca11cda016ceb01e30be6237e22a00cabe1bd388f6e17fdd26e91f6bfd7c2afb8ec0d1742c945c81129efc1
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: 3dmdcfV4sVhAhf5hnZhaO3NknvYRYKhJH
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ install:
5
+ - gem install bundler
6
+ - bundle install
7
+ script:
8
+ - bundle exec rake spec
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
- ### Select host
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 | jq '{"github.com"}' > github.json
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
- ### Merge config
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
@@ -1,3 +1,3 @@
1
1
  module Sconb
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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
- configs[key + ' ' + value] = config_load(path, value)
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
@@ -1,3 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
1
3
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
4
  require 'sconb'
3
5
 
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.6
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-09-18 00:00:00.000000000 Z
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