password_strength_validator 1.0.0 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40eb0c731f91de78bfe7f44b770137c7ab2c7c95
4
- data.tar.gz: 95ed2b573cc9dc5dce2c2772bc055ceb89165d3b
3
+ metadata.gz: 10a64ed36419b25c0f0f79deb40c75bef2b2e45a
4
+ data.tar.gz: 8eff9d69049ea664c895527e2885c67c744a5282
5
5
  SHA512:
6
- metadata.gz: 4844e6bb822b8939ad88d8fc8b32eeda131acbaecf7fdaa8750e90796c4320a613943d1b67c4df0a4065346151f9cb7e9d8ae5ea3c03ba63d59e0a893b0b4a9b
7
- data.tar.gz: 0fa0fa82cacef99298923587bf28c4f0e4476206adbe58c2127e057ebe4228c099866efcf6e0d2755218df5035e5291c6b68a8b0761409f14627af0fcb093180
6
+ metadata.gz: 06199d82e45ae4ca4bf17c96d58e3a727ba77d106a4edde8f2f40ec2fe6421ed2173017bb38ddc9b6443a15cbf258beaf6b1cfc89fb9a3a2f71ff2b91696df7b
7
+ data.tar.gz: 9d31f2f975ecde6f8e11e51efaaa14d7264e98cd68f66f1562c1edfa76a6a035fb971fb312bfb02451b1d06369d6c0f0562ee7c2c08dab10ab2517bb2a891fb4
data/README.md CHANGED
@@ -31,7 +31,7 @@ end
31
31
  - acceptable symbols:
32
32
 
33
33
  ```
34
- !"\#$%&'()*+,-./:;<=>?[\]^_`{|}~
34
+ !@"#$%&'()*+,-./:;<=>?[\]^_`{|}~
35
35
  ```
36
36
 
37
37
  - custom error message
@@ -10,12 +10,7 @@ module PasswordStrengthValidator
10
10
  number_of_symbols: 0,
11
11
  }.freeze
12
12
 
13
- SYMBOLS = [
14
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
15
- 58, 59, 60, 61, 62, 63, 64,
16
- 91, 92, 93, 94, 95, 96,
17
- 123, 124, 125, 126
18
- ].freeze
13
+ SYMBOLS = %w[!@"#$%&'()*+,-./:;<=>?[\\]^_`{|}~].first.unpack('C*').freeze
19
14
 
20
15
  class Validator
21
16
  def initialize(password, options = {})
@@ -40,11 +35,11 @@ module PasswordStrengthValidator
40
35
  end
41
36
 
42
37
  def has_enough_digits?
43
- @password.split('').find_all { |c| c.match(/[0-9]/) }.size >= @options.number_of_digits
38
+ @password.each_char.grep(/[0-9]/).size >= @options.number_of_digits
44
39
  end
45
40
 
46
41
  def has_enough_symbols?
47
- @password.split('').map { |c| c.unpack('*C') }.flatten.find_all { |cc| SYMBOLS.include?(cc) }.size >= @options.number_of_symbols
42
+ @password.each_char.map(&:ord).select { |c| SYMBOLS.include?(c) }.size >= @options.number_of_symbols
48
43
  end
49
44
  end
50
45
  end
@@ -1,3 +1,3 @@
1
1
  module PasswordStrengthValidator
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: password_strength_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIOYA, Hiromu