ruby-diceware 0.0.2 → 0.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.
@@ -7,12 +7,14 @@ 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
+ option :camelcase, type: :boolean, default: false, aliases: :c, desc: 'Generate a camelCase passphrase with no spaces'
11
+ option :numbers, type: :boolean, default: false, aliases: :n, desc: 'Generate a passphrase with at least one number'
11
12
  def throw
12
13
  passphrase_options = {}.tap do |o|
13
14
  o[:words] = options['length']
14
15
  o[:wordlist] = options['wordlist']
15
16
  o[:camelcase] = options['camelcase']
17
+ o[:numbers] = options['numbers']
16
18
  end
17
19
 
18
20
  passphrase = RubyDice::Passphrase.generate passphrase_options
@@ -10,6 +10,10 @@ module RubyDice
10
10
  wordlist = Wordlist.new(wordlist_options)
11
11
  words = wordlist.random(options[:words])
12
12
 
13
+ if !words.detect { |w| w.match(/\d/) } && options[:numbers]
14
+ words[-1] += SecureRandom.random_number(100).to_s
15
+ end
16
+
13
17
  if options[:camelcase]
14
18
  words.map!(&:capitalize)
15
19
  words[0] = words[0].downcase
@@ -1,3 +1,3 @@
1
1
  module RubyDice
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -19,6 +19,14 @@ describe RubyDice::Passphrase do
19
19
  passphrase = RubyDice::Passphrase.generate(camelcase: true)
20
20
  passphrase.should eql(camel)
21
21
  end
22
+
23
+ it 'returns a passphrase with a number' do
24
+ words = %w[mary had a little lamb]
25
+ with_number = /mary had a little lamb\d+/
26
+ RubyDice::Wordlist.any_instance.stub(:random).and_return(words)
27
+ passphrase = RubyDice::Passphrase.generate(numbers: true)
28
+ passphrase.should =~ with_number
29
+ end
22
30
  end
23
31
 
24
32
  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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: -3511717855085469607
116
+ hash: -3135137275591674634
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: -3511717855085469607
125
+ hash: -3135137275591674634
126
126
  requirements: []
127
127
  rubyforge_project:
128
128
  rubygems_version: 1.8.23