pwned 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pwned
4
- VERSION = "1.1.0"
4
+ ##
5
+ # The current version of the +pwned+ gem.
6
+ VERSION = "1.2.0"
5
7
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
24
  spec.add_development_dependency "webmock", "~> 3.3"
25
+ spec.add_development_dependency "yard", "~> 0.9.12"
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pwned
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Nash
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-12 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.12
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.12
69
83
  description: Tools to use the Pwned Passwords API.
70
84
  email:
71
85
  - philnash@gmail.com
@@ -84,11 +98,31 @@ files:
84
98
  - Rakefile
85
99
  - bin/console
86
100
  - bin/setup
101
+ - docs/NotPwnedValidator.html
102
+ - docs/Pwned.html
103
+ - docs/Pwned/Error.html
104
+ - docs/Pwned/Password.html
105
+ - docs/Pwned/TimeoutError.html
106
+ - docs/PwnedValidator.html
107
+ - docs/_index.html
108
+ - docs/class_list.html
109
+ - docs/css/common.css
110
+ - docs/css/full_list.css
111
+ - docs/css/style.css
112
+ - docs/file.README.html
113
+ - docs/file_list.html
114
+ - docs/frames.html
115
+ - docs/index.html
116
+ - docs/js/app.js
117
+ - docs/js/full_list.js
118
+ - docs/js/jquery.js
119
+ - docs/method_list.html
120
+ - docs/top-level-namespace.html
87
121
  - lib/locale/en.yml
88
122
  - lib/pwned.rb
89
123
  - lib/pwned/error.rb
124
+ - lib/pwned/not_pwned_validator.rb
90
125
  - lib/pwned/password.rb
91
- - lib/pwned/pwned_validator.rb
92
126
  - lib/pwned/version.rb
93
127
  - pwned.gemspec
94
128
  homepage: https://github.com/philnash/pwned
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class PwnedValidator < ActiveModel::EachValidator
4
- # We do not want to break customer sign-up process when the service is down.
5
- DEFAULT_ON_ERROR = :valid
6
- DEFAULT_THRESHOLD = 0
7
-
8
- def validate_each(record, attribute, value)
9
- begin
10
- pwned_check = Pwned::Password.new(value, request_options)
11
- if pwned_check.pwned_count > threshold
12
- record.errors.add(attribute, :pwned, options.merge(count: pwned_check.pwned_count))
13
- end
14
- rescue Pwned::Error => error
15
- case on_error
16
- when :invalid
17
- record.errors.add(attribute, :pwned_error, options.merge(message: options[:error_message]))
18
- when :valid
19
- # Do nothing, consider the record valid
20
- when Proc
21
- on_error.call(record, error)
22
- else
23
- raise
24
- end
25
- end
26
- end
27
-
28
- def on_error
29
- options[:on_error] || DEFAULT_ON_ERROR
30
- end
31
-
32
- def request_options
33
- options[:request_options] || {}
34
- end
35
-
36
- def threshold
37
- threshold = options[:threshold] || DEFAULT_THRESHOLD
38
- raise TypeError, "PwnedValidator option 'threshold' must be of type Integer" unless threshold.is_a? Integer
39
- threshold
40
- end
41
- end