battery-staple 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ class DictionaryReader
2
+ def self.read
3
+ words = File.readlines("#{File.dirname(__FILE__)}/dictionary.txt").reject do |line|
4
+ line.strip.size < 4 || uppercase?(line)
5
+ end
6
+ words.map { |word| word.strip }
7
+ end
8
+
9
+ def self.uppercase?(word)
10
+ word[0].downcase != word[0]
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require 'randomizer'
2
+ require 'dictionary_reader'
3
+
4
+ class RandomPassword
5
+
6
+ def initialize(randomizer = Randomizer.new)
7
+ @randomizer = randomizer
8
+ end
9
+
10
+ def generate(dictionary, num_words=1)
11
+ password = []
12
+ num_words.times do
13
+ key = @randomizer.random(dictionary.length)
14
+ password << dictionary[key]
15
+ end
16
+ password.join(" ")
17
+ end
18
+
19
+ def self.generate(num_words)
20
+ dictionary = DictionaryReader.read
21
+ RandomPassword.new.generate(dictionary, num_words)
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ class Randomizer
2
+
3
+ def random(ceiling)
4
+ Kernel.rand(ceiling)
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: battery-staple
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Jim Suchy
9
+ - Kevin Liddle
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-12-18 00:00:00 Z
15
+ dependencies: []
16
+
17
+ description: Password generator, based on http://xkcd.com/936/
18
+ email: kevin@8thlight.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - lib/dictionary.txt
27
+ - lib/dictionary_reader.rb
28
+ - lib/random_password.rb
29
+ - lib/randomizer.rb
30
+ homepage: https://github.com/KevinLiddle/battery-staple
31
+ licenses: []
32
+
33
+ post_install_message:
34
+ rdoc_options: []
35
+
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.8
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: correct horse battery staple
57
+ test_files: []
58
+