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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be89ceea477e5f5e5c498ff5306aad19e6317a8b
4
- data.tar.gz: 1aaba686fc42c26228e4bbd4562e346d68a86808
3
+ metadata.gz: 39cae7e98d9aeae247f774ada51fdebbf6e09e22
4
+ data.tar.gz: ddf26702c8247fc659c6c7a77fe1b220d63692ba
5
5
  SHA512:
6
- metadata.gz: 3ec3a319a7e009e8ef822abdbb40b7c162d0278770af14a89ab2db93d0da2a71d8560c67a41c20487ef9400680bf1c2b8da3fdb1cf75dd07924afea803ca76c7
7
- data.tar.gz: 19e2fda87d29a6c67f8d6a1f39437a3fb9826709848d671b955d89e7ce0839e7df780f01ab1ea6614c5143091983482a1ac494c0a7fc7c424cbbeaedf2035c60
6
+ metadata.gz: 5a0bbcbe08c9f8ec9d567a01cc48af0e34c86519565a0347e6f66524de4f6d2c2d9066a895586187c9291074cd121ec0ee0083de96f599c668c92a9799aad3fb
7
+ data.tar.gz: 05411bf9b0f79c32ac732b03c48558a0c58275acc4259daf033822e6be027945506046da78641fdcbb4f8d0b64c876a0f25fd2c1f53f4abf1e13430ab84a0145
@@ -1,3 +1,7 @@
1
+ ### Humanizer 2.6.4 (2017-07-07)
2
+
3
+ * Prevents NoMethodError when form posts non-existing question id
4
+
1
5
  ### Humanizer 2.6.3 (2016-09-07)
2
6
 
3
7
  * Added translations: Danish, Serbian & Swedish
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "2.6.3"
2
+ VERSION = "2.6.4"
3
3
  end
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.3
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: 2016-09-06 00:00:00.000000000 Z
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: 2.14.0
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: 2.14.0
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.4.5.1
127
+ rubygems_version: 2.6.8
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: A really simple captcha solution