sshez 1.0.0 → 1.0.2

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: 92e7ad6ffc038ec583c0e8d15995dae91f3e9213
4
- data.tar.gz: abee0de7a57f897b1c4282104004c25fac951c01
3
+ metadata.gz: 5d67f02bfbc4bab3ad5cda1254209ee5f05ed5e7
4
+ data.tar.gz: 9d16b4baca02436c2fcbfddfd1ddc45a99459d26
5
5
  SHA512:
6
- metadata.gz: 9bdcd92b15600a5608b20551fbaa1ed4aa54a03ee92633ca2b50e2ff487fcb9bd74f8ce52cf81dafd903554e2ca68432cd1ca7b1346dbaffbb8c1d00ad4ed127
7
- data.tar.gz: e66737176284415821b272430bd6e591fb5424775082999b21a89b506b8592f612185b8cf1681b5694992fdf768be4e30f2f752eae7e174f6ca5949aa14fb9cf
6
+ metadata.gz: ff60f9af66f116fdd3842771c9d1213b74689f4348fca1a00ecceb26dcb814b9e3ed4adb0d553e58f33620876bd261f522ebe57e4d760889e0f5e52edcb37f3a
7
+ data.tar.gz: c52207746a1f31ddc73e85d60b64be011cf8ba9eb2d0856a8bcc81905a9bf9f2f9107443978416fb91bb7c6839f1fcdeb0418df0f8b647bf4e23391c36c6e8bd
@@ -1,6 +1,9 @@
1
+ ### UNRELEASED
2
+
1
3
  ### 1.0.0 - 2016-02-09
2
4
 
3
5
  * enhancements
6
+ * Added `reset` for removing all aliases
4
7
  * Added `connect` for ssh connection
5
8
  * Added `sshez add` as default and only way to add aliases (breaking change)
6
9
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sshez (1.0.0)
4
+ sshez (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -33,6 +33,8 @@ module Sshez
33
33
  (proc { |alias_name, role_host| [alias_name] + role_host.split('@') })),
34
34
  'remove' => Command.new('remove', (proc { |args| args.length == 1 }),
35
35
  'sshez remove <alias>'),
36
+ 'rm' => Command.new('remove', (proc { |args| args.length == 1 }),
37
+ 'sshez rm <alias>'),
36
38
  'connect' => Command.new('connect', (proc { |args| args.length == 1 }),
37
39
  'sshez connect <alias>'),
38
40
  'reset' => Command.new('reset', (proc { |args| args.length == 0 }),
@@ -98,15 +98,17 @@ module Sshez
98
98
  #
99
99
  def remove(alias_name, options)
100
100
  file = File.open(FILE_PATH, 'r')
101
- new_file = File.open(FILE_PATH + 'temp', 'w')
102
- remove_alias_name(alias_name, file, new_file)
103
-
104
- File.delete(FILE_PATH)
105
- File.rename(FILE_PATH + 'temp', FILE_PATH)
106
- # Causes a bug in fedore if permission was not updated to 0600
107
- File.chmod(0600, FILE_PATH)
108
-
109
- unless PRINTER.output?
101
+ servers = all_hosts_in(file)
102
+ if servers.include?alias_name
103
+ new_file = File.open(FILE_PATH + 'temp', 'w')
104
+ remove_alias_name(alias_name, file, new_file)
105
+
106
+ File.delete(FILE_PATH)
107
+ File.rename(FILE_PATH + 'temp', FILE_PATH)
108
+ # Causes a bug in fedore if permission was not updated to 0600
109
+ File.chmod(0600, FILE_PATH)
110
+ PRINTER.print "`#{alias_name}` was successfully removed from your hosts"
111
+ else
110
112
  PRINTER.print "Could not find host `#{alias_name}`"
111
113
  end
112
114
  finish_exec
@@ -154,8 +156,12 @@ module Sshez
154
156
  end # list(options)
155
157
 
156
158
  def reset(options)
157
- file = File.open(FILE_PATH, "w")
158
- file.close
159
+ resp = PRINTER.prompt 'Are you sure you want to remove all aliases? [Y/n]'
160
+ if resp.match(/y/i)
161
+ file = File.open(FILE_PATH, "w")
162
+ file.close
163
+ PRINTER.print 'You have successfully reset your ssh config file.'
164
+ end
159
165
  end
160
166
 
161
167
  #
@@ -13,20 +13,31 @@ module Sshez
13
13
  @verbose = false
14
14
  end
15
15
 
16
- # adds to output then prints
16
+ #
17
+ # Adds to output then prints
18
+ #
17
19
  def print(text)
18
20
  @output += %(#{text}\n)
19
21
  puts text
20
22
  end # print(text)
21
23
 
22
24
  #
23
- # prints only if verbose set to true
25
+ # Adds to output and prints only if verbose set to true
24
26
  #
25
27
  def verbose_print(text)
26
28
  @output += %(#{text}\n)
27
29
  puts text if @verbose
28
30
  end
29
31
 
32
+ #
33
+ # Prompts for user input
34
+ #
35
+ def prompt(text)
36
+ @output += %(#{text}\n)
37
+ print text
38
+ STDIN.gets
39
+ end # print(text)
40
+
30
41
  #
31
42
  # Did we print anything?
32
43
  #
@@ -2,5 +2,5 @@ module Sshez
2
2
  #
3
3
  # Returns version
4
4
  #
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.2"
6
6
  end
@@ -68,7 +68,7 @@ describe Sshez do
68
68
  end
69
69
 
70
70
  it 'ends with 30' do
71
- expect(output).to end_with "30\n\nTerminated Successfully!\n"
71
+ expect(output).to end_with "\nTerminated Successfully!\n"
72
72
  end
73
73
  end
74
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshez
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Immortal Friday
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-09 00:00:00.000000000 Z
12
+ date: 2016-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler