humanizer 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Antti Akonniemi, Joao Carlos Cardoso, Kisko Labs
1
+ Copyright (c) 2010 Kisko Labs and contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,11 +1,19 @@
1
+ # Humanizer
2
+
1
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.
2
4
 
3
- ### Installation
5
+ ## Installation
6
+
7
+ 1. `gem install humanizer`
8
+ 2. `rails g humanizer`
9
+
10
+ ## Advanced Installation
4
11
 
5
- 1. gem install humanizer
6
- 2. rails g humanizer
12
+ * Install all locales: `rails g humanizer --all-locales`
13
+ * Show available locales: `rails g humanizer --show-locales`
14
+ * Install selected locales: `rails g humanizer en fi de`
7
15
 
8
- ### Usage
16
+ ## Usage
9
17
 
10
18
  1. In your model, include Humanizer and add the #require_human_on method, example:
11
19
 
@@ -20,12 +28,28 @@ Humanizer is a very simple CAPTCHA method. It has a localized YAML file with que
20
28
  <%= f.text_field :humanizer_answer %>
21
29
  <%= f.hidden_field :humanizer_question_id %>
22
30
 
23
- ### Configuration
31
+ ## Configuration
32
+
33
+ Default translations can be found in config/locales/
34
+
35
+ You might want to add/change question and answer pairs. This can be easily done by adding/modifying entries in locales file.
36
+
37
+ ## Live sites
38
+
39
+ * [ArcticStartup.com](http://arcticstartup.com/) - signup form
40
+
41
+ ## License
42
+
43
+ Humanizer is licensed under the MIT License, for more details see the LICENSE file.
24
44
 
25
- Default translations can be found from config/locales/humanizer.en.yml
45
+ ## Question/Answer Translations
26
46
 
27
- You might want to add / change question and answer pairs. This can be easily done by adding / modifying entries in locales file.
47
+ * English, Finnish and Portuguese translations by [Kisko Labs](http://kiskolabs.com/)
48
+ * German by [Sven Schwyn](http://github.com/svoop)
49
+ * Dutch by [Joren De Groof](http://github.com/joren)
50
+ * Brazilian Portuguese by [Britto](http://github.com/britto)
28
51
 
29
- ### Live sites
52
+ ## Contributors
30
53
 
31
- * [ArcticStartup.com](http://arcticstartup.com/) - signup form
54
+ * [Florian Bertholin](http://github.com/Arkan)
55
+ * [seogrady](http://github.com/seogrady)
@@ -1,7 +1,49 @@
1
1
  class HumanizerGenerator < Rails::Generators::Base
2
- LOCALE_FILE = File.join(File.dirname(__FILE__) , "templates", "en.yml")
2
+ source_root File.expand_path("../templates/locales", __FILE__)
3
+ argument :selected_locales, :type => :array, :default => ["en"], :banner => "en fi de"
4
+ desc "Adds locales for Humanizer to your Rails application.\nBy default it will only add English."
5
+ class_option :"show-locales", :desc => "Print all available locales", :type => :boolean
6
+ class_option :"all-locales", :desc => "Install all available locales", :type => :boolean
3
7
 
4
- def add_locale
5
- template LOCALE_FILE, "config/locales/humanizer.en.yml"
8
+ def add_locales
9
+ if options["show-locales"]
10
+ puts "Available locales:\n" +
11
+ " - " + available_locales.sort.join("\n - ")
12
+ else
13
+ if options["all-locales"]
14
+ install_locales(available_locales)
15
+ else
16
+ check_locales!
17
+ install_locales(selected_locales)
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def available_locales
25
+ Dir.glob(File.join(self.class.source_root, "*.yml")).map do |path|
26
+ path.match(/([\w-]+)\.yml$/)[1]
27
+ end
28
+ end
29
+
30
+ def check_locales!
31
+ unknown_locales = []
32
+ selected_locales.each do |locale|
33
+ unknown_locales << locale unless available_locales.include?(locale)
34
+ end
35
+
36
+ if unknown_locales.any?
37
+ abort "The following locales do not exist: \n" +
38
+ " - " + unknown_locales.join("\n - ") + "\n\n" +
39
+ "The available locales are: " +
40
+ available_locales.sort.join(", ")
41
+ end
42
+ end
43
+
44
+ def install_locales(locales)
45
+ locales.each do |locale|
46
+ copy_file "#{locale}.yml", "config/locales/humanizer.#{locale}.yml"
47
+ end
6
48
  end
7
49
  end
@@ -0,0 +1,43 @@
1
+ de:
2
+ humanizer:
3
+ validation:
4
+ error: "Sie sind kein Mensch"
5
+ questions:
6
+ - question: "Zwei plus zwei?"
7
+ answers: ["4", "vier"]
8
+ - question: "Alle meine Entchen, schwimmen auf dem..."
9
+ answer: see
10
+ - question: "Welche Zahl kommt vor der Zwölf?"
11
+ answers: ["11", "elf"]
12
+ - question: "Fünf mal zwei ergibt?"
13
+ answers: ["10", "zehn"]
14
+ - question: "Die nächste Zahl der Serie: 10, 11, 12, 13, 14, .."
15
+ answers: ["15", "fünfzehn"]
16
+ - question: "Wieviel ist fünf mal fünf?"
17
+ answers: ["25", "fünfundzwanzig"]
18
+ - question: "Zehn geteilt durch zwei ist?"
19
+ answers: ["5", "fünf"]
20
+ - question: "Welcher Tag folgt auf den Montag?"
21
+ answer: "dienstag"
22
+ - question: "Wie lautet der letzte Monat des Jahres?"
23
+ answer: "dezember"
24
+ - question: "Wie viele Minuten hat eine Stunde?"
25
+ answers: ["60", "sechzig"]
26
+ - question: "Was ist das Gegenteil von oben?"
27
+ answer: "unten"
28
+ - question: "Was ist das Gegenteil von Norden?"
29
+ answer: "süden"
30
+ - question: "Was ist das Gegenteil von schlecht?"
31
+ answer: "gut"
32
+ - question: "Wieviel ist 4 mal vier?"
33
+ answers: ["16", "sechzehn"]
34
+ - question: "Welche Zahl folgt auf die 20?"
35
+ answers: ["21", "einundzwanzig"]
36
+ - question: "Welcher Monat kommt vor dem Juli?"
37
+ answer: "juni"
38
+ - question: "Wieviel ist fünfzehn geteilt durch drei?"
39
+ answer: ["fünf", "5"]
40
+ - question: "Wieviel ist 14 minus 4?"
41
+ answers: ["10", "zehn"]
42
+ - question: "Was folgt als nächstes? Montag, Dienstag, Mittwoch, ..."
43
+ answer: "donnerstag"
@@ -14,7 +14,7 @@ en:
14
14
  - question: "Insert the next number in this sequence: 10, 11, 12, 13, 14, .."
15
15
  answers: ["15", "fifteen"]
16
16
  - question: "What is five times five?"
17
- answers: ["25", "twentyfive"]
17
+ answers: ["25", "twenty-five"]
18
18
  - question: "Ten divided by two is what?"
19
19
  answers: ["5", "five"]
20
20
  - question: What day comes after Monday?
@@ -32,12 +32,12 @@ en:
32
32
  - question: What is 4 times four?
33
33
  answers: ["16", "sixteen"]
34
34
  - question: What number comes after 20?
35
- answers: ["21", "twentyone"]
35
+ answers: ["21", "twenty-one"]
36
36
  - question: What month comes before July?
37
37
  answer: "june"
38
38
  - question: What is fifteen divided by three?
39
- answer: "five"
39
+ answer: ["five", "5"]
40
40
  - question: What is 14 minus 4?
41
41
  answers: ["10", "ten"]
42
42
  - question: "What comes next? Monday, Tuesday, Wednesday.."
43
- answer: "Thursday"
43
+ answer: "Thursday"
@@ -0,0 +1,43 @@
1
+ fi:
2
+ humanizer:
3
+ validation:
4
+ error: Et ole ihminen
5
+ questions:
6
+ - question: Kaksi plus kaksi?
7
+ answers: ["4", "neljä"]
8
+ - question: Loppu hyvin, kaikki...
9
+ answer: hyvin
10
+ - question: Kahtatoista edeltävä numero?
11
+ answers: ["11", "yksitoista"]
12
+ - question: Viisi kertaa kaksi on?
13
+ answers: ["10", "kymmenen"]
14
+ - question: "Seuraava numero tässä sarjassa: 10, 11, 12, 13, 14, .."
15
+ answers: ["15", "viisitoista"]
16
+ - question: "Viisi kertaa viisi on?"
17
+ answers: ["25", "kaksikymmentäviisi"]
18
+ - question: "Kymmenen jaettuna kahdella on?"
19
+ answers: ["5", "viisi"]
20
+ - question: Maanantaita seuraava päivä on?
21
+ answer: "tiistai"
22
+ - question: Mikä on vuoden viimeinen päivä?
23
+ answer: "joulukuu"
24
+ - question: Kuinka monta minuuttia on tunnissa?
25
+ answers: ["60", "kuusikymmentä"]
26
+ - question: Vastakohta sanalle 'alas'?
27
+ answer: "ylös"
28
+ - question: Pohjoisen vastakohta?
29
+ answer: "etelä"
30
+ - question: Huonon vastakohta?
31
+ answer: "hyvä"
32
+ - question: Kuinka paljon on 4 kertaa neljä?
33
+ answers: ["16", "kuusitoista"]
34
+ - question: Mikä numero tulee kahdenkymmenen jälkeen?
35
+ answers: ["21", "kaksikymmentäyksi"]
36
+ - question: Heinäkuuta edeltävä kuukausi on?
37
+ answer: "kesäkuu"
38
+ - question: Mitä on viisitoista jaettuna kolmella?
39
+ answer: ["viisi", "5"]
40
+ - question: Mitä on 14 miinus 4?
41
+ answers: ["10", "kymmenen"]
42
+ - question: "Mikä tulee seuraavaksi? Maanantai, Tiistai, Keskiviikko..."
43
+ answer: "Torstai"
@@ -0,0 +1,43 @@
1
+ nl:
2
+ humanizer:
3
+ validation:
4
+ error: U bent geen mens
5
+ questions:
6
+ - question: Twee plus twee?
7
+ answers: ["4", "vier"]
8
+ - question: "Een twee drie vier, hoedje van..."
9
+ answer: papier
10
+ - question: Wat is het nummer tussen tien en twaalf?
11
+ answers: ["11", "elf"]
12
+ - question: Vijf maal twee is hoeveel?
13
+ answers: ["10", "tien"]
14
+ - question: "Vul het volgende nummer in deze rij aan: 10, 11, 12, 13, 14, .."
15
+ answers: ["15", "vijftien"]
16
+ - question: "Wat is vijf maail vijf?"
17
+ answers: ["25", "vijfentwintig"]
18
+ - question: "Tein gedeeld door twee is hoeveel?"
19
+ answers: ["5", "vijf"]
20
+ - question: Welke dag komt er na maandag?
21
+ answer: "dinsdag"
22
+ - question: Wat is de laatste maand van het jaar?
23
+ answer: "december"
24
+ - question: Hoeveel minuten zitten er in een uur?
25
+ answers: ["60", "zestig"]
26
+ - question: Wat is het omgkeerde van benden?
27
+ answer: "boven"
28
+ - question: Wat is het omgekeerde van zuid?
29
+ answer: ["noord", "noorden"]
30
+ - question: Wat is het omgekeerde van slecht?
31
+ answer: "goed"
32
+ - question: Hoeveel is 4 maal vier?
33
+ answers: ["16", "zestien"]
34
+ - question: Welk getal komt er na 20?
35
+ answers: ["21", "eenentwintig"]
36
+ - question: Welke maand komt er voor juli?
37
+ answer: "juni"
38
+ - question: Hoeveel is vijftien gedeeld door drie?
39
+ answer: ["vijf", "5"]
40
+ - question: Hoeveel is 14 min 4?
41
+ answers: ["10", "tien"]
42
+ - question: "Wat is het volgende? Maandag, dinsdag, woensdag..."
43
+ answer: "donderdag"
@@ -0,0 +1,43 @@
1
+ pt-BR:
2
+ humanizer:
3
+ validation:
4
+ error: Você não é humano
5
+ questions:
6
+ - question: Dois mais dois?
7
+ answers: ["4", "quatro"]
8
+ - question: "Água mole em pedra dura, tanto bate até que..."
9
+ answer: fura
10
+ - question: Que número vem antes de doze?
11
+ answers: ["11", "onze"]
12
+ - question: Quanto é cinco vezes dois?
13
+ answers: ["10", "dez"]
14
+ - question: "Coloque o próximo número na sequência: 10, 11, 12, 13, 14, .."
15
+ answers: ["15", "quinze"]
16
+ - question: Quanto é cinco vezes cinco?
17
+ answers: ["25", "vinte e cinco"]
18
+ - question: Quanto é dez dividido por dois?
19
+ answers: ["5", "cinco"]
20
+ - question: Que dia vem depois da segunda-feira?
21
+ answers: ["terça", "terça-feira"]
22
+ - question: Qual é o último mês do ano?
23
+ answer: "dezembro"
24
+ - question: Quantos minutos tem uma hora?
25
+ answers: ["60", "sessenta"]
26
+ - question: Qual é o contrário de alto?
27
+ answer: "baixo"
28
+ - question: Qual é o contrário de norte?
29
+ answer: "sul"
30
+ - question: Qual é o contrário de ruim?
31
+ answer: "bom"
32
+ - question: Quanto é 4 vezes quatro?
33
+ answers: ["16", "dezesseis"]
34
+ - question: Que número vem depois de 20?
35
+ answers: ["21", "vinte e um"]
36
+ - question: Que mês vem antes de julho?
37
+ answer: "junho"
38
+ - question: Quanto é quinze dividido por três?
39
+ answer: ["cinco", "5"]
40
+ - question: Quanto é 14 menos 4?
41
+ answers: ["10", "dez"]
42
+ - question: "O que vem em seguida? segunda, terça, quarta, ..."
43
+ answers: ["quinta", "quinta-feira"]
@@ -0,0 +1,43 @@
1
+ pt-PT:
2
+ humanizer:
3
+ validation:
4
+ error: Você não é humano
5
+ questions:
6
+ - question: Dois mais dois?
7
+ answers: ["4", "quatro"]
8
+ - question: "Água mole em pedra dura, tanto bate até que..."
9
+ answer: fura
10
+ - question: Que número vem antes de doze?
11
+ answers: ["11", "onze"]
12
+ - question: Cinco vezes dois?
13
+ answers: ["10", "dez"]
14
+ - question: "Coloque o próximo número na sequência: 10, 11, 12, 13, 14, .."
15
+ answers: ["15", "quinze"]
16
+ - question: Cinco vezes cinco?
17
+ answers: ["25", "vinte e cinco"]
18
+ - question: Quanto é dez dividido por dois?
19
+ answers: ["5", "cinco"]
20
+ - question: Que dia vem depois da segunda-feira?
21
+ answers: ["terça", "terça-feira"]
22
+ - question: Qual é o último mês do ano?
23
+ answer: "dezembro"
24
+ - question: Quantos minutos tem uma hora?
25
+ answers: ["60", "sessenta"]
26
+ - question: Qual é o contrário de alto?
27
+ answer: "baixo"
28
+ - question: Qual é o contrário de norte?
29
+ answer: "sul"
30
+ - question: Qual é o contrário de mau?
31
+ answer: "bom"
32
+ - question: Quanto é quatro vezes quatro?
33
+ answers: ["16", "dezasseis"]
34
+ - question: Que número vem depois de vinte?
35
+ answers: ["21", "vinte e um"]
36
+ - question: Que mês vem antes de julho?
37
+ answer: "junho"
38
+ - question: Quanto é quinze dividido por três?
39
+ answer: ["cinco", "5"]
40
+ - question: Quanto é 14 menos 4?
41
+ answers: ["10", "dez"]
42
+ - question: "Qual é o próximo? segunda, terça, quarta, ..."
43
+ answers: ["quinta", "quinta-feira"]
data/lib/humanizer.rb CHANGED
@@ -31,13 +31,14 @@ module Humanizer
31
31
  end
32
32
 
33
33
  def humanizer_check_answer
34
- errors[:base] << I18n.translate("humanizer.validation.error") unless humanizer_correct_answer?
34
+ errors[:humanizer_answer] << I18n.translate("humanizer.validation.error") unless humanizer_correct_answer?
35
35
  end
36
36
 
37
37
  module ClassMethods
38
38
 
39
- def require_human_on(validate_on)
40
- validate :humanizer_check_answer, :on => validate_on
39
+ def require_human_on(validate_on, opts = {})
40
+ opts[:on] = validate_on
41
+ validate :humanizer_check_answer, opts
41
42
  end
42
43
 
43
44
  end
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "2.0.0"
3
- end
2
+ VERSION = "2.1.0"
3
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
+ - 1
7
8
  - 0
8
- - 0
9
- version: 2.0.0
9
+ version: 2.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Antti Akonniemi
@@ -15,11 +15,69 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-30 00:00:00 +03:00
18
+ date: 2010-09-09 00:00:00 +03:00
19
19
  default_executable:
20
- dependencies: []
21
-
22
- description: Recaptcha was too much for us, so we created this. Shout-out to brain_busters
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bundler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 1
31
+ - 0
32
+ - 0
33
+ version: 1.0.0
34
+ type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 2
59
+ - 0
60
+ - 0
61
+ - beta
62
+ version: 2.0.0.beta
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rails
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 3
75
+ - 0
76
+ - 0
77
+ version: 3.0.0
78
+ type: :development
79
+ version_requirements: *id004
80
+ description: reCAPTCHA was too much for us, so we created this. Simplest captcha ever.
23
81
  email:
24
82
  - antti@kiskolabs.com
25
83
  - joao@kiskolabs.com
@@ -36,7 +94,12 @@ files:
36
94
  - LICENSE
37
95
  - CHANGELOG.md
38
96
  - README.md
39
- - lib/generators/templates/en.yml
97
+ - lib/generators/templates/locales/de.yml
98
+ - lib/generators/templates/locales/en.yml
99
+ - lib/generators/templates/locales/fi.yml
100
+ - lib/generators/templates/locales/nl.yml
101
+ - lib/generators/templates/locales/pt-BR.yml
102
+ - lib/generators/templates/locales/pt-PT.yml
40
103
  has_rdoc: true
41
104
  homepage: http://github.com/kiskolabs/humanizer
42
105
  licenses: []