pwm 1.2.0 → 1.2.1
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.tailor +106 -0
- data/.travis.yml +2 -6
- data/README.md +19 -5
- data/bin/pwm +1 -1
- data/features/pwm.feature +20 -0
- data/features/step_definitions/pwm.rb +3 -0
- data/features/support/env.rb +4 -0
- data/lib/pwm.rb +5 -2
- data/lib/pwm/version.rb +1 -1
- data/pwm.gemspec +2 -2
- data/spec/pwm_spec.rb +26 -28
- metadata +38 -29
- data/.rvmrc +0 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 58c0d286216f2201a37bc78782c5763a1695daee
|
4
|
+
data.tar.gz: 6ff21248e08dbed3d06db1ab01fb2df19be4ca01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb1a4fefbd355ced7e2a05b820c2b4ee1ad91b4a30538bce05805b85bfda887ae270c6705ef9c33fea3ffe6475840fa83658d86c3c55cc67597f15fb7e37b35e
|
7
|
+
data.tar.gz: 4e9af9353c9c751c1f58755986eb90634c3f6bf4f13a7608678aacbc3a5005d757fdc7f4db442fc726a3c363b32c2ee79e6224534010cdc8273ca335eb1df1e3
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/.tailor
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
#------------------------------------------------------------------------------
|
2
|
+
# Horizontal Whitespace
|
3
|
+
#------------------------------------------------------------------------------
|
4
|
+
# allow_hard_tabs True to let hard tabs be considered a single space.
|
5
|
+
# Default: false
|
6
|
+
#
|
7
|
+
# allow_trailing_line_spaces
|
8
|
+
# True to skip detecting extra spaces at the ends of
|
9
|
+
# lines.
|
10
|
+
# Default: false
|
11
|
+
#
|
12
|
+
# indentation_spaces The number of spaces to consider a proper indent.
|
13
|
+
# Default: 2
|
14
|
+
#
|
15
|
+
# max_line_length The maximum number of characters in a line before
|
16
|
+
# tailor complains.
|
17
|
+
# Default: 80
|
18
|
+
# spaces_after_comma Number of spaces to expect after a comma.
|
19
|
+
# Default: 1
|
20
|
+
#
|
21
|
+
# spaces_before_comma Number of spaces to expect before a comma.
|
22
|
+
# Default: 0
|
23
|
+
#
|
24
|
+
# spaces_after_lbrace The number of spaces to expect after an lbrace ('{').
|
25
|
+
# Default: 1
|
26
|
+
#
|
27
|
+
# spaces_before_lbrace The number of spaces to expect before an lbrace ('{').
|
28
|
+
# Default: 1
|
29
|
+
#
|
30
|
+
# spaces_before_rbrace The number of spaces to expect before an rbrace ('}').
|
31
|
+
# Default: 1
|
32
|
+
#
|
33
|
+
# spaces_in_empty_braces The number of spaces to expect between braces when
|
34
|
+
# there's nothing in the braces (i.e. {}).
|
35
|
+
# Default: 0
|
36
|
+
#
|
37
|
+
# spaces_after_lbracket The number of spaces to expect after an
|
38
|
+
# lbracket ('[').
|
39
|
+
# Default: 0
|
40
|
+
#
|
41
|
+
# spaces_before_rbracket The number of spaces to expect before an
|
42
|
+
# rbracket (']').
|
43
|
+
# Default: 0
|
44
|
+
#
|
45
|
+
# spaces_after_lparen The number of spaces to expect after an
|
46
|
+
# lparen ('(').
|
47
|
+
# Default: 0
|
48
|
+
#
|
49
|
+
# spaces_before_rparen The number of spaces to expect before an
|
50
|
+
# rbracket (')').
|
51
|
+
# Default: 0
|
52
|
+
#
|
53
|
+
#------------------------------------------------------------------------------
|
54
|
+
# Naming
|
55
|
+
#------------------------------------------------------------------------------
|
56
|
+
# allow_camel_case_methods
|
57
|
+
# Setting to true skips detection of camel-case method
|
58
|
+
# names (i.e. def myMethod).
|
59
|
+
# Default: false
|
60
|
+
#
|
61
|
+
# allow_screaming_snake_case_classes
|
62
|
+
# Setting to true skips detection of screaming
|
63
|
+
# snake-case class names (i.e. My_Class).
|
64
|
+
# Default: false
|
65
|
+
#
|
66
|
+
#------------------------------------------------------------------------------
|
67
|
+
# Vertical Whitespace
|
68
|
+
#------------------------------------------------------------------------------
|
69
|
+
# max_code_lines_in_class The number of lines of code in a class to allow before
|
70
|
+
# tailor will warn you.
|
71
|
+
# Default: 300
|
72
|
+
#
|
73
|
+
# max_code_lines_in_method
|
74
|
+
# The number of lines of code in a method to allow
|
75
|
+
# before tailor will warn you.
|
76
|
+
# Default: 30
|
77
|
+
#
|
78
|
+
# trailing_newlines The number of newlines that should be at the end of
|
79
|
+
# the file.
|
80
|
+
# Default: 1
|
81
|
+
#
|
82
|
+
Tailor.config do |config|
|
83
|
+
config.formatters "text"
|
84
|
+
config.file_set 'lib/**/*.rb' do |style|
|
85
|
+
style.allow_camel_case_methods false, level: :error
|
86
|
+
style.allow_hard_tabs false, level: :error
|
87
|
+
style.allow_screaming_snake_case_classes false, level: :error
|
88
|
+
style.allow_trailing_line_spaces false, level: :error
|
89
|
+
style.allow_invalid_ruby false, level: :warn
|
90
|
+
style.indentation_spaces 2, level: :off
|
91
|
+
style.max_code_lines_in_class 300, level: :error
|
92
|
+
style.max_code_lines_in_method 30, level: :error
|
93
|
+
style.max_line_length 80, level: :error
|
94
|
+
style.spaces_after_comma 1, level: :error
|
95
|
+
style.spaces_after_lbrace 1, level: :error
|
96
|
+
style.spaces_after_lbracket 0, level: :error
|
97
|
+
style.spaces_after_lparen 0, level: :error
|
98
|
+
style.spaces_before_comma 0, level: :error
|
99
|
+
style.spaces_before_lbrace 1, level: :error
|
100
|
+
style.spaces_before_rbrace 1, level: :error
|
101
|
+
style.spaces_before_rbracket 0, level: :error
|
102
|
+
style.spaces_before_rparen 0, level: :error
|
103
|
+
style.spaces_in_empty_braces 0, level: :error
|
104
|
+
style.trailing_newlines 1, level: :error
|
105
|
+
end
|
106
|
+
end
|
data/.travis.yml
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.8.7
|
4
|
-
- 1.9.2
|
5
3
|
- 1.9.3
|
6
|
-
-
|
7
|
-
-
|
8
|
-
- rbx-18mode
|
9
|
-
- rbx-19mode
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.0
|
10
6
|
# uncomment this line if your project needs to run something other than `rake`:
|
11
7
|
# script: bundle exec rspec spec
|
data/README.md
CHANGED
@@ -13,20 +13,34 @@ least one upper-case letter, one lower-case letter, and one number.
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
```ruby
|
17
|
+
require 'pwm'
|
18
|
+
Pwm.password(length)
|
19
|
+
```
|
18
20
|
|
19
21
|
The default length is 16. The minimum length is 8. Specifying a length
|
20
22
|
less than 8 will raise `Pwm::TooShortException`.
|
21
23
|
|
22
24
|
You can also call pwm from the command line:
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
```bash
|
27
|
+
$ pwm
|
28
|
+
h6ECtbDZPnRddHV7
|
29
|
+
$ echo $?
|
30
|
+
0
|
31
|
+
$ pwm 8
|
32
|
+
XdWod8f8
|
33
|
+
$ echo $?
|
34
|
+
0
|
35
|
+
$ pwm 4
|
36
|
+
length must be >= 8
|
37
|
+
$ echo $?
|
38
|
+
1
|
39
|
+
```
|
26
40
|
|
27
41
|
## Author
|
28
42
|
|
29
|
-
Mark Cornick <mark@
|
43
|
+
Mark Cornick <mark@cornick.io>
|
30
44
|
|
31
45
|
## (Lack of) Copyright
|
32
46
|
|
data/bin/pwm
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
Feature: Pwm
|
2
|
+
|
3
|
+
In order to generate random passwords
|
4
|
+
As a person needing random passwords
|
5
|
+
I want to use the pwm command-line tool
|
6
|
+
|
7
|
+
Scenario: Generating a password of the default length
|
8
|
+
When I run `pwm`
|
9
|
+
Then the password should be 16 characters long
|
10
|
+
And the exit status should be 0
|
11
|
+
|
12
|
+
Scenario: Generating a password of a valid specific length
|
13
|
+
When I run `pwm 8`
|
14
|
+
Then the password should be 8 characters long
|
15
|
+
And the exit status should be 0
|
16
|
+
|
17
|
+
Scenario: Generating a password of an invalid specific length
|
18
|
+
When I run `pwm 4`
|
19
|
+
Then the output should contain "length must be >= 8"
|
20
|
+
And the exit status should be 1
|
data/lib/pwm.rb
CHANGED
@@ -31,10 +31,13 @@ module Pwm
|
|
31
31
|
# or raises exception if length < 8.
|
32
32
|
def self.password(length = 16)
|
33
33
|
if length < 8
|
34
|
-
raise Pwm::TooShortException,
|
34
|
+
raise Pwm::TooShortException,
|
35
|
+
"Requested length #{length} is too short."
|
35
36
|
else
|
36
37
|
password = ''
|
37
|
-
until (password.match(/[A-Z]/) &&
|
38
|
+
until (password.match(/[A-Z]/) &&
|
39
|
+
password.match(/[a-z]/) &&
|
40
|
+
password.match(/[0-9]/))
|
38
41
|
password = (0..length - 1).inject('') do |pw, n|
|
39
42
|
pw + characters[rand(characters.length)]
|
40
43
|
end
|
data/lib/pwm/version.rb
CHANGED
data/pwm.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
# specify any dependencies here; for example:
|
20
|
+
s.add_development_dependency "aruba"
|
20
21
|
s.add_development_dependency "rake"
|
21
|
-
s.add_development_dependency "rspec"
|
22
|
-
# s.add_runtime_dependency "rest-client"
|
22
|
+
s.add_development_dependency "rspec", "~> 2.14.0"
|
23
23
|
end
|
data/spec/pwm_spec.rb
CHANGED
@@ -1,62 +1,60 @@
|
|
1
1
|
require 'pwm'
|
2
2
|
|
3
3
|
describe Pwm do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Pwm.characters.
|
4
|
+
describe 'The default set of characters' do
|
5
|
+
(('A'..'Z').to_a - ['I', 'O']).each do |letter|
|
6
|
+
it "includes #{letter}" do
|
7
|
+
expect(Pwm.characters).to include(letter)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
11
|
-
|
12
|
-
Pwm.characters.
|
10
|
+
(('a'..'z').to_a - ['l']).each do |letter|
|
11
|
+
it "includes #{letter}" do
|
12
|
+
expect(Pwm.characters).to include(letter)
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
|
-
|
17
|
-
Pwm.characters.
|
15
|
+
('2'..'9').each do |letter|
|
16
|
+
it "includes #{letter}" do
|
17
|
+
expect(Pwm.characters).to include(letter)
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
|
22
|
-
Pwm.characters.
|
20
|
+
%w(I O l 0 1).each do |letter|
|
21
|
+
it "does not include #{letter}" do
|
22
|
+
expect(Pwm.characters).not_to include(letter)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
describe 'The password method' do
|
28
28
|
context 'when given a length' do
|
29
29
|
context 'equal to 8' do
|
30
30
|
it 'generates a password of that length' do
|
31
|
-
Pwm.password(8).length.
|
31
|
+
expect(Pwm.password(8).length).to eq(8)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
context 'greater than 8' do
|
35
35
|
it 'generates a password of that length' do
|
36
|
-
Pwm.password(9).length.
|
36
|
+
expect(Pwm.password(9).length).to eq(9)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
context 'less than 8' do
|
40
|
-
it '
|
40
|
+
it 'raises Pwm::TooShortException' do
|
41
41
|
expect { Pwm.password(7) }.to raise_error(Pwm::TooShortException)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
45
|
context 'when not given a length' do
|
46
46
|
it 'generates a 16-character password' do
|
47
|
-
Pwm.password.length.
|
47
|
+
expect(Pwm.password.length).to eq(16)
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
Pwm.password.should match(/[2-9]/)
|
59
|
-
end
|
50
|
+
it 'generates passwords containing at least one upper-case letter' do
|
51
|
+
expect(Pwm.password).to match(/[A-Z]/)
|
52
|
+
end
|
53
|
+
it 'generates passwords containing at least one lower-case letter' do
|
54
|
+
expect(Pwm.password).to match(/[a-z]/)
|
55
|
+
end
|
56
|
+
it 'generates passwords containing at least one number' do
|
57
|
+
expect(Pwm.password).to match(/[2-9]/)
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
metadata
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mark Cornick
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: aruba
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '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: 2.14.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.0
|
46
55
|
description: A tiny class and command-line tool to generate reasonably secure passwords.
|
47
56
|
email:
|
48
57
|
- mark@markcornick.com
|
@@ -51,48 +60,48 @@ executables:
|
|
51
60
|
extensions: []
|
52
61
|
extra_rdoc_files: []
|
53
62
|
files:
|
54
|
-
- .gemtest
|
55
|
-
- .gitignore
|
56
|
-
- .
|
57
|
-
- .
|
63
|
+
- ".gemtest"
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".tailor"
|
67
|
+
- ".travis.yml"
|
58
68
|
- CONTRIBUTING.md
|
59
69
|
- Gemfile
|
60
70
|
- README.md
|
61
71
|
- Rakefile
|
62
72
|
- bin/pwm
|
73
|
+
- features/pwm.feature
|
74
|
+
- features/step_definitions/pwm.rb
|
75
|
+
- features/support/env.rb
|
63
76
|
- lib/pwm.rb
|
64
77
|
- lib/pwm/version.rb
|
65
78
|
- pwm.gemspec
|
66
79
|
- spec/pwm_spec.rb
|
67
80
|
homepage: https://github.com/markcornick/pwm
|
68
81
|
licenses: []
|
82
|
+
metadata: {}
|
69
83
|
post_install_message:
|
70
84
|
rdoc_options: []
|
71
85
|
require_paths:
|
72
86
|
- lib
|
73
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
88
|
requirements:
|
76
|
-
- -
|
89
|
+
- - ">="
|
77
90
|
- !ruby/object:Gem::Version
|
78
91
|
version: '0'
|
79
|
-
segments:
|
80
|
-
- 0
|
81
|
-
hash: 1750747729140527601
|
82
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
93
|
requirements:
|
85
|
-
- -
|
94
|
+
- - ">="
|
86
95
|
- !ruby/object:Gem::Version
|
87
96
|
version: '0'
|
88
|
-
segments:
|
89
|
-
- 0
|
90
|
-
hash: 1750747729140527601
|
91
97
|
requirements: []
|
92
98
|
rubyforge_project:
|
93
|
-
rubygems_version:
|
99
|
+
rubygems_version: 2.2.0
|
94
100
|
signing_key:
|
95
|
-
specification_version:
|
101
|
+
specification_version: 4
|
96
102
|
summary: A reasonably secure password maker
|
97
103
|
test_files:
|
104
|
+
- features/pwm.feature
|
105
|
+
- features/step_definitions/pwm.rb
|
106
|
+
- features/support/env.rb
|
98
107
|
- spec/pwm_spec.rb
|
data/.rvmrc
DELETED
@@ -1,48 +0,0 @@
|
|
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
|