ruby-diceware 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/ruby-dice/cli.rb +2 -0
- data/lib/ruby-dice/passphrase.rb +11 -1
- data/lib/ruby-dice/version.rb +1 -1
- data/spec/ruby-dice_spec.rb +8 -0
- metadata +4 -4
data/README.md
CHANGED
data/lib/ruby-dice/cli.rb
CHANGED
@@ -7,10 +7,12 @@ module RubyDice
|
|
7
7
|
option :length, type: :numeric, default: 5, aliases: :l, desc: 'Amount of words to use'
|
8
8
|
option :print, type: :boolean, default: false, aliases: :p, desc: 'Output passphrase to terminal'
|
9
9
|
option :wordlist, type: :string, default: nil, aliases: :w, desc: 'Use a custom wordlist file', banner: 'filename'
|
10
|
+
option :camelcase, type: :boolean, default: false, aliases: :c, desc: 'Generate a camelCase password with no spaces'
|
10
11
|
def throw
|
11
12
|
passphrase_options = {}.tap do |o|
|
12
13
|
o[:words] = options['length']
|
13
14
|
o[:wordlist] = options['wordlist']
|
15
|
+
o[:camelcase] = options['camelcase']
|
14
16
|
end
|
15
17
|
|
16
18
|
passphrase = RubyDice::Passphrase.generate passphrase_options
|
data/lib/ruby-dice/passphrase.rb
CHANGED
@@ -8,7 +8,17 @@ module RubyDice
|
|
8
8
|
wordlist_options[:wordlist] = options.delete(:wordlist)
|
9
9
|
|
10
10
|
wordlist = Wordlist.new(wordlist_options)
|
11
|
-
wordlist.random(options[:words])
|
11
|
+
words = wordlist.random(options[:words])
|
12
|
+
|
13
|
+
if options[:camelcase]
|
14
|
+
words.map!(&:capitalize)
|
15
|
+
words[0] = words[0].downcase
|
16
|
+
phrase = words.join
|
17
|
+
else
|
18
|
+
phrase = words.join(' ')
|
19
|
+
end
|
20
|
+
|
21
|
+
phrase
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
data/lib/ruby-dice/version.rb
CHANGED
data/spec/ruby-dice_spec.rb
CHANGED
@@ -11,6 +11,14 @@ describe RubyDice::Passphrase do
|
|
11
11
|
passphrase = RubyDice::Passphrase.generate(wordlist: file)
|
12
12
|
passphrase.split(' ').size.should eql(5)
|
13
13
|
end
|
14
|
+
|
15
|
+
it 'returns a camel cased passphrase' do
|
16
|
+
words = %w[mary had a little lamb]
|
17
|
+
camel = 'maryHadALittleLamb'
|
18
|
+
RubyDice::Wordlist.any_instance.stub(:random).and_return(words)
|
19
|
+
passphrase = RubyDice::Passphrase.generate(camelcase: true)
|
20
|
+
passphrase.should eql(camel)
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
describe RubyDice::Wordlist do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-diceware
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
segments:
|
115
115
|
- 0
|
116
|
-
hash:
|
116
|
+
hash: -3511717855085469607
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash:
|
125
|
+
hash: -3511717855085469607
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
128
|
rubygems_version: 1.8.23
|