acts_as_textcaptcha 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,59 +8,46 @@ The gem can be configured with your very own logic questions (to fall back on if
8
8
 
9
9
  Text CAPTCHA's logic questions are aimed at a child's age of 7, so can be solved easily by all but the most cognitively impaired users. As they involve human logic, such questions cannot be solved by a robot. There are both advantages and disadvantages for using logic questions over image based captchas, {find out more at Text CAPTCHA}[http://textcaptcha.com/why].
10
10
 
11
- == Rails 3
12
-
13
- This gem is Rails 3 compatible.
14
-
15
11
  == Demo
16
12
 
17
13
  Here's a {fully working demo on heroku}[http://textcaptcha.heroku.com]!
18
14
 
19
- == Requirements
20
-
21
- What do you need?
15
+ == Installing
22
16
 
23
- * {Rails}[http://github.com/rails/rails] >= 2.3.x (including Rails 3)
24
- * {Ruby}[http://ruby-lang.org/] >= 1.8.7 (also tested with REE and Ruby 1.9.2)
25
- * {bcrypt-ruby}[http://bcrypt-ruby.rubyforge.org/] gem (to securely encrypt the spam answers in your session)
26
- * {Text CAPTCHA api key}[http://textcaptcha.com/register] (_optional_, since you can define your own logic questions, see below for details)
27
- * {Rspec2}[http://rspec.info/] (_optional_ if you want to run the tests, requires >= rspec2)
28
-
29
- == Installing
17
+ === Rails 3
30
18
 
31
- Install the gem
19
+ Just add the following to your Gemfile, then run `bundle install`;
32
20
 
33
- gem install acts_as_textcaptcha
21
+ gem 'acts_as_textcaptcha'
34
22
 
23
+ === Rails 2.3.*
24
+
25
+ Add the following to your environment.rb file, then install with `gem install acts_as_textcaptcha`;
26
+
27
+ config.gem 'acts_as_textcaptcha'
28
+
29
+ === As a plugin
30
+
35
31
  Or install as a plugin with
36
-
32
+
37
33
  rails plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
38
34
  OR
39
35
  script/plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
40
-
36
+
41
37
  If you do decide to install this as a Rails plugin, you'll have to manually include the bcrypt-ruby gem in your Gemfile or environment config. Like so;
42
-
38
+
43
39
  gem 'bcrypt-ruby', :require => 'bcrypt'
44
40
  OR
45
41
  config.gem 'bcrypt-ruby', :lib => 'bcrypt'
46
-
47
- == Using
48
-
49
- First add the gem to your Gemfile
50
42
 
51
- gem "acts_as_textcaptcha"
52
-
53
- OR add to your environment.rb config;
43
+ == Setting up
54
44
 
55
- config.gem 'acts_as_textcaptcha'
56
-
57
-
58
- Next configure your models to be spam protected; (this is the most basic way to configure the gem, with an api key only)
45
+ Configure which models are to be spam protected; (this is the most basic way to configure the gem, with an api key only)
59
46
 
60
47
  class Comment < ActiveRecord::Base
61
48
  acts_as_textcaptcha({'api_key' => 'your_textcaptcha_api_key'})
62
49
  end
63
-
50
+
64
51
  Next in your controller *new* and *create* actions you'll want to _spamify_ your model and merge in the answers. Like so;
65
52
 
66
53
  def new
@@ -77,7 +64,7 @@ Next in your controller *new* and *create* actions you'll want to _spamify_ your
77
64
  render :action => 'new'
78
65
  end
79
66
  end
80
-
67
+
81
68
  Finally, in your form/view erb do something like the following;
82
69
 
83
70
  <%- if @comment.new_record? -%>
@@ -88,10 +75,10 @@ Finally, in your form/view erb do something like the following;
88
75
  <%= f.text_field :spam_answer, :value => '' %>
89
76
  <%- end -%>
90
77
  <%- end -%>
91
-
78
+
92
79
  == More Configurations
93
80
 
94
- You can also configure spam protection in the following ways.
81
+ You can also configure acts_as_textcaptcha in the following ways.
95
82
 
96
83
  === Hash
97
84
 
@@ -110,12 +97,21 @@ You can also configure spam protection in the following ways.
110
97
 
111
98
  === YAML config
112
99
 
113
- All the above options can be expressed in a {textcaptcha.yml}[http://github.com/matthutchinson/acts_as_textcaptcha/raw/master/config/textcaptcha.yml] file. Drop this into your RAILS_ROOT/config folder.
100
+ All the above options can be expressed in a {textcaptcha.yml}[http://github.com/matthutchinson/acts_as_textcaptcha/raw/master/config/textcaptcha.yml] file. Drop this into your RAILS_ROOT/config folder. The gem comes with a handy rake task to copy over a textcaptcha.yml template to your Rails config directory.
101
+
102
+ rake textcaptcha:generate_config
103
+
104
+ *NOTE:* If you are on Rails 2.3.*, you'll have to add the following to your Rakefile to make this task available;
114
105
 
115
- === _Without_ the Text CAPTCHA web service
106
+ `# load textcaptcha rake tasks
107
+ Dir["#{Gem.searcher.find('acts_as_textcaptcha').full_gem_path}/lib/tasks/**/*.rake"].each { |ext| load ext } if Gem.searcher.find('acts_as_textcaptcha')`
108
+
109
+
110
+ === Using _Without_ the Text CAPTCHA web service
116
111
 
117
112
  It *also* is possible to configure to use only your own user defined logic questions. To do so, just ommit the api_key and set at least 1 logic question in your options.
118
113
 
114
+
119
115
  == What does the code do?
120
116
 
121
117
  The gem contains two parts, a module for your ActiveRecord models, and a tiny helper method (spamify).
@@ -134,11 +130,43 @@ If the web service fails or no-api key is specified AND no alternate questions a
134
130
 
135
131
  For more details on the code please check the {documentation}[http://rdoc.info/projects/matthutchinson/acts_as_textcaptcha].
136
132
 
137
- == Rake Tasks
133
+ == Translations
134
+
135
+ Recent versions of the gem use standard Rails, I18n translation for the 2 possible error messages generated by acts_as_textcaptcha, with a fall-back to a default English error message. Unfortunately in some versions of Rails 2.3.* the translation fall-back fails. For this case (and when translating) the translations should be provided in your locale file with the following hierarchy (assuming your model is Comment);
136
+
137
+ en:
138
+ activerecord:
139
+ errors:
140
+ models:
141
+ comment:
142
+ disabled: "Sorry, adding a %{model} is currently disabled"
143
+ attributes:
144
+ spam_answer:
145
+ incorrect_answer: "is incorrect, try another question instead"
146
+ activemodel:
147
+ attributes:
148
+ comment:
149
+ spam_answer: "Spam answer"
150
+
151
+ It should be noted that currently the textcaptcha API service only offers logic questions in English.
152
+
153
+ == Testing and docs
154
+
155
+ In development you can run the specs and rdoc tasks like so;
138
156
 
139
157
  * rake spec (run the rspec2 tests)
140
158
  * rake rdoc (generate docs)
141
159
 
160
+ == Requirements
161
+
162
+ What do you need?
163
+
164
+ * {Rails}[http://github.com/rails/rails] >= 2.3.2 (including Rails 3)
165
+ * {Ruby}[http://ruby-lang.org/] >= 1.8.7 (also tested with REE and Ruby 1.9.2)
166
+ * {bcrypt-ruby}[http://bcrypt-ruby.rubyforge.org/] gem (to securely encrypt the spam answers in your session)
167
+ * {Text CAPTCHA api key}[http://textcaptcha.com/register] (_optional_, since you can define your own logic questions, see below for details)
168
+ * {Rspec2}[http://rspec.info/] (_optional_ if you want to run the tests, requires >= rspec2)
169
+
142
170
  == Links
143
171
 
144
172
  * {Documentation}[http://rdoc.info/projects/matthutchinson/acts_as_textcaptcha]
@@ -157,7 +185,7 @@ For more details on the code please check the {documentation}[http://rdoc.info/p
157
185
 
158
186
  == Todo
159
187
 
160
- * Test in other Ruby versions
188
+ * Fix issue with multiple forms open in the same session
161
189
 
162
190
  == Usage
163
191
 
data/Rakefile CHANGED
@@ -20,4 +20,4 @@ RDoc::Task.new do |rd|
20
20
  rd.rdoc_dir = 'doc'
21
21
  rd.options << "--all"
22
22
  rd.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
23
- end
23
+ end
@@ -20,13 +20,14 @@ Gem::Specification.new do |s|
20
20
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
21
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  s.require_paths = ["lib"]
23
-
24
- s.add_dependency('rails')
25
- s.add_dependency('activerecord')
23
+
26
24
  s.add_dependency('bcrypt-ruby', '~> 2.1.2')
27
-
28
- s.add_development_dependency('rspec', '~> 2.5.0')
29
- s.add_development_dependency('rcov', '~> 0.9.9')
30
- s.add_development_dependency('rdoc', '~> 3.5.3')
25
+
26
+ s.add_development_dependency('rails')
27
+ s.add_development_dependency('activerecord')
28
+ s.add_development_dependency('bundler')
29
+ s.add_development_dependency('rspec')
30
+ s.add_development_dependency('rcov')
31
+ s.add_development_dependency('rdoc')
31
32
  s.add_development_dependency('sqlite3')
32
33
  end
@@ -16,9 +16,11 @@ end
16
16
 
17
17
  module ActsAsTextcaptcha
18
18
 
19
- class Railtie < ::Rails::Railtie
20
- rake_tasks do
21
- load "tasks/textcaptcha.rake"
19
+ if Rails.version =~ /^3\./
20
+ class Railtie < ::Rails::Railtie
21
+ rake_tasks do
22
+ load "tasks/textcaptcha.rake"
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsTextcaptcha
2
- VERSION = "2.2.1"
2
+ VERSION = "2.2.2"
3
3
  end
metadata CHANGED
@@ -1,108 +1,119 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: acts_as_textcaptcha
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.2
4
5
  prerelease:
5
- version: 2.2.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Matthew Hutchinson
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-19 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rails
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-07-26 00:00:00.000000000 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bcrypt-ruby
17
+ requirement: &2152243920 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.2
24
23
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: activerecord
28
24
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2152243920
26
+ - !ruby/object:Gem::Dependency
27
+ name: rails
28
+ requirement: &2152243500 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
35
- type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: bcrypt-ruby
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
39
35
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *2152243500
37
+ - !ruby/object:Gem::Dependency
38
+ name: activerecord
39
+ requirement: &2152243040 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.1.2
46
- type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: rspec
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
50
46
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *2152243040
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ requirement: &2152242620 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 2.5.0
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
57
56
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: rcov
61
57
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *2152242620
59
+ - !ruby/object:Gem::Dependency
60
+ name: rspec
61
+ requirement: &2152242200 !ruby/object:Gem::Requirement
63
62
  none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 0.9.9
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
68
67
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: rdoc
72
68
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *2152242200
70
+ - !ruby/object:Gem::Dependency
71
+ name: rcov
72
+ requirement: &2152241780 !ruby/object:Gem::Requirement
74
73
  none: false
75
- requirements:
76
- - - ~>
77
- - !ruby/object:Gem::Version
78
- version: 3.5.3
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
79
78
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: sqlite3
83
79
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
80
+ version_requirements: *2152241780
81
+ - !ruby/object:Gem::Dependency
82
+ name: rdoc
83
+ requirement: &2152241360 !ruby/object:Gem::Requirement
85
84
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
90
89
  type: :development
91
- version_requirements: *id007
92
- description: |-
93
- Spam protection for your ActiveRecord models using logic questions and the excellent textcaptcha api. See textcaptcha.com for more details and to get your api key.
94
- The logic questions are aimed at a child's age of 7, so can be solved easily by all but the most cognitively impaired users. As they involve human logic, such questions cannot be solved by a robot.
95
- For more reasons on why logic questions are useful, see here; http://textcaptcha.com/why
96
- email:
90
+ prerelease: false
91
+ version_requirements: *2152241360
92
+ - !ruby/object:Gem::Dependency
93
+ name: sqlite3
94
+ requirement: &2152240940 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *2152240940
103
+ description: ! "Spam protection for your ActiveRecord models using logic questions
104
+ and the excellent textcaptcha api. See textcaptcha.com for more details and to get
105
+ your api key.\n The logic questions are aimed at a child's age of 7, so can be
106
+ solved easily by all but the most cognitively impaired users. As they involve human
107
+ logic, such questions cannot be solved by a robot.\n For more reasons on why logic
108
+ questions are useful, see here; http://textcaptcha.com/why"
109
+ email:
97
110
  - matt@hiddenloop.com
98
111
  executables: []
99
-
100
112
  extensions: []
101
-
102
- extra_rdoc_files:
113
+ extra_rdoc_files:
103
114
  - README.rdoc
104
115
  - LICENSE
105
- files:
116
+ files:
106
117
  - .gitignore
107
118
  - Gemfile
108
119
  - LICENSE
@@ -123,34 +134,33 @@ files:
123
134
  - spec/schema.rb
124
135
  - spec/spec.opts
125
136
  - spec/spec_helper.rb
137
+ has_rdoc: true
126
138
  homepage: http://github.com/matthutchinson/acts_as_textcaptcha
127
139
  licenses: []
128
-
129
140
  post_install_message:
130
141
  rdoc_options: []
131
-
132
- require_paths:
142
+ require_paths:
133
143
  - lib
134
- required_ruby_version: !ruby/object:Gem::Requirement
144
+ required_ruby_version: !ruby/object:Gem::Requirement
135
145
  none: false
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: "0"
140
- required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
151
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: "0"
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
146
156
  requirements: []
147
-
148
157
  rubyforge_project:
149
- rubygems_version: 1.8.5
158
+ rubygems_version: 1.6.2
150
159
  signing_key:
151
160
  specification_version: 3
152
- summary: Spam protection for your models via logic questions and the excellent textcaptcha.com api
153
- test_files:
161
+ summary: Spam protection for your models via logic questions and the excellent textcaptcha.com
162
+ api
163
+ test_files:
154
164
  - spec/acts_as_textcaptcha_spec.rb
155
165
  - spec/database.yml
156
166
  - spec/schema.rb