altpass 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +66 -0
  2. data/bin/altpass.rb +30 -0
  3. data/lib/altpass/version.rb +1 -1
  4. metadata +2 -2
data/README.md CHANGED
@@ -106,6 +106,7 @@ Options
106
106
  -------
107
107
 
108
108
  Usage: altpass.rb [options]
109
+ -c Create default configuration file /Users/abatko/.altpass.yaml
109
110
  -l, --length [INTEGER>0] Password length
110
111
  -m, --memorizable [true|false] Use the memorizable pattern or not
111
112
  -p, --permutations [vvv] Show permutation size; verbosity increases with v's
@@ -166,6 +167,71 @@ These examples assume the above mentioned *Configuration* section is in effect.
166
167
  31,752,000 permutations
167
168
  --length 8 --memorizable true
168
169
 
170
+ ### Create a configuration file
171
+
172
+ Use the convenience of the `-c` switch to create a default configuration file:
173
+
174
+ $ altpass.rb -c
175
+ Created configuration file /Users/abatko/.altpass.yaml
176
+
177
+ $ altpass.rb
178
+ yZH3jw9r
179
+
180
+ Note that once a configuration file exists, the `-c` option changes to *show* its content:
181
+
182
+ $ altpass.rb -h
183
+ Usage: altpass.rb [options]
184
+ -c Show default configuration file /Users/abatko/.altpass.yaml
185
+ ... ...
186
+ ... ...
187
+ ... ...
188
+
189
+ $ altpass.rb -c
190
+ Your altpass configuration file is /Users/abatko/.altpass.yaml
191
+ :length: 8
192
+ :memorizable: true
193
+ :permutations: false
194
+ :switches: false
195
+
196
+ Let's remove the configuration file, and create another one with custom settings:
197
+
198
+ $ rm ~/.altpass.yaml
199
+ remove /Users/abatko/.altpass.yaml? y
200
+
201
+ $ altpass.rb -c -l20 -mf
202
+ Created configuration file /Users/abatko/.altpass.yaml
203
+
204
+ $ altpass.rb -c
205
+ Your altpass configuration file is /Users/abatko/.altpass.yaml
206
+ :length: 20
207
+ :memorizable: false
208
+ :permutations: false
209
+ :switches: false
210
+
211
+ $ altpass.rb
212
+ mgYzNWjdy2JEMZ9emDy5
213
+
214
+ ### Recommended configuration and usage
215
+
216
+ If you create accounts frequently, and like to have unique passwords that are
217
+ as long as the service you are signing up for allows, then consider this
218
+ default: length 20, non-memoriable.
219
+
220
+ Create your configuration file as follows:
221
+
222
+ $ altpass.rb -c -l20 -mf
223
+
224
+ and simply override it at the command-line on a per-need basis (for instance,
225
+ when the service has a shorter maximum):
226
+
227
+ $ altpass.rb -l16
228
+
229
+ Note that some services don't specify a maximum, yet they actually have one. In
230
+ such cases, you may create your account with a password that will ultimately not
231
+ let you log in, and you will have to use their "forgot/reset password" feature
232
+ (consider also contacting that service and asking them to post the password
233
+ length limit on their sign-up page).
234
+
169
235
  Contributing
170
236
  ============
171
237
 
@@ -20,6 +20,10 @@ options = options.merge(yaml_defaults) unless yaml_defaults.nil?
20
20
  OptionParser.new do |opts|
21
21
  opts.banner = 'Usage: altpass.rb [options]'
22
22
 
23
+ opts.on('-c', "#{File.exist?(CONFIGURATION_FILE) ? 'Show' : 'Create'} default configuration file #{CONFIGURATION_FILE}") do |l|
24
+ options[:createconfig] = true
25
+ end
26
+
23
27
  opts.on('-l', '--length [INTEGER>0]', OptionParser::DecimalInteger, 'Password length') do |l|
24
28
  unless l > 0
25
29
  puts 'argument to -l must be > 0'
@@ -63,6 +67,32 @@ def show_permutations(options)
63
67
  puts permutations.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse + ' permutations'
64
68
  end
65
69
 
70
+ if options[:createconfig]
71
+ if File.exist?(CONFIGURATION_FILE)
72
+ puts "Your altpass configuration file is #{CONFIGURATION_FILE}"
73
+ if File.readable?(CONFIGURATION_FILE)
74
+ puts File.read(CONFIGURATION_FILE)
75
+ else
76
+ puts 'But it is NOT readable!'
77
+ end
78
+ else
79
+ File.open(CONFIGURATION_FILE, 'w') { |f|
80
+ f.write(
81
+ ":length: #{options[:length]}\n" +
82
+ ":memorizable: #{options[:memorizable]}\n" +
83
+ ":permutations: #{options[:permutations]}\n" +
84
+ ":switches: #{options[:switches]}\n"
85
+ )
86
+ }
87
+ if File.exist?(CONFIGURATION_FILE)
88
+ puts "Created configuration file #{CONFIGURATION_FILE}"
89
+ else
90
+ puts 'Something went wrong; configuration file NOT created!'
91
+ end
92
+ end
93
+ exit
94
+ end
95
+
66
96
  puts Altpass.generate(:length => options[:length], :memorizable => options[:memorizable])
67
97
 
68
98
  show_permutations(options) if options[:permutations]
@@ -1,4 +1,4 @@
1
1
  module Altpass
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: altpass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-14 00:00:00.000000000Z
12
+ date: 2013-01-09 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Generate passwords derived from hand-alternating, visually unambiguous,
15
15
  alphanumeric characters. This is a Ruby gem and command-line utility. Formerly known