word_gen 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +157 -0
- data/Rakefile +2 -0
- data/bin/word_gen +79 -0
- data/lib/word_gen/generator.rb +29 -0
- data/lib/word_gen/modes.rb +16 -0
- data/lib/word_gen/version.rb +3 -0
- data/lib/word_gen.rb +3 -0
- data/word_gen.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b1773a868a5012f81f6205f90c4710164de75f5
|
4
|
+
data.tar.gz: f5d1ffede2ace6132875c88d2991dca1310d911d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a2864707f51f0dfe4ed2aa9b0d5569a3f405c76262675de60e0d88c851c577322b5c3f589a4f60e46afc6ae87a7641a43d197f92692995be299358b2e462a37
|
7
|
+
data.tar.gz: d08cf85e7aac6db36f24caf079981ed914d21ff8f713a63ad42c2ac81697e8e337809eb8c97fcff6808d0682f14268211dcbe851b5b1253b0eb17925877a743e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Stefan Schmidt
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# WordGen
|
2
|
+
|
3
|
+
A simple word generator written in Ruby. It generates all possible combinations
|
4
|
+
of characters in the given length. It comes with different character sets to choose from.
|
5
|
+
You can use `word_gen -l` to get a list of all available sets.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'word_gen'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install word_gen
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
word_gen -h
|
27
|
+
Usage: word_gen [options]
|
28
|
+
-w, --world-length WORD_LENGTH The length of the word
|
29
|
+
-s, --set SET Available charachter sets
|
30
|
+
(NUMERIC,LOWER,UPPER,COMMON_SYBBOLS,
|
31
|
+
ALL_SYMBOLS,L_ALPHA_NUMERIC,U_ALPHA_NUMERIC,
|
32
|
+
LCS_ALPHA_NUMERIC,UCS_ALPHA_NUMERIC,
|
33
|
+
LS_ALPHA_NUMERIC,US_ALPHA_NUMERIC,
|
34
|
+
LU_COMMON_SYMBOLS,LOWER_UPPER_NUMERIC,ALL)
|
35
|
+
-o, --output-file OUTPUT_FILE Output file name
|
36
|
+
-h, --help Prints this help
|
37
|
+
-l, --list-sets Lists available character sets
|
38
|
+
```
|
39
|
+
|
40
|
+
## Examples
|
41
|
+
|
42
|
+
```
|
43
|
+
word_gen -w 3 -s NUMERIC
|
44
|
+
11
|
45
|
+
12
|
46
|
+
13
|
47
|
+
14
|
48
|
+
15
|
49
|
+
16
|
50
|
+
17
|
51
|
+
18
|
52
|
+
19
|
53
|
+
10
|
54
|
+
21
|
55
|
+
22
|
56
|
+
23
|
57
|
+
24
|
58
|
+
25
|
59
|
+
26
|
60
|
+
27
|
61
|
+
28
|
62
|
+
29
|
63
|
+
20
|
64
|
+
31
|
65
|
+
32
|
66
|
+
33
|
67
|
+
34
|
68
|
+
35
|
69
|
+
36
|
70
|
+
37
|
71
|
+
38
|
72
|
+
39
|
73
|
+
30
|
74
|
+
41
|
75
|
+
42
|
76
|
+
43
|
77
|
+
44
|
78
|
+
45
|
79
|
+
46
|
80
|
+
47
|
81
|
+
48
|
82
|
+
49
|
83
|
+
40
|
84
|
+
51
|
85
|
+
52
|
86
|
+
53
|
87
|
+
54
|
88
|
+
55
|
89
|
+
56
|
90
|
+
57
|
91
|
+
58
|
92
|
+
59
|
93
|
+
50
|
94
|
+
61
|
95
|
+
62
|
96
|
+
63
|
97
|
+
64
|
98
|
+
65
|
99
|
+
66
|
100
|
+
67
|
101
|
+
68
|
102
|
+
69
|
103
|
+
60
|
104
|
+
71
|
105
|
+
72
|
106
|
+
73
|
107
|
+
74
|
108
|
+
75
|
109
|
+
76
|
110
|
+
77
|
111
|
+
78
|
112
|
+
79
|
113
|
+
70
|
114
|
+
81
|
115
|
+
82
|
116
|
+
83
|
117
|
+
84
|
118
|
+
85
|
119
|
+
86
|
120
|
+
87
|
121
|
+
88
|
122
|
+
89
|
123
|
+
80
|
124
|
+
91
|
125
|
+
92
|
126
|
+
93
|
127
|
+
94
|
128
|
+
95
|
129
|
+
96
|
130
|
+
97
|
131
|
+
98
|
132
|
+
99
|
133
|
+
90
|
134
|
+
01
|
135
|
+
02
|
136
|
+
03
|
137
|
+
04
|
138
|
+
05
|
139
|
+
06
|
140
|
+
07
|
141
|
+
08
|
142
|
+
09
|
143
|
+
00
|
144
|
+
```
|
145
|
+
|
146
|
+
## Specs
|
147
|
+
|
148
|
+
TODO: write specs
|
149
|
+
|
150
|
+
|
151
|
+
## Contributing
|
152
|
+
|
153
|
+
1. Fork it ( https://github.com/[my-github-username]/word_gen/fork )
|
154
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
155
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
156
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
157
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/word_gen
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'word_gen'
|
7
|
+
rescue LoadError
|
8
|
+
require 'rubygems'
|
9
|
+
require 'word_gen'
|
10
|
+
end
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.on('-w', '--word-length WORD_LENGTH', 'The length of the word') do |f|
|
16
|
+
options[:word_length] = f
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
modes = WordGen::Modes.constants.map(&:to_s)
|
21
|
+
opts.on('-s', '--set SET', modes, 'Available charachter sets', " (#{modes.join(",")})") do |f|
|
22
|
+
options[:character_set] = f
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on('-o', '--output-file OUTPUT_FILE', 'Output file name') do |f|
|
26
|
+
options[:output_file] = f
|
27
|
+
end
|
28
|
+
|
29
|
+
options[:verbose] = false
|
30
|
+
opts.on('-v', '--verbose', 'Get a verbose version of the character sets', 'Use in combination with "-vl"') do
|
31
|
+
options[:verbose] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('-l', '--list-sets', 'Lists available character sets') do
|
35
|
+
puts "Character sets:"
|
36
|
+
WordGen::Modes.constants.each do |m|
|
37
|
+
set = WordGen::Modes.class_eval m.to_s
|
38
|
+
if options[:verbose]
|
39
|
+
puts "#{m} #{'SIZE:'.rjust(30- m.size)} #{set.size} \n#{set}"
|
40
|
+
else
|
41
|
+
puts "#{m} #{'SIZE:'.rjust(30- m.size)} #{set.size}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on_tail('-h', '--help', '--usage', 'Prints this help') do
|
48
|
+
puts opts
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on_tail('-v', '--version', 'Prints the version') do
|
53
|
+
puts "word_gen version #{WordGen::VERSION}"
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
end.parse!
|
57
|
+
|
58
|
+
word_length = options[:word_length]
|
59
|
+
character_set = options[:character_set]
|
60
|
+
output_file = options[:output_file]
|
61
|
+
|
62
|
+
unless character_set && WordGen::Modes.constants.include?(character_set.to_sym)
|
63
|
+
puts 'Choose a character set with -s'
|
64
|
+
puts 'Get a list of all available character sets with -l'
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
unless word_length
|
69
|
+
puts 'Provide a word_length with -w'
|
70
|
+
exit 1
|
71
|
+
end
|
72
|
+
|
73
|
+
if output_file
|
74
|
+
File.open(output_file, "w+") do |file|
|
75
|
+
WordGen::Generator.new(word_length, WordGen::Modes.class_eval(character_set), file).start
|
76
|
+
end
|
77
|
+
else
|
78
|
+
WordGen::Generator.new(word_length, WordGen::Modes.class_eval(character_set)).start
|
79
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class WordGen::Generator
|
2
|
+
|
3
|
+
attr_reader :word_length, :character_set, :writer
|
4
|
+
|
5
|
+
def initialize word_length, character_set, writer = $stdout
|
6
|
+
@word_length, @character_set, @writer = Integer(word_length), character_set.map(&:to_s), writer
|
7
|
+
if word_length < 1
|
8
|
+
fail ArgumentError, 'word_length need to be positibe'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def start
|
13
|
+
printAllKLengthRec character_set, "", character_set.size, word_length
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def printAllKLengthRec char_set, prefix, n, k
|
19
|
+
if k == 0
|
20
|
+
writer.puts prefix
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
n.times do |i|
|
25
|
+
new_prefix = prefix + char_set[i]
|
26
|
+
printAllKLengthRec char_set, new_prefix, n, k - 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module WordGen::Modes
|
2
|
+
NUMERIC = %w{1 2 3 4 5 6 7 8 9 0}
|
3
|
+
LOWER = %w{a b c d e f g h i j k l m n o p q r s t u v w x y z}
|
4
|
+
UPPER = %w{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}
|
5
|
+
COMMON_SYBBOLS = %w{! ? $ # @}
|
6
|
+
ALL_SYMBOLS = COMMON_SYBBOLS + %w{& % ^ * ( ) { } _ - + = | . ,}
|
7
|
+
L_ALPHA_NUMERIC = LOWER + NUMERIC
|
8
|
+
U_ALPHA_NUMERIC = UPPER + NUMERIC
|
9
|
+
LCS_ALPHA_NUMERIC = LOWER + NUMERIC + COMMON_SYBBOLS
|
10
|
+
UCS_ALPHA_NUMERIC = UPPER + NUMERIC + COMMON_SYBBOLS
|
11
|
+
LS_ALPHA_NUMERIC = LOWER + NUMERIC + ALL_SYMBOLS
|
12
|
+
US_ALPHA_NUMERIC = UPPER + NUMERIC + ALL_SYMBOLS
|
13
|
+
LU_COMMON_SYMBOLS = NUMERIC + LOWER + UPPER + COMMON_SYBBOLS
|
14
|
+
LOWER_UPPER_NUMERIC = NUMERIC + LOWER + UPPER
|
15
|
+
ALL = NUMERIC + LOWER + UPPER + ALL_SYMBOLS
|
16
|
+
end
|
data/lib/word_gen.rb
ADDED
data/word_gen.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'word_gen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "word_gen"
|
8
|
+
spec.version = WordGen::VERSION
|
9
|
+
spec.authors = ["Stefan Schmidt"]
|
10
|
+
spec.email = ["schlubbi@me.com"]
|
11
|
+
spec.summary = %q{Generate WordLists}
|
12
|
+
spec.description = %q{Generate WordLists and display them on STDOUT or save them to a file.}
|
13
|
+
spec.homepage = "http://schlubbi.io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: word_gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Schmidt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Generate WordLists and display them on STDOUT or save them to a file.
|
70
|
+
email:
|
71
|
+
- schlubbi@me.com
|
72
|
+
executables:
|
73
|
+
- word_gen
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/word_gen
|
83
|
+
- lib/word_gen.rb
|
84
|
+
- lib/word_gen/generator.rb
|
85
|
+
- lib/word_gen/modes.rb
|
86
|
+
- lib/word_gen/version.rb
|
87
|
+
- word_gen.gemspec
|
88
|
+
homepage: http://schlubbi.io
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.0.3
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Generate WordLists
|
112
|
+
test_files: []
|