pwm 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,5 +2,3 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- .rvmrc
6
- .rbenv-version
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p327@pwm"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.16.20 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,12 @@
1
+ # Contribution guidelines for pwm
2
+
3
+ pwm is intended to be small, simple, fast, and easy to understand. All
4
+ contributions must maintain these four qualities. If your pull request
5
+ is large, complicated, makes pwm slow, or is impossible to understand, I
6
+ will reject it.
7
+
8
+ pwm is in the public domain. All contributions must therefore also be in
9
+ the public domain. Pull requests containing copyright or license notices
10
+ will be rejected. Because pwm is in the public domain, you can fork it
11
+ and put whatever license you like on it; however, the canonical pwm code
12
+ base is in the public domain and will remain so.
data/README.md CHANGED
@@ -8,12 +8,16 @@ O, all lower-case letters except l, and the digits 2 through 9. 0 and O
8
8
  are not used to avoid confusion with each other. I, l, and 1 are not
9
9
  used for the same reason.
10
10
 
11
+ Starting with version 1.1.0, passwords are guaranteed to contain at
12
+ least one upper-case letter, one lower-case letter, and one number.
13
+
11
14
  ## Usage
12
15
 
13
16
  require 'pwm'
14
17
  Pwm.password(length)
15
18
 
16
- The default length is 16.
19
+ The default length is 16. The minimum length is 8. Specifying a length
20
+ less than 8 will raise `Pwm::TooShortException`.
17
21
 
18
22
  You can also call pwm from the command line:
19
23
 
data/lib/pwm.rb CHANGED
@@ -2,6 +2,10 @@ require "pwm/version"
2
2
 
3
3
  module Pwm
4
4
 
5
+ # Internal: The exception raised when a requested password length is
6
+ # too short.
7
+ class TooShortException < Exception; end
8
+
5
9
  # Internal: The set of characters from which passwords will be assembled.
6
10
  # This could be overridden if you don't like the default.
7
11
  #
@@ -24,10 +28,10 @@ module Pwm
24
28
  # # => 'oUX4fmqr'
25
29
  #
26
30
  # Returns the generated password as a String if length >= 8,
27
- # or nil is length < 8.
31
+ # or raises exception if length < 8.
28
32
  def self.password(length = 16)
29
33
  if length < 8
30
- nil
34
+ raise Pwm::TooShortException, "Requested length #{length} is too short."
31
35
  else
32
36
  password = ''
33
37
  until (password.match(/[A-Z]/) && password.match(/[a-z]/) && password.match(/[0-9]/))
@@ -1,3 +1,3 @@
1
1
  module Pwm
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -38,7 +38,7 @@ describe Pwm do
38
38
  end
39
39
  context 'less than 8' do
40
40
  it 'does not generate a password' do
41
- Pwm.password(7).should be_nil
41
+ expect { Pwm.password(7) }.to raise_error(Pwm::TooShortException)
42
42
  end
43
43
  end
44
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
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: 2012-09-24 00:00:00.000000000 Z
12
+ date: 2012-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -53,7 +53,9 @@ extra_rdoc_files: []
53
53
  files:
54
54
  - .gemtest
55
55
  - .gitignore
56
+ - .rvmrc
56
57
  - .travis.yml
58
+ - CONTRIBUTING.md
57
59
  - Gemfile
58
60
  - README.md
59
61
  - Rakefile
@@ -74,15 +76,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
76
  - - ! '>='
75
77
  - !ruby/object:Gem::Version
76
78
  version: '0'
79
+ segments:
80
+ - 0
81
+ hash: 1750747729140527601
77
82
  required_rubygems_version: !ruby/object:Gem::Requirement
78
83
  none: false
79
84
  requirements:
80
85
  - - ! '>='
81
86
  - !ruby/object:Gem::Version
82
87
  version: '0'
88
+ segments:
89
+ - 0
90
+ hash: 1750747729140527601
83
91
  requirements: []
84
92
  rubyforge_project:
85
- rubygems_version: 1.8.23
93
+ rubygems_version: 1.8.24
86
94
  signing_key:
87
95
  specification_version: 3
88
96
  summary: A reasonably secure password maker