perch 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/haddock.rb +9 -7
- metadata +1 -1
data/lib/haddock.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A more memorable password generator. Swordfish? No, I got tired of that. I
|
2
2
|
# changed it.
|
3
3
|
module Haddock
|
4
|
-
VERSION = '0.2.
|
4
|
+
VERSION = '0.2.5'
|
5
5
|
|
6
6
|
module Password
|
7
7
|
# The minimum password legnth.
|
@@ -16,9 +16,8 @@ module Haddock
|
|
16
16
|
# Paths used to detect default words files.
|
17
17
|
PATHS = %w(/usr/share/dict/words /usr/share/words)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
ANIMALS = %w(badger horse squirrel cats beaver armadillo camel dingo fish hamster chipmunk crocodile cougar hedgehog pony shrew puma pocrupine platypus mustang sheep mongoose rabbit fox sloth stallion)
|
19
|
+
ADJECTIVES = File.dirname(__FILE__) +"/adjectives.txt"
|
20
|
+
ANIMALS = File.dirname(__FILE__) +"/animals.txt"
|
22
21
|
|
23
22
|
|
24
23
|
@@delimiters = '`~!@#$%^&*()-_=+[{]}\\|;:\'",<.>/?'
|
@@ -53,7 +52,10 @@ module Haddock
|
|
53
52
|
raise LengthError, "Invalid length" unless length.is_a? Integer
|
54
53
|
raise LengthError, "Password length is too short" if length < MINIMUM
|
55
54
|
raise LengthError, "Password length is too long" if length > MAXIMUM
|
56
|
-
|
55
|
+
if options[:animal]
|
56
|
+
@@animals = IO.readlines ANIMALS
|
57
|
+
@@adjectives = IO.readlines ADJECTIVES
|
58
|
+
end
|
57
59
|
words_limit = length * 0.75 # Ensure over-proportionate word lengths.
|
58
60
|
|
59
61
|
begin
|
@@ -94,11 +96,11 @@ module Haddock
|
|
94
96
|
|
95
97
|
private
|
96
98
|
def random_adj
|
97
|
-
|
99
|
+
@@adjectives[rand(@@adjectives.length)].chomp
|
98
100
|
end
|
99
101
|
|
100
102
|
def random_animal
|
101
|
-
|
103
|
+
@@animals[rand(@@animals.length)].chomp.capitalize
|
102
104
|
end
|
103
105
|
|
104
106
|
def random_word
|