humanizer 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/humanizer.rb +14 -12
- data/lib/humanizer/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39cae7e98d9aeae247f774ada51fdebbf6e09e22
|
4
|
+
data.tar.gz: ddf26702c8247fc659c6c7a77fe1b220d63692ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a0bbcbe08c9f8ec9d567a01cc48af0e34c86519565a0347e6f66524de4f6d2c2d9066a895586187c9291074cd121ec0ee0083de96f599c668c92a9799aad3fb
|
7
|
+
data.tar.gz: 05411bf9b0f79c32ac732b03c48558a0c58275acc4259daf033822e6be027945506046da78641fdcbb4f8d0b64c876a0f25fd2c1f53f4abf1e13430ab84a0145
|
data/CHANGELOG.md
CHANGED
data/lib/humanizer.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
module Humanizer
|
2
|
-
|
2
|
+
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(ClassMethods)
|
5
5
|
end
|
6
|
-
|
6
|
+
|
7
7
|
attr_accessor :humanizer_answer
|
8
8
|
attr_writer :humanizer_question_id
|
9
9
|
|
10
10
|
def humanizer_question
|
11
11
|
humanizer_questions[humanizer_question_id.to_i]["question"]
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def humanizer_question_id
|
15
|
-
@humanizer_question_id ||= random_humanizer_question_id
|
15
|
+
(@humanizer_question_id ||= random_humanizer_question_id).to_i
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def change_humanizer_question(current=nil)
|
19
19
|
@humanizer_question_ids = nil if humanizer_question_ids.compact.count == 1
|
20
20
|
humanizer_question_ids.delete(current) if current
|
21
21
|
@humanizer_question_id = random_humanizer_question_id
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def humanizer_correct_answer?
|
25
|
-
humanizer_answer &&
|
26
|
-
humanizer_answers_for_id(humanizer_question_id).include?(humanizer_answer.mb_chars.downcase.strip)
|
25
|
+
humanizer_answer && humanizer_answers_for_id(humanizer_question_id).include?(humanizer_answer.mb_chars.downcase.strip)
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
@@ -54,20 +53,23 @@ module Humanizer
|
|
54
53
|
|
55
54
|
def humanizer_answers_for_id(id)
|
56
55
|
question = humanizer_questions[id.to_i]
|
56
|
+
|
57
|
+
return [] unless question
|
58
|
+
|
57
59
|
Array(question["answer"] || question["answers"]).map { |a| a.to_s.mb_chars.downcase }
|
58
60
|
end
|
59
61
|
|
60
62
|
def humanizer_check_answer
|
61
63
|
errors.add(:humanizer_answer, I18n.translate("humanizer.validation.error")) unless humanizer_correct_answer?
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
module ClassMethods
|
65
|
-
|
67
|
+
|
66
68
|
def require_human_on(validate_on = nil, opts = {})
|
67
69
|
opts[:on] = validate_on if validate_on
|
68
70
|
validate :humanizer_check_answer, opts
|
69
71
|
end
|
70
|
-
|
72
|
+
|
71
73
|
end
|
72
|
-
|
74
|
+
|
73
75
|
end
|
data/lib/humanizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humanizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antti Akonniemi
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -47,14 +47,14 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 3.6.0
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 3.6.0
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: activemodel
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: 1.3.6
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project: humanizer
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.6.8
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: A really simple captcha solution
|