pwm 1.0.2 → 1.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.
- data/Rakefile +1 -0
- data/lib/pwm.rb +22 -3
- data/lib/pwm/version.rb +1 -1
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/pwm.rb
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
require "pwm/version"
|
2
2
|
|
3
3
|
module Pwm
|
4
|
+
|
5
|
+
# Internal: The set of characters from which passwords will be assembled.
|
6
|
+
# This could be overridden if you don't like the default.
|
7
|
+
#
|
8
|
+
# Returns the set of characters as an Array.
|
4
9
|
def self.characters
|
5
|
-
(('A'..'Z').to_a
|
10
|
+
(('A'..'Z').to_a + ('a'..'z').to_a +
|
11
|
+
('2'..'9').to_a) - ['I', 'O', 'l']
|
6
12
|
end
|
7
13
|
|
8
|
-
|
9
|
-
|
14
|
+
# Public: Generate a password.
|
15
|
+
#
|
16
|
+
# length - The length of the password.
|
17
|
+
#
|
18
|
+
# Examples
|
19
|
+
#
|
20
|
+
# Pwm.password
|
21
|
+
# # => 'SPdHeZnn9rut4AUz'
|
22
|
+
#
|
23
|
+
# Pwm.password(8)
|
24
|
+
# # => 'oUX4fmqr'
|
25
|
+
#
|
26
|
+
# Returns the generated password as a String.
|
27
|
+
def self.password(length = 16)
|
28
|
+
(0..length - 1).inject('') do |pw, n|
|
10
29
|
pw + characters[rand(characters.length)]
|
11
30
|
end
|
12
31
|
end
|
data/lib/pwm/version.rb
CHANGED