humanizer 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76a1854d099e40a3d8d1f57bb85e4e1fb8c65622
4
+ data.tar.gz: 8784e987a3785596f48f1e8b1239d45678230646
5
+ SHA512:
6
+ metadata.gz: ce6705809a1dd080f1cccfce7cef69cd4160658461c19c10932ff468aaae81ac86f1beae4aa8440813a6990bd4676ecfa54fb345391f572b26faaa66f35a512a
7
+ data.tar.gz: f8b2d3c1c53f1d11db73b325b07cf2ff105c1211321b0c773e3d6f83cbf5ef0d1e3a89441f0803da0d205a0bdc6bcbb793b0d9a42aea6b8f3e5f5c5e1d6a6af0
@@ -1,3 +1,9 @@
1
+ ### Humanizer 2.6.0 (2013-11-25)
2
+
3
+ * Raise an exception of the translations are missing
4
+ * Make translation lookups work with both strings and symbols
5
+ * Improvements to the dutch translations
6
+
1
7
  ### Humanizer 2.5.0 (2013-09-10)
2
8
 
3
9
  * Added translations: Greek and zh-TW
data/README.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # Humanizer
2
2
 
3
- Humanizer is a very simple CAPTCHA method. It has a localized YAML file with questions and answers which is used to validate that the user is an actual human. Any model that includes ActiveModel::Validations should work. Our aim is to be database and mapper agnostic, so if it doesn't work for you, open an issue. Humanizer only works with Rails 3.
3
+ Humanizer is a very simple CAPTCHA method. It has a localized YAML file with questions and answers which is used to validate that the user is an actual human. Any model that includes ActiveModel::Validations should work. Our aim is to be database and mapper agnostic, so if it doesn't work for you, open an issue. Humanizer works with Rails 3 and 4.
4
4
 
5
5
  ## Installation
6
6
 
7
- 1. `gem install humanizer`
8
- 2. `rails g humanizer`
7
+ Add `humanizer` to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'humanizer'
11
+ ```
12
+
13
+ Bundle and run the generator in terminal:
14
+
15
+ ```sh
16
+ bundle
17
+ rails g humanizer
18
+ ```
9
19
 
10
20
  ## Advanced Installation
11
21
 
@@ -17,19 +27,25 @@ Humanizer is a very simple CAPTCHA method. It has a localized YAML file with que
17
27
 
18
28
  1. In your model, include Humanizer and add the #require_human_on method, example:
19
29
 
20
- class User < ActiveRecord::Base
21
- include Humanizer
22
- require_human_on :create
23
- end
30
+ ```ruby
31
+ class User < ActiveRecord::Base
32
+ include Humanizer
33
+ require_human_on :create
34
+ end
35
+ ```
24
36
 
25
37
  2. Ask the question in the form, example:
26
38
 
27
- <%= f.label :humanizer_answer, @model.humanizer_question %>
28
- <%= f.text_field :humanizer_answer %>
29
- <%= f.hidden_field :humanizer_question_id %>
39
+ ```erb
40
+ <%= f.label :humanizer_answer, @model.humanizer_question %>
41
+ <%= f.text_field :humanizer_answer %>
42
+ <%= f.hidden_field :humanizer_question_id %>
43
+ ```
30
44
 
31
45
  3. If you are using attr_accessible, remember to whitelist `:humanizer_answer` and `:humanizer_question_id`.
32
46
 
47
+ 4. If you are using strong_parameters, remember to permit `:humanizer_answer` and `:humanizer_question_id`.
48
+
33
49
  ## Configuration
34
50
 
35
51
  Default translations can be found in config/locales/
@@ -42,8 +58,10 @@ You might want to skip the humanizer validations on your tests or rails console.
42
58
 
43
59
  You can just have a simple attribute on your model and use it to bypass the validation. Here's an example:
44
60
 
45
- attr_accessor :bypass_humanizer
46
- require_human_on :create, :unless => :bypass_humanizer
61
+ ```ruby
62
+ attr_accessor :bypass_humanizer
63
+ require_human_on :create, :unless => :bypass_humanizer
64
+ ```
47
65
 
48
66
  Now when bypass_humanizer is true, validation will be skipped.
49
67
 
@@ -53,8 +71,10 @@ In case you want to give your users the option to change the question, there's a
53
71
 
54
72
  To make sure the current question doesn't get asked again, you can pass the current question id to the method. For example:
55
73
 
56
- @user.change_humanizer_question(params[:user][:humanizer_question_id])
57
-
74
+ ```ruby
75
+ @user.change_humanizer_question(params[:user][:humanizer_question_id])
76
+ ```
77
+
58
78
  ## Live sites
59
79
 
60
80
  * [ArcticStartup.com](http://arcticstartup.com/) - sign up form
@@ -13,9 +13,9 @@ nl:
13
13
  answers: ["10", "tien"]
14
14
  - question: "Vul het volgende nummer in deze rij aan: 10, 11, 12, 13, 14, .."
15
15
  answers: ["15", "vijftien"]
16
- - question: "Wat is vijf maail vijf?"
16
+ - question: "Wat is vijf maal vijf?"
17
17
  answers: ["25", "vijfentwintig"]
18
- - question: "Tein gedeeld door twee is hoeveel?"
18
+ - question: "Tien gedeeld door twee is hoeveel?"
19
19
  answers: ["5", "vijf"]
20
20
  - question: Welke dag komt er na maandag?
21
21
  answer: "dinsdag"
@@ -23,11 +23,11 @@ nl:
23
23
  answer: "december"
24
24
  - question: Hoeveel minuten zitten er in een uur?
25
25
  answers: ["60", "zestig"]
26
- - question: Wat is het omgkeerde van benden?
26
+ - question: Wat is het tegenovergestelde van beneden?
27
27
  answer: "boven"
28
- - question: Wat is het omgekeerde van zuid?
28
+ - question: Wat is het tegenovergestelde van zuid?
29
29
  answer: ["noord", "noorden"]
30
- - question: Wat is het omgekeerde van slecht?
30
+ - question: Wat is het tegenovergestelde van slecht?
31
31
  answer: "goed"
32
32
  - question: Hoeveel is 4 maal vier?
33
33
  answers: ["16", "zestien"]
@@ -26,9 +26,21 @@ module Humanizer
26
26
  end
27
27
 
28
28
  private
29
-
29
+
30
30
  def humanizer_questions
31
- @humanizer_questions ||= I18n.translate("humanizer.questions")
31
+ @humanizer_questions ||= begin
32
+ questions = I18n.translate!("humanizer.questions")
33
+ # Poor man's HashWithIndifferentAccess
34
+ questions.map do |question|
35
+ question.default_proc = proc do |h, k|
36
+ case k
37
+ when String then sym = k.to_sym; h[sym] if h.key?(sym)
38
+ when Symbol then str = k.to_s; h[str] if h.key?(str)
39
+ end
40
+ end
41
+ end
42
+ questions
43
+ end
32
44
  end
33
45
 
34
46
  def humanizer_question_ids
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "2.5.0"
2
+ VERSION = "2.6.0"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: humanizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
5
- prerelease:
4
+ version: 2.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Antti Akonniemi
@@ -10,70 +9,62 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-09-12 00:00:00.000000000 Z
12
+ date: 2013-11-25 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
46
  - - ~>
53
47
  - !ruby/object:Gem::Version
54
- version: 2.11.0
48
+ version: 2.14.0
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
53
  - - ~>
61
54
  - !ruby/object:Gem::Version
62
- version: 2.11.0
55
+ version: 2.14.0
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: activemodel
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ~>
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: 3.0.0
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ~>
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: 3.0.0
79
70
  description: reCAPTCHA was too much for us, so we created this. Simplest captcha ever.
@@ -105,27 +96,28 @@ files:
105
96
  - lib/generators/templates/locales/zh-CN.yml
106
97
  - lib/generators/templates/locales/zh-TW.yml
107
98
  homepage: http://github.com/kiskolabs/humanizer
108
- licenses: []
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
109
102
  post_install_message:
110
103
  rdoc_options: []
111
104
  require_paths:
112
105
  - lib
113
106
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
107
  requirements:
116
- - - ! '>='
108
+ - - '>='
117
109
  - !ruby/object:Gem::Version
118
110
  version: '0'
119
111
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
112
  requirements:
122
- - - ! '>='
113
+ - - '>='
123
114
  - !ruby/object:Gem::Version
124
115
  version: 1.3.6
125
116
  requirements: []
126
117
  rubyforge_project: humanizer
127
- rubygems_version: 1.8.23
118
+ rubygems_version: 2.0.6
128
119
  signing_key:
129
- specification_version: 3
120
+ specification_version: 4
130
121
  summary: A really simple captcha solution
131
122
  test_files: []
123
+ has_rdoc: