pwm 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58c0d286216f2201a37bc78782c5763a1695daee
4
- data.tar.gz: 6ff21248e08dbed3d06db1ab01fb2df19be4ca01
3
+ metadata.gz: 189dbb4eaa91cc5fb097644d22f10ee25d20ad9d
4
+ data.tar.gz: 36bc9792cdc0b9015616475726ffd2f6e077a9bf
5
5
  SHA512:
6
- metadata.gz: eb1a4fefbd355ced7e2a05b820c2b4ee1ad91b4a30538bce05805b85bfda887ae270c6705ef9c33fea3ffe6475840fa83658d86c3c55cc67597f15fb7e37b35e
7
- data.tar.gz: 4e9af9353c9c751c1f58755986eb90634c3f6bf4f13a7608678aacbc3a5005d757fdc7f4db442fc726a3c363b32c2ee79e6224534010cdc8273ca335eb1df1e3
6
+ metadata.gz: 260b7f490b18c101b0a5d04b8757a17df69df963cadb125c6e89bf2adeb08de8e0737bc38472752a76ae67384047b4accf243597fdd2dfd3fc01e22d9bc497db
7
+ data.tar.gz: 2f82eeadb7224e6c4b9107b88e6137df44de0a41e09d7a889bb319be6406f560ad5f84ad7cf26f047f699c0bdc6d4cfdefd02a8675d2cd87af52d02dbb9c0ada
data/.gitignore CHANGED
@@ -3,3 +3,5 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .ruby-version
6
+ vendor
7
+ coverage
@@ -0,0 +1,7 @@
1
+ AllCops:
2
+ Excludes:
3
+ - vendor/**
4
+ Documentation:
5
+ Enabled: false
6
+ Encoding:
7
+ Enabled: false
@@ -3,5 +3,4 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - 2.1.0
6
- # uncomment this line if your project needs to run something other than `rake`:
7
- # script: bundle exec rspec spec
6
+ script: bundle exec rake
data/Rakefile CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
2
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
7
+ Cucumber::Rake::Task.new(:features)
4
8
  RSpec::Core::RakeTask.new(:spec)
9
+ Rubocop::RakeTask.new
5
10
 
6
- task :default => :spec
7
- task :test => :spec
11
+ task :default => [:rubocop, :spec, :features]
@@ -4,7 +4,7 @@ Feature: Pwm
4
4
  As a person needing random passwords
5
5
  I want to use the pwm command-line tool
6
6
 
7
- Scenario: Generating a password of the default length
7
+ Scenario: Generating a password of no specific length
8
8
  When I run `pwm`
9
9
  Then the password should be 16 characters long
10
10
  And the exit status should be 0
@@ -1,3 +1,3 @@
1
- Then /^the password should be (\d+) characters long$/ do |length|
2
- expect(all_output.strip.length).to eq length.to_i
1
+ Then(/^the password should be (\d+) characters long$/) do |length|
2
+ expect(all_output.strip.length).to eq(length.to_i)
3
3
  end
data/lib/pwm.rb CHANGED
@@ -1,7 +1,6 @@
1
- require "pwm/version"
1
+ require 'pwm/version'
2
2
 
3
3
  module Pwm
4
-
5
4
  # Internal: The exception raised when a requested password length is
6
5
  # too short.
7
6
  class TooShortException < Exception; end
@@ -11,8 +10,7 @@ module Pwm
11
10
  #
12
11
  # Returns the set of characters as an Array.
13
12
  def self.characters
14
- (('A'..'Z').to_a + ('a'..'z').to_a +
15
- ('2'..'9').to_a) - ['I', 'O', 'l']
13
+ (('A'..'Z').to_a + ('a'..'z').to_a + ('2'..'9').to_a) - %w(I O l)
16
14
  end
17
15
 
18
16
  # Public: Generate a password.
@@ -30,19 +28,35 @@ module Pwm
30
28
  # Returns the generated password as a String if length >= 8,
31
29
  # or raises exception if length < 8.
32
30
  def self.password(length = 16)
33
- if length < 8
34
- raise Pwm::TooShortException,
35
- "Requested length #{length} is too short."
36
- else
37
- password = ''
38
- until (password.match(/[A-Z]/) &&
39
- password.match(/[a-z]/) &&
40
- password.match(/[0-9]/))
41
- password = (0..length - 1).inject('') do |pw, n|
42
- pw + characters[rand(characters.length)]
43
- end
31
+ fail Pwm::TooShortException, "#{length} is too short." if length < 8
32
+ password = ''
33
+ until acceptable?(password)
34
+ password = (0..length - 1).reduce('') do |pw, n|
35
+ pw + characters[rand(characters.length)]
44
36
  end
45
- password
46
37
  end
38
+ password
39
+ end
40
+
41
+ private
42
+
43
+ # Private: Checks if a password is acceptable.
44
+ #
45
+ # password - the password to check
46
+ #
47
+ # Examples
48
+ #
49
+ # Pwm.acceptable?('AaBbCc1234')
50
+ # # => true
51
+ #
52
+ # Pwm.acceptable?('ABCDEFGHIJ')
53
+ # # => false
54
+ #
55
+ # Returns true if password has at least one of each required character
56
+ # class, or false if not.
57
+ def self.acceptable?(password)
58
+ password.match(/[A-Z]/) &&
59
+ password.match(/[a-z]/) &&
60
+ password.match(/[0-9]/)
47
61
  end
48
62
  end
@@ -1,3 +1,3 @@
1
1
  module Pwm
2
- VERSION = "1.2.1"
2
+ VERSION = '1.2.2'
3
3
  end
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "pwm"
7
7
  s.version = Pwm::VERSION
8
8
  s.authors = ["Mark Cornick"]
9
- s.email = ["mark@markcornick.com"]
10
- s.homepage = "https://github.com/markcornick/pwm"
9
+ s.email = ["mark@cornick.io"]
10
+ s.homepage = "https://bitbucket.org/markcornick/pwm"
11
11
  s.summary = %q{A reasonably secure password maker}
12
12
  s.description = %q{A tiny class and command-line tool to generate reasonably secure passwords.}
13
13
 
@@ -20,4 +20,6 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency "aruba"
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "rspec", "~> 2.14.0"
23
+ s.add_development_dependency "rubocop"
24
+ s.add_development_dependency "simplecov"
23
25
  end
@@ -1,25 +1,29 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter '/vendor/'
4
+ end
1
5
  require 'pwm'
2
6
 
3
7
  describe Pwm do
4
8
  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)
9
+ (('A'..'Z').to_a - %w(I O)).each do |character|
10
+ it "includes #{character}" do
11
+ expect(Pwm.characters).to include(character)
8
12
  end
9
13
  end
10
- (('a'..'z').to_a - ['l']).each do |letter|
11
- it "includes #{letter}" do
12
- expect(Pwm.characters).to include(letter)
14
+ (('a'..'z').to_a - ['l']).each do |character|
15
+ it "includes #{character}" do
16
+ expect(Pwm.characters).to include(character)
13
17
  end
14
18
  end
15
- ('2'..'9').each do |letter|
16
- it "includes #{letter}" do
17
- expect(Pwm.characters).to include(letter)
19
+ ('2'..'9').each do |character|
20
+ it "includes #{character}" do
21
+ expect(Pwm.characters).to include(character)
18
22
  end
19
23
  end
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)
24
+ %w(I O l 0 1).each do |character|
25
+ it "does not include #{character}" do
26
+ expect(Pwm.characters).not_to include(character)
23
27
  end
24
28
  end
25
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cornick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-10 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba
@@ -52,9 +52,37 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: A tiny class and command-line tool to generate reasonably secure passwords.
56
84
  email:
57
- - mark@markcornick.com
85
+ - mark@cornick.io
58
86
  executables:
59
87
  - pwm
60
88
  extensions: []
@@ -63,7 +91,7 @@ files:
63
91
  - ".gemtest"
64
92
  - ".gitignore"
65
93
  - ".rspec"
66
- - ".tailor"
94
+ - ".rubocop.yml"
67
95
  - ".travis.yml"
68
96
  - CONTRIBUTING.md
69
97
  - Gemfile
@@ -77,7 +105,7 @@ files:
77
105
  - lib/pwm/version.rb
78
106
  - pwm.gemspec
79
107
  - spec/pwm_spec.rb
80
- homepage: https://github.com/markcornick/pwm
108
+ homepage: https://bitbucket.org/markcornick/pwm
81
109
  licenses: []
82
110
  metadata: {}
83
111
  post_install_message:
@@ -96,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
124
  version: '0'
97
125
  requirements: []
98
126
  rubyforge_project:
99
- rubygems_version: 2.2.0
127
+ rubygems_version: 2.2.2
100
128
  signing_key:
101
129
  specification_version: 4
102
130
  summary: A reasonably secure password maker
data/.tailor DELETED
@@ -1,106 +0,0 @@
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