nobspw 0.3.0 → 0.4.0

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
- SHA1:
3
- metadata.gz: 48035c919105e867a0aa76612c6dcf13708da443
4
- data.tar.gz: ab7cdfe7326b2c6bcf9e4afdf8518a17dd21bec2
2
+ SHA256:
3
+ metadata.gz: 2822386df873b457c238d992dc10557886e06852ff13d3d82ff83aa678d399d5
4
+ data.tar.gz: 514207c17b7aa170f7e037953ff48dde07c884a86fbba822277e317506d9738f
5
5
  SHA512:
6
- metadata.gz: 628ec2cae8c6ea70c2a43027e749bf6f1c3c1f1b4b825ed1e0b24a429cea18d043ee25cbef04a37b73dd49f7ee7343cf468e99a50a21e9f05ee458951f43a5ab
7
- data.tar.gz: cd3b210d94da9263eb497577d93fb93bc36d8cd45fd9e58ca0267019c646c426832ed9af2ccc001bb2a94a29e05a8aa02ac0b94c96aaf01fb4cf3aebc9bea428
6
+ metadata.gz: 3c22655a227cddafed368bf1fe64ae30825106ebf50f3c5833868a4cfec9ec077c784d2c62bc78860d6d30be0a169e0dab209920e7424e87e4ee6ad854bcdff6
7
+ data.tar.gz: ee59f029dc465da9adf867c939c96d62a03a888f54256a6c22256efc666a1bc5b54acdc20a2f9b9746af6a777c305d8eac901a6a46ea087e89468b2399af1cf5
@@ -3,4 +3,5 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.3
5
5
  - 2.4.0
6
+ - 2.5.0
6
7
  before_install: gem install bundler -v 1.14.2
data/README.md CHANGED
@@ -82,8 +82,7 @@ PasswordValidator will try to guess the correct field name for each `PasswordChe
82
82
  If you have field names different than above, you can tell `PasswordValidator` which fields to use for specific attributes:
83
83
 
84
84
  ```ruby
85
- validates :password, presence: true,
86
- password: { :name => :customer_name,
85
+ validates :password, password: { :name => :customer_name,
87
86
  :email => :electronic_address },
88
87
  if: -> { new_record? || changes[:password] }
89
88
  ```
@@ -93,6 +92,7 @@ validates :password, presence: true,
93
92
  NOBSPW currently validates for the following, in this order:
94
93
 
95
94
  ```ruby
95
+ password_empty?
96
96
  name_included_in_password?
97
97
  email_included_in_password?
98
98
  domain_included_in_password?
@@ -8,6 +8,7 @@ module NOBSPW
8
8
  attr_accessor :domain_name
9
9
  attr_accessor :blacklist
10
10
  attr_accessor :validation_methods
11
+ attr_accessor :interrupt_validation_for
11
12
 
12
13
  def initialize
13
14
  @min_password_length = 10
@@ -18,6 +19,7 @@ module NOBSPW
18
19
  @domain_name = nil
19
20
  @blacklist = nil
20
21
  @validation_methods = NOBSPW::ValidationMethods::DEFAULT_VALIDATION_METHODS
22
+ @interrupt_validation_for = NOBSPW::ValidationMethods::INTERRUPT_VALIDATION_FOR
21
23
  end
22
24
  end
23
25
  end
@@ -4,9 +4,7 @@ module NOBSPW
4
4
 
5
5
  def initialize(name: nil, username: nil, email: nil, password:)
6
6
  @name, @username, @email, @password = \
7
- name&.strip, username&.strip, email&.strip, password&.strip
8
-
9
- raise ArgumentError.new("Password was not specified.") if password.nil? || password.strip.length == 0
7
+ name&.strip, username&.strip, email&.strip, (password || '').strip
10
8
  end
11
9
 
12
10
  def strong?
@@ -30,7 +28,10 @@ module NOBSPW
30
28
  @weak_password_reasons = []
31
29
 
32
30
  NOBSPW.configuration.validation_methods.each do |method|
33
- @weak_password_reasons << method.to_s.sub(/\?$/, '').to_sym if send("#{method}")
31
+ if send("#{method}")
32
+ @weak_password_reasons << method.to_s.sub(/\?$/, '').to_sym
33
+ break if NOBSPW.configuration.interrupt_validation_for.include?(method)
34
+ end
34
35
  end
35
36
 
36
37
  @strong = @weak_password_reasons.empty?
@@ -1,6 +1,7 @@
1
1
  module NOBSPW
2
2
  module ValidationMethods
3
- DEFAULT_VALIDATION_METHODS = %i(name_included_in_password?
3
+ DEFAULT_VALIDATION_METHODS = %i(password_empty?
4
+ name_included_in_password?
4
5
  email_included_in_password?
5
6
  domain_included_in_password?
6
7
  password_too_short?
@@ -9,8 +10,14 @@ module NOBSPW
9
10
  password_not_allowed?
10
11
  password_too_common?)
11
12
 
13
+ INTERRUPT_VALIDATION_FOR = %i(password_empty?)
14
+
12
15
  private
13
16
 
17
+ def password_empty?
18
+ @password.nil? || @password.strip == ''
19
+ end
20
+
14
21
  def name_included_in_password?
15
22
  return nil unless @name
16
23
  words = remove_word_separators(@name).split(' ')
@@ -75,16 +82,16 @@ module NOBSPW
75
82
  # Helper methods
76
83
 
77
84
  def email_without_extension(email)
78
- name, domain, whatev = email.split("@", 3)
85
+ name, domain, whatev = email&.split("@", 3)
79
86
  "#{name}@#{strip_extension_from_domain(domain)}"
80
87
  end
81
88
 
82
89
  def strip_extension_from_domain(domain)
83
- domain.split(".").first
90
+ domain&.split(".")&.first
84
91
  end
85
92
 
86
93
  def remove_word_separators(str)
87
- str.gsub(/-|_|\.|\'|\"|\@/, ' ')
94
+ str&.gsub(/-|_|\.|\'|\"|\@/, ' ')
88
95
  end
89
96
 
90
97
  end
@@ -1,3 +1,3 @@
1
1
  module NOBSPW
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nobspw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Mercier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.5.2
199
+ rubygems_version: 2.7.3
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: No Bullshit Password strength checker