ppg 0.0.1.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/ppg +7 -9
- data/lib/ppg/password.rb +5 -3
- data/lib/ppg/phonemes.rb +7 -7
- data/lib/ppg/pwgen.rb +1 -1
- metadata +10 -8
- checksums.yaml +0 -7
data/bin/ppg
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- encoding: utf-8 -*-
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
require_relative '../lib/ppg'
|
6
5
|
require 'getoptlong'
|
7
6
|
|
8
7
|
DEFAULT_PASSWORD_LENGTH = 8
|
@@ -49,12 +48,12 @@ password_length = DEFAULT_PASSWORD_LENGTH
|
|
49
48
|
exit
|
50
49
|
when '--digits'
|
51
50
|
|
52
|
-
mutators[:Digits] =
|
53
|
-
|
51
|
+
mutators[:Digits] = arg.empty? ? 1 : arg.to_i,
|
52
|
+
Proc.new { Random.rand(10).to_s }
|
54
53
|
|
55
54
|
when '--upcase'
|
56
|
-
mutators[:Upcase] =
|
57
|
-
|
55
|
+
mutators[:Upcase] = arg.empty? ? 1 : arg.to_i,
|
56
|
+
Proc.new { |c| c.upcase }
|
58
57
|
|
59
58
|
when '--length'
|
60
59
|
password_length = arg.to_i
|
@@ -73,8 +72,9 @@ password_length = DEFAULT_PASSWORD_LENGTH
|
|
73
72
|
end
|
74
73
|
|
75
74
|
pwgen = PwGen.new(password_length)
|
75
|
+
|
76
76
|
mutators.each { |name, mutator|
|
77
|
-
puts "enabling #{name} mutator for #{mutator.
|
77
|
+
puts "enabling #{name} mutator for #{mutator.first} character(s)"
|
78
78
|
pwgen.add_mutator(*mutator)
|
79
79
|
}
|
80
80
|
|
@@ -84,6 +84,4 @@ rescue GetoptLong::MissingArgument
|
|
84
84
|
puts
|
85
85
|
print_help
|
86
86
|
exit
|
87
|
-
|
88
87
|
end
|
89
|
-
|
data/lib/ppg/password.rb
CHANGED
@@ -3,16 +3,18 @@ class Password
|
|
3
3
|
attr_reader :PASSWORD_LENGTH
|
4
4
|
|
5
5
|
def initialize (password_length, password_pattern = nil)
|
6
|
+
raise ArgumentError, "length must be > 0" if password_length <= 0
|
6
7
|
@PASSWORD_LENGTH = password_length.freeze
|
7
8
|
@password = String.new
|
8
9
|
#TODO: make password_pattern validation check method
|
9
10
|
@password_pattern ||= []
|
10
11
|
end
|
11
12
|
|
12
|
-
def length= (
|
13
|
-
|
13
|
+
def length= (password_length)
|
14
|
+
raise ArgumentError, "length must be > 0" if password_length <= 0
|
15
|
+
@PASSWORD_LENGTH = password_length.freeze
|
14
16
|
end
|
15
|
-
|
17
|
+
|
16
18
|
alias :to_s :password
|
17
19
|
|
18
20
|
end
|
data/lib/ppg/phonemes.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
$ENGLISH_PHONEMES_HASH = {
|
2
2
|
|
3
|
-
:
|
3
|
+
:vowel => [ "a","e","i","o","u" ],
|
4
4
|
|
5
|
-
:
|
5
|
+
:consonant => [ "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n",
|
6
6
|
"p", "r", "s", "t", "v", "w", "x", "y", "z" ],
|
7
7
|
|
8
|
-
:
|
8
|
+
:dipthong => {
|
9
9
|
:vowel => ["ae", "oh", "oo", "ah", "ai", "ee", "ei", "ie"],
|
10
10
|
:consonant => ["ng", "gh", "ch", "ph", "qu", "sh", "th"]
|
11
11
|
}
|
@@ -15,7 +15,7 @@ $ENGLISH_PHONEMES_HASH = {
|
|
15
15
|
$ENGLISH_DOWNCASE_REGEXP = /[a-z]/.freeze
|
16
16
|
|
17
17
|
class Phonemes
|
18
|
-
attr_reader :downcase_regexp
|
18
|
+
attr_reader :downcase_regexp, :phonemes
|
19
19
|
|
20
20
|
def initialize(
|
21
21
|
vowels = nil,
|
@@ -24,9 +24,9 @@ class Phonemes
|
|
24
24
|
downcase_regexp = $ENGLISH_DOWNCASE_REGEXP
|
25
25
|
)
|
26
26
|
|
27
|
-
@phonemes = { :vowel => vowels || $ENGLISH_PHONEMES_HASH[:
|
28
|
-
:consonant => consonants || $ENGLISH_PHONEMES_HASH[:
|
29
|
-
:dipthong => dipthongs || $ENGLISH_PHONEMES_HASH[:
|
27
|
+
@phonemes = { :vowel => vowels || $ENGLISH_PHONEMES_HASH[:vowel],
|
28
|
+
:consonant => consonants || $ENGLISH_PHONEMES_HASH[:consonant],
|
29
|
+
:dipthong => dipthongs || $ENGLISH_PHONEMES_HASH[:dipthong]
|
30
30
|
}
|
31
31
|
@downcase_regexp = downcase_regexp
|
32
32
|
end
|
data/lib/ppg/pwgen.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- enoch0x5a
|
@@ -17,33 +18,34 @@ executables:
|
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
20
|
-
- bin/ppg
|
21
|
-
- lib/ppg.rb
|
22
21
|
- lib/ppg/password.rb
|
23
22
|
- lib/ppg/phonemes.rb
|
24
23
|
- lib/ppg/pwgen.rb
|
24
|
+
- lib/ppg.rb
|
25
|
+
- bin/ppg
|
25
26
|
homepage:
|
26
27
|
licenses:
|
27
28
|
- MIT
|
28
|
-
metadata: {}
|
29
29
|
post_install_message:
|
30
30
|
rdoc_options: []
|
31
31
|
require_paths:
|
32
32
|
- lib
|
33
33
|
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
34
35
|
requirements:
|
35
|
-
- -
|
36
|
+
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '0'
|
38
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
39
41
|
requirements:
|
40
|
-
- -
|
42
|
+
- - ! '>='
|
41
43
|
- !ruby/object:Gem::Version
|
42
44
|
version: '0'
|
43
45
|
requirements: []
|
44
46
|
rubyforge_project:
|
45
|
-
rubygems_version:
|
47
|
+
rubygems_version: 1.8.23
|
46
48
|
signing_key:
|
47
|
-
specification_version:
|
49
|
+
specification_version: 3
|
48
50
|
summary: Phonetic Password Generator
|
49
51
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 8cfd70a8672f3df6fe2516af336b97f686aa3001
|
4
|
-
data.tar.gz: 82bfb856d6a3cfe78bbfcbcd70066abfd6a00d8a
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: db880f29757216f42134cb11376b231931a2bb1ada582d7dc1771bafd2c36f1d110efaccf551852b2fbb28f2ccf78457f2a4ea521209e6c7994fcf534e036819
|
7
|
-
data.tar.gz: 6fb661bc2b099fbf6b15aad50b16484f5907e21d702e2b57927863561e3aec3e7ac2b451c408bbdf67c9d2cd286e4ef4f3bd0062412cb8648c2f211802ca6cf2
|