ssh-short 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA512:
3
- metadata.gz: bbe973b7717c28b471aabdc48d745b426a06ca643b5e73917718d3a82e56fb21b80a4ac4c673777cf43c06889b029e56ea3d44fe778ae6a15e0850666c3471ac
4
- data.tar.gz: 76944a2e2c54ec68e1ce484fe8aea6dc45ed5e46267a5d4ce7f8e339345b1456ab0e31f2f8e7e5e8bb4cbba0292bc491553d04181a9ea296207e45b56cb2852c
3
+ data.tar.gz: 8dd082ac87f7edfae8849622cd12d53e72c869a794bba884d58b3a1b86155025f0cc11608ee1dc89b2c54759be97beadb6dffcdc8997f9fb975ccfbc4a49bab0
4
+ metadata.gz: abee1242981455872aa9556b41588e8fd0b379d1db3ca458951b2b662fdea744412db526862b7155689aa085427a758b14fae13bf4eaa7dee3939f3f556c73a8
5
5
  SHA1:
6
- metadata.gz: 20e9987e3c98a5143b9e66939a19eab801e22e7d
7
- data.tar.gz: f7e8835fb92e1f2f930755a26b2eaec005e1f4b3
6
+ data.tar.gz: 38070a5945bf08e55a334e6eff7a2e5abf5c6f7d
7
+ metadata.gz: 06f47f255095c87e0dcf0f740fc8c5ea7ad1085a
@@ -14,6 +14,7 @@ module SshShort
14
14
  abort "Error: No keys found in #{@keys_dir}" unless keys.count > 0
15
15
 
16
16
  key_names = keys.collect { |key| File.basename key }
17
+ key_names.unshift 'id_rsa'
17
18
 
18
19
  puts 'Select a key:'
19
20
  key_names.each_with_index { |key_name, i| puts "#{i}) #{key_name}" }
@@ -25,7 +26,8 @@ module SshShort
25
26
  end
26
27
 
27
28
  def get_key(key_name)
28
- key = "#{@keys_dir}/#{key_name}"
29
+ key = key_name.eql?('id_rsa') ? '~/.ssh/id_rsa' : "#{@keys_dir}/#{key_name}"
30
+ key = File.expand_path(key)
29
31
  abort "Error: Cannot find #{key}" unless File.exist? key
30
32
  key
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module SshShort
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+ require 'ssh_short/keyset'
3
+
4
+ describe SshShort::KeySet do
5
+
6
+ let(:keys_dir) { '/path/to/keys' }
7
+ let(:keys) { [ 'key_a.pem', 'key_b.pem', 'key_c.pem', 'key_d.pem' ] }
8
+
9
+ subject(:key_set) { SshShort::KeySet.new keys_dir }
10
+
11
+ before(:each) do
12
+ allow(File).to receive(:exist?) {keys_dir}.and_return(true)
13
+ allow(File).to receive(:file?).and_return(true)
14
+ allow(Dir).to receive(:glob).and_return(keys)
15
+ allow(STDIN).to receive(:gets).and_return('2')
16
+ allow(key_set).to receive(:puts) # Stop prompt list printing to STDOUT
17
+ end
18
+
19
+ describe 'prompt_for_key' do
20
+
21
+ it 'returns the name of the selected key' do
22
+ result = key_set.prompt_for_key
23
+ expect(result).to eq 'key_b.pem'
24
+ end
25
+
26
+ context 'when key 0 is selected' do
27
+
28
+ before(:each) do
29
+ allow(STDIN).to receive(:gets).and_return('0')
30
+ end
31
+
32
+ it 'returns the default key name' do
33
+ result = key_set.prompt_for_key
34
+ expect(result).to eq 'id_rsa'
35
+ end
36
+
37
+ end
38
+
39
+
40
+ end
41
+
42
+ describe 'get_key' do
43
+
44
+ it 'returns the key path from the name' do
45
+ key_name = 'key_c.pem'
46
+ result = key_set.get_key key_name
47
+ expect(result).to eq "#{keys_dir}/#{key_name}"
48
+ end
49
+
50
+ context 'when the default key name is provided' do
51
+
52
+ it 'returns the default key path' do
53
+ result = key_set.get_key 'id_rsa'
54
+ expect(result).to match /.ssh\/id_rsa/
55
+ end
56
+
57
+ end
58
+
59
+
60
+ end
61
+
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh-short
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Poulton
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2015-09-25 00:00:00 Z
12
+ date: 2016-02-11 00:00:00 Z
13
13
  dependencies: []
14
14
 
15
15
  description: Easy ssh
@@ -33,6 +33,7 @@ files:
33
33
  - lib/ssh_short/parser.rb
34
34
  - lib/ssh_short/version.rb
35
35
  - spec/spec_helper.rb
36
+ - spec/ssh_short/keyset_spec.rb
36
37
  - spec/ssh_short/nodemapper_spec.rb
37
38
  - spec/ssh_short/parser_spec.rb
38
39
  - ssh-short.gemspec
@@ -64,5 +65,6 @@ specification_version: 4
64
65
  summary: Fewer keystrokes to get things done
65
66
  test_files:
66
67
  - spec/spec_helper.rb
68
+ - spec/ssh_short/keyset_spec.rb
67
69
  - spec/ssh_short/nodemapper_spec.rb
68
70
  - spec/ssh_short/parser_spec.rb