pwrb 0.0.2 → 0.0.3

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.
@@ -2,29 +2,14 @@
2
2
  <project version="4">
3
3
  <component name="ChangeListManager">
4
4
  <list default="true" id="fb6b7e76-7e96-491a-9ada-23a63a7176ba" name="Default" comment="">
5
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/.name" />
6
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/.rakeTasks" />
7
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
8
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/pwrb/cli.rb" />
9
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/compiler.xml" />
10
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/pwrb/db.rb" />
11
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/encodings.xml" />
12
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/dictionaries/hanjianwei.xml" />
13
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
14
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
15
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/copyright/profiles_settings.xml" />
16
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" />
17
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/pwrb.iml" />
18
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/scopes/scope_settings.xml" />
19
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
20
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
5
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/pwrb/cli.rb" afterPath="$PROJECT_DIR$/lib/pwrb/cli.rb" />
21
6
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/pwrb.rb" afterPath="$PROJECT_DIR$/lib/pwrb.rb" />
22
7
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/bin/pwrb" afterPath="$PROJECT_DIR$/bin/pwrb" />
23
8
  <change type="MODIFICATION" beforePath="$PROJECT_DIR$/lib/pwrb/version.rb" afterPath="$PROJECT_DIR$/lib/pwrb/version.rb" />
24
9
  </list>
25
10
  <ignored path="pwrb.iws" />
26
11
  <ignored path=".idea/workspace.xml" />
27
- <file path="/Dummy.txt" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356154365753" ignored="false" />
12
+ <file path="/Dummy.txt" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356179562309" ignored="false" />
28
13
  <file path="/usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/openssl/bn.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356143887096" ignored="false" />
29
14
  <file path="/usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/json/common.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356143887096" ignored="false" />
30
15
  <file path="/pwrb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356177756979" ignored="false" />
@@ -33,7 +18,7 @@
33
18
  <file path="/pwrb.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356176785244" ignored="false" />
34
19
  <file path="/temp.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356164501486" ignored="false" />
35
20
  <file path="/db.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356177694742" ignored="false" />
36
- <file path="/cli.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356177846703" ignored="false" />
21
+ <file path="/cli.rb" changelist="fb6b7e76-7e96-491a-9ada-23a63a7176ba" time="1356179626534" ignored="false" />
37
22
  <option name="TRACKING_ENABLED" value="true" />
38
23
  <option name="SHOW_DIALOG" value="false" />
39
24
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -48,7 +33,6 @@
48
33
  <disable_hints />
49
34
  </component>
50
35
  <component name="DebuggerManager">
51
- <ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
52
36
  <breakpoint_any default_suspend_policy="SuspendAll" default_condition_enabled="true">
53
37
  <breakpoint>
54
38
  <option name="NOTIFY_CAUGHT" value="true" />
@@ -83,6 +67,7 @@
83
67
  <option name="LOG_MESSAGE" value="" />
84
68
  </breakpoint>
85
69
  </breakpoint_any>
70
+ <ui_properties default_suspend_policy="SuspendAll" default_condition_enabled="true" />
86
71
  <breakpoint_rules />
87
72
  <ui_properties />
88
73
  </component>
@@ -94,19 +79,19 @@
94
79
  <splitter split-orientation="horizontal" split-proportion="0.5">
95
80
  <split-first>
96
81
  <leaf>
97
- <file leaf-file-name="pwrb.rb" pinned="false" current="false" current-in-tab="false">
82
+ <file leaf-file-name="pwrb.rb" pinned="false" current="false" current-in-tab="true">
98
83
  <entry file="file://$PROJECT_DIR$/lib/pwrb.rb">
99
84
  <provider selected="true" editor-type-id="text-editor">
100
- <state line="4" column="17" selection-start="78" selection-end="78" vertical-scroll-proportion="0.0">
85
+ <state line="4" column="0" selection-start="61" selection-end="61" vertical-scroll-proportion="0.06369427">
101
86
  <folding />
102
87
  </state>
103
88
  </provider>
104
89
  </entry>
105
90
  </file>
106
- <file leaf-file-name="pwrb" pinned="false" current="false" current-in-tab="true">
91
+ <file leaf-file-name="pwrb" pinned="false" current="false" current-in-tab="false">
107
92
  <entry file="file://$PROJECT_DIR$/bin/pwrb">
108
93
  <provider selected="true" editor-type-id="text-editor">
109
- <state line="38" column="31" selection-start="921" selection-end="921" vertical-scroll-proportion="0.33262712">
94
+ <state line="5" column="0" selection-start="95" selection-end="95" vertical-scroll-proportion="0.0">
110
95
  <folding />
111
96
  </state>
112
97
  </provider>
@@ -130,15 +115,6 @@
130
115
  </provider>
131
116
  </entry>
132
117
  </file>
133
- <file leaf-file-name="pwrb.gemspec" pinned="false" current="false" current-in-tab="false">
134
- <entry file="file://$PROJECT_DIR$/pwrb.gemspec">
135
- <provider selected="true" editor-type-id="text-editor">
136
- <state line="19" column="17" selection-start="833" selection-end="833" vertical-scroll-proportion="0.0">
137
- <folding />
138
- </state>
139
- </provider>
140
- </entry>
141
- </file>
142
118
  </leaf>
143
119
  </split-first>
144
120
  <split-second>
@@ -146,16 +122,16 @@
146
122
  <file leaf-file-name="pwrb" pinned="false" current="false" current-in-tab="false">
147
123
  <entry file="file://$PROJECT_DIR$/bin/pwrb">
148
124
  <provider selected="true" editor-type-id="text-editor">
149
- <state line="72" column="26" selection-start="1860" selection-end="1860" vertical-scroll-proportion="0.0">
125
+ <state line="5" column="0" selection-start="95" selection-end="95" vertical-scroll-proportion="0.0">
150
126
  <folding />
151
127
  </state>
152
128
  </provider>
153
129
  </entry>
154
130
  </file>
155
- <file leaf-file-name="db.rb" pinned="false" current="true" current-in-tab="true">
131
+ <file leaf-file-name="db.rb" pinned="false" current="false" current-in-tab="false">
156
132
  <entry file="file://$PROJECT_DIR$/lib/pwrb/db.rb">
157
133
  <provider selected="true" editor-type-id="text-editor">
158
- <state line="20" column="7" selection-start="530" selection-end="530" vertical-scroll-proportion="0.32223415">
134
+ <state line="2" column="19" selection-start="50" selection-end="50" vertical-scroll-proportion="0.0">
159
135
  <folding />
160
136
  </state>
161
137
  </provider>
@@ -164,16 +140,16 @@
164
140
  <file leaf-file-name="cli.rb" pinned="false" current="false" current-in-tab="false">
165
141
  <entry file="file://$PROJECT_DIR$/lib/pwrb/cli.rb">
166
142
  <provider selected="true" editor-type-id="text-editor">
167
- <state line="60" column="13" selection-start="1401" selection-end="1401" vertical-scroll-proportion="0.0">
143
+ <state line="3" column="0" selection-start="67" selection-end="67" vertical-scroll-proportion="0.0">
168
144
  <folding />
169
145
  </state>
170
146
  </provider>
171
147
  </entry>
172
148
  </file>
173
- <file leaf-file-name="version.rb" pinned="false" current="false" current-in-tab="false">
149
+ <file leaf-file-name="version.rb" pinned="false" current="true" current-in-tab="true">
174
150
  <entry file="file://$PROJECT_DIR$/lib/pwrb/version.rb">
175
151
  <provider selected="true" editor-type-id="text-editor">
176
- <state line="1" column="18" selection-start="30" selection-end="30" vertical-scroll-proportion="0.0">
152
+ <state line="1" column="18" selection-start="30" selection-end="30" vertical-scroll-proportion="0.015923567">
177
153
  <folding />
178
154
  </state>
179
155
  </provider>
@@ -200,9 +176,9 @@
200
176
  <option name="changedFiles">
201
177
  <list>
202
178
  <option value="$PROJECT_DIR$/lib/pwrb/client.rb" />
203
- <option value="$PROJECT_DIR$/lib/pwrb.rb" />
204
179
  <option value="$PROJECT_DIR$/lib/pwrb/db.rb" />
205
180
  <option value="$PROJECT_DIR$/lib/pwrb/cli.rb" />
181
+ <option value="$PROJECT_DIR$/lib/pwrb.rb" />
206
182
  <option value="$PROJECT_DIR$/bin/pwrb" />
207
183
  <option value="$PROJECT_DIR$/lib/pwrb/version.rb" />
208
184
  </list>
@@ -261,6 +237,8 @@
261
237
  <sortByType />
262
238
  </navigator>
263
239
  <panes>
240
+ <pane id="PackagesPane" />
241
+ <pane id="Scope" />
264
242
  <pane id="ProjectPane">
265
243
  <subPane>
266
244
  <PATH>
@@ -327,8 +305,6 @@
327
305
  </PATH>
328
306
  </subPane>
329
307
  </pane>
330
- <pane id="PackagesPane" />
331
- <pane id="Scope" />
332
308
  </panes>
333
309
  </component>
334
310
  <component name="PropertiesComponent">
@@ -345,8 +321,8 @@
345
321
  <property name="FullScreen" value="false" />
346
322
  <property name="MemberChooser.showClasses" value="true" />
347
323
  <property name="GoToClass.includeLibraries" value="false" />
348
- <property name="options.splitter.details.proportions" value="0.2" />
349
324
  <property name="options.searchVisible" value="true" />
325
+ <property name="options.splitter.details.proportions" value="0.2" />
350
326
  </component>
351
327
  <component name="PyConsoleOptionsProvider">
352
328
  <option name="myPythonConsoleState">
@@ -518,10 +494,9 @@
518
494
  <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
519
495
  <window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
520
496
  <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
521
- <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32921812" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
522
497
  <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
523
498
  <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
524
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.11259338" sideWeight="0.6707819" order="0" side_tool="false" content_ui="combo" />
499
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.11366062" sideWeight="0.6707819" order="0" side_tool="false" content_ui="combo" />
525
500
  <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
526
501
  <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
527
502
  <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32921812" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
@@ -530,6 +505,7 @@
530
505
  <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
531
506
  <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
532
507
  <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
508
+ <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32921812" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
533
509
  <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
534
510
  <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
535
511
  </layout>
@@ -590,6 +566,27 @@
590
566
  <breakpoint-manager />
591
567
  </component>
592
568
  <component name="editorHistoryManager">
569
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/db.rb">
570
+ <provider selected="true" editor-type-id="text-editor">
571
+ <state line="20" column="7" selection-start="530" selection-end="530" vertical-scroll-proportion="0.0">
572
+ <folding />
573
+ </state>
574
+ </provider>
575
+ </entry>
576
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/cli.rb">
577
+ <provider selected="true" editor-type-id="text-editor">
578
+ <state line="60" column="13" selection-start="1401" selection-end="1401" vertical-scroll-proportion="0.0">
579
+ <folding />
580
+ </state>
581
+ </provider>
582
+ </entry>
583
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/version.rb">
584
+ <provider selected="true" editor-type-id="text-editor">
585
+ <state line="1" column="18" selection-start="30" selection-end="30" vertical-scroll-proportion="0.0">
586
+ <folding />
587
+ </state>
588
+ </provider>
589
+ </entry>
593
590
  <entry file="file://$PROJECT_DIR$/lib/pwrb.rb">
594
591
  <provider selected="true" editor-type-id="text-editor">
595
592
  <state line="174" column="9" selection-start="4682" selection-end="4682" vertical-scroll-proportion="0.0">
@@ -611,13 +608,6 @@
611
608
  </state>
612
609
  </provider>
613
610
  </entry>
614
- <entry file="file://$PROJECT_DIR$/pwrb.gemspec">
615
- <provider selected="true" editor-type-id="text-editor">
616
- <state line="19" column="17" selection-start="833" selection-end="833" vertical-scroll-proportion="0.0">
617
- <folding />
618
- </state>
619
- </provider>
620
- </entry>
621
611
  <entry file="file://$PROJECT_DIR$/lib/pwrb.rb">
622
612
  <provider selected="true" editor-type-id="text-editor">
623
613
  <state line="38" column="63" selection-start="1108" selection-end="1108" vertical-scroll-proportion="0.0">
@@ -639,13 +629,6 @@
639
629
  </state>
640
630
  </provider>
641
631
  </entry>
642
- <entry file="file://$PROJECT_DIR$/pwrb.gemspec">
643
- <provider selected="true" editor-type-id="text-editor">
644
- <state line="19" column="17" selection-start="833" selection-end="833" vertical-scroll-proportion="0.0">
645
- <folding />
646
- </state>
647
- </provider>
648
- </entry>
649
632
  <entry file="file://$PROJECT_DIR$/pwrb.iml">
650
633
  <provider selected="true" editor-type-id="text-editor">
651
634
  <state line="8" column="37" selection-start="503" selection-end="503" vertical-scroll-proportion="0.0">
@@ -660,37 +643,37 @@
660
643
  </state>
661
644
  </provider>
662
645
  </entry>
663
- <entry file="file://$PROJECT_DIR$/lib/pwrb.rb">
646
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/cli.rb">
664
647
  <provider selected="true" editor-type-id="text-editor">
665
- <state line="4" column="17" selection-start="78" selection-end="78" vertical-scroll-proportion="0.0">
648
+ <state line="3" column="0" selection-start="67" selection-end="67" vertical-scroll-proportion="0.0">
666
649
  <folding />
667
650
  </state>
668
651
  </provider>
669
652
  </entry>
670
- <entry file="file://$PROJECT_DIR$/lib/pwrb/version.rb">
653
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/db.rb">
671
654
  <provider selected="true" editor-type-id="text-editor">
672
- <state line="1" column="18" selection-start="30" selection-end="30" vertical-scroll-proportion="0.0">
655
+ <state line="2" column="19" selection-start="50" selection-end="50" vertical-scroll-proportion="0.0">
673
656
  <folding />
674
657
  </state>
675
658
  </provider>
676
659
  </entry>
677
- <entry file="file://$PROJECT_DIR$/bin/pwrb">
660
+ <entry file="file://$PROJECT_DIR$/lib/pwrb.rb">
678
661
  <provider selected="true" editor-type-id="text-editor">
679
- <state line="72" column="26" selection-start="1860" selection-end="1860" vertical-scroll-proportion="0.0">
662
+ <state line="4" column="0" selection-start="61" selection-end="61" vertical-scroll-proportion="0.06369427">
680
663
  <folding />
681
664
  </state>
682
665
  </provider>
683
666
  </entry>
684
- <entry file="file://$PROJECT_DIR$/lib/pwrb/cli.rb">
667
+ <entry file="file://$PROJECT_DIR$/bin/pwrb">
685
668
  <provider selected="true" editor-type-id="text-editor">
686
- <state line="60" column="13" selection-start="1401" selection-end="1401" vertical-scroll-proportion="0.0">
669
+ <state line="5" column="0" selection-start="95" selection-end="95" vertical-scroll-proportion="0.0">
687
670
  <folding />
688
671
  </state>
689
672
  </provider>
690
673
  </entry>
691
- <entry file="file://$PROJECT_DIR$/lib/pwrb/db.rb">
674
+ <entry file="file://$PROJECT_DIR$/lib/pwrb/version.rb">
692
675
  <provider selected="true" editor-type-id="text-editor">
693
- <state line="20" column="7" selection-start="530" selection-end="530" vertical-scroll-proportion="0.32223415">
676
+ <state line="1" column="18" selection-start="30" selection-end="30" vertical-scroll-proportion="0.015923567">
694
677
  <folding />
695
678
  </state>
696
679
  </provider>
data/bin/pwrb CHANGED
@@ -3,8 +3,8 @@
3
3
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  require 'pwrb'
6
- require 'optparse'
7
6
  require 'highline/import'
7
+ require 'optparse'
8
8
 
9
9
  begin
10
10
  options = {}
@@ -1,182 +1,4 @@
1
- require "pwrb/version"
2
- require 'pwrb/db'
1
+ require 'pwrb/version'
3
2
  require 'pwrb/cli'
3
+ require 'pwrb/db'
4
4
 
5
- require 'clipboard'
6
- require 'gpgme'
7
- require 'json'
8
- require 'highline/import'
9
- require 'tabularize'
10
- require 'securerandom'
11
-
12
- module Pwrb
13
- class PasswordDB
14
- def initialize(filename, password)
15
- @filename = filename
16
- @passwords = []
17
- @crypto = GPGME::Crypto.new
18
-
19
- # Read encrypted file
20
- if File.exist?(filename)
21
- text = @crypto.decrypt(filename, :password => password).to_s
22
- @passwords = JSON.parse(text, :symbolize_names => true)
23
- else
24
- FileUtils.mkdir_p(File.dirname(filename))
25
- save
26
- File.chmod(0600, filename)
27
- end
28
- end
29
-
30
- def save
31
- text = JSON.generate(@passwords)
32
- text.force_encoding('ASCII-8BIT')
33
- @crypto.encrypt(text, :output => File.open(@filename, 'w+'))
34
- end
35
-
36
- def to_s
37
- "<*>"
38
- end
39
-
40
- def query(user, site)
41
- @passwords.select {|p| /#{user}/i =~ p[:user] && (/#{site}/i =~ p[:site] || /#{site}/i =~ p[:url]) }
42
- end
43
-
44
- def ask_for_password(prompt, confirm=false)
45
- password = ask(prompt + ": ") { |q| q.echo = false; q.validate = /\A.+\Z/ }
46
- if confirm
47
- password_confirm = ask_for_password(prompt + " again")
48
-
49
- if password == password_confirm
50
- password
51
- else
52
- puts "Password mismatch, try again!"
53
- ask_for_password(prompt, true)
54
- end
55
- else
56
- password
57
- end
58
- end
59
-
60
- def ask_for_selection
61
- case
62
- when @selected.empty?
63
- puts "Record not exists!"
64
- nil
65
- when @selected.length == 1
66
- @selected.first
67
- else
68
- list
69
- choose = ask('Which one? ', Integer) { |q| q.in = 0..@selected.length-1 }
70
- @selected[choose]
71
- end
72
- end
73
-
74
- def ask_for_item(init={})
75
- item = init
76
-
77
- item[:user] = ask("User name? ") { |q| q.default = init[:user] || @options[:user]; q.validate = /\A\S+\Z/ }
78
- item[:email] = ask("Email? ") { |q| q.default = init[:email] }
79
- item[:site] = ask("Site? ") { |q| q.default = init[:site] || @options[:site]; q.validate = /\A.+\Z/ }
80
- item[:url] = ask("URL? ") { |q| q.default = init[:url] || @options[:site] }
81
-
82
- item
83
- end
84
-
85
- def ask_for_confirm
86
- confirm = ask("Are you sure? ") { |q| q.validate = /\A(y|yes|n|no)\Z/i }
87
- ['y', 'yes'].include?(confirm)
88
- end
89
-
90
- def timestamp
91
- Date.today.strftime("%Y%m%d")
92
- end
93
-
94
- def list
95
- return if @selected.empty?
96
-
97
- table = Tabularize.new
98
- table << %w[# ID User Password Site Date]
99
- table.separator!
100
-
101
- @selected.each_with_index do |item, index|
102
- user = item[:user]
103
- user += "<%s>" % item[:email] unless item[:email].empty?
104
- site = "%s[%s]" % [item[:site], item[:url]]
105
- password = (@options[:print] ? item[:password] : "***")
106
-
107
- table << [index.to_s, item[:id].split('-').first, user, password, site, item[:date]]
108
- end
109
-
110
- puts table
111
- end
112
-
113
- def copy
114
- target = ask_for_selection
115
- seconds = 10
116
-
117
- if target
118
- original_clipboard_content = Clipboard.paste
119
- sleep 0.1
120
- Clipboard.copy target[:password]
121
- puts "Password for #{target[:site]} is in clipboard for #{seconds} seconds"
122
- begin
123
- sleep seconds
124
- rescue Interrupt
125
- Clipboard.copy original_clipboard_content
126
- raise
127
- end
128
- Clipboard.copy original_clipboard_content
129
- end
130
- end
131
-
132
- def update
133
- target = ask_for_selection
134
-
135
- if target
136
- target[:password] = ask_for_password("Enter new password", confirm = true)
137
- target[:date] = timestamp
138
- write_safe
139
- puts "Update complete!"
140
- end
141
- end
142
-
143
-
144
- def add
145
- item = ask_for_item
146
-
147
- item[:id] = SecureRandom.uuid
148
- item[:password] = ask_for_password("Enter password", confirm = true)
149
- item[:date] = timestamp
150
-
151
- if ask_for_confirm
152
- @data << item
153
- write_safe
154
- puts "Added #{item[:user]}@#{item[:site]}!"
155
- end
156
- end
157
-
158
- def edit
159
- target = ask_for_selection
160
-
161
- if target
162
- ask_for_item(target)
163
- if ask_for_confirm
164
- target[:date] = timestamp
165
- write_safe
166
- puts "Update #{target[:user]}@#{target[:site]}!"
167
- end
168
- end
169
- end
170
-
171
- def remove
172
- target = ask_for_selection
173
-
174
- if target && ask_for_confirm
175
- @data.delete(target)
176
- write_safe
177
- puts "#{target[:user]}@#{target[:site]} Removed!"
178
- end
179
- end
180
-
181
- end
182
- end
@@ -1,5 +1,6 @@
1
- require 'highline/import'
2
1
  require 'clipboard'
2
+ require 'highline/import'
3
+ require 'tabularize'
3
4
 
4
5
  module Pwrb
5
6
  class CLI
@@ -1,3 +1,3 @@
1
1
  module Pwrb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: