pws 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/features/get.feature +12 -0
- data/lib/pws.rb +13 -4
- data/lib/pws/version.rb +1 -1
- metadata +2 -2
data/features/get.feature
CHANGED
@@ -57,5 +57,17 @@ Feature: Get
|
|
57
57
|
And I type "my_master_password_wrong"
|
58
58
|
Then the output should contain "Master password:"
|
59
59
|
And the output should contain "NO ACCESS"
|
60
|
+
|
61
|
+
Scenario: Get the password for "gihub" using an abbrev shortcut
|
62
|
+
Given A safe exists with master password "my_master_password" and keys
|
63
|
+
| github | 123 |
|
64
|
+
| google | 345 |
|
65
|
+
| gitorious | 678 |
|
66
|
+
When I run `pws get gith 0` interactively
|
67
|
+
And I type "my_master_password"
|
68
|
+
Then the output should contain "Master password:"
|
69
|
+
And the output should contain "The password for github has been copied to your clipboard"
|
70
|
+
And the clipboard should contain "123"
|
71
|
+
|
60
72
|
|
61
73
|
|
data/lib/pws.rb
CHANGED
@@ -4,8 +4,10 @@ require_relative 'pws/encryptor'
|
|
4
4
|
require_relative 'pws/format'
|
5
5
|
|
6
6
|
require 'fileutils'
|
7
|
-
require 'clipboard'
|
8
7
|
require 'securerandom'
|
8
|
+
require 'abbrev'
|
9
|
+
|
10
|
+
require 'clipboard'
|
9
11
|
require 'zucker/alias_for'
|
10
12
|
require 'paint/pa'
|
11
13
|
|
@@ -98,11 +100,12 @@ class PWS
|
|
98
100
|
|
99
101
|
# Gets the password entry and copies it to the clipboard. The second parameter is the time in seconds it stays there
|
100
102
|
def get(key, seconds = @options[:seconds])
|
101
|
-
if
|
103
|
+
if real_key = @abbrevs[key]
|
104
|
+
password = @data[real_key][:password]
|
102
105
|
if seconds && seconds.to_i > 0
|
103
106
|
original_clipboard_content = Clipboard.paste
|
104
107
|
Clipboard.copy password
|
105
|
-
pa %[The password for #{
|
108
|
+
pa %[The password for #{real_key} is now available in your clipboard for #{seconds.to_i} second#{?s if seconds.to_i > 1}], :green
|
106
109
|
begin
|
107
110
|
sleep seconds.to_i
|
108
111
|
rescue Interrupt
|
@@ -113,7 +116,7 @@ class PWS
|
|
113
116
|
return true
|
114
117
|
else
|
115
118
|
Clipboard.copy password
|
116
|
-
pa %[The password for #{
|
119
|
+
pa %[The password for #{real_key} has been copied to your clipboard], :green
|
117
120
|
return true
|
118
121
|
end
|
119
122
|
else
|
@@ -231,6 +234,7 @@ class PWS
|
|
231
234
|
password: @password,
|
232
235
|
format: @options[:in],
|
233
236
|
)
|
237
|
+
update_abbrevs!
|
234
238
|
else
|
235
239
|
create_safe(password)
|
236
240
|
end
|
@@ -248,6 +252,7 @@ class PWS
|
|
248
252
|
iterations: @options[:iterations],
|
249
253
|
)
|
250
254
|
File.open(@filename, 'w'){ |f| f.write(encrypted_data) }
|
255
|
+
update_abbrevs!
|
251
256
|
end
|
252
257
|
|
253
258
|
def create_safe(password = nil)
|
@@ -284,6 +289,10 @@ class PWS
|
|
284
289
|
charpool[SecureRandom.random_number(charpool_size)]
|
285
290
|
}.join
|
286
291
|
end
|
292
|
+
|
293
|
+
def update_abbrevs!
|
294
|
+
@abbrevs = @data.keys.abbrev
|
295
|
+
end
|
287
296
|
end
|
288
297
|
|
289
298
|
# Command line behavior in pws/runner.rb
|
data/lib/pws/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clipboard
|