acts_as_textcaptcha 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.*.db
2
+ *.db
3
+ doc
4
+ *.gem
5
+ Gemfile.lock
6
+ pkg/*
7
+ coverage
8
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in acts_as_textcaptcha.gemspec
4
+ gemspec
data/README.rdoc CHANGED
@@ -10,8 +10,8 @@ Text CAPTCHA's logic questions are aimed at a child's age of 7, so can be solved
10
10
 
11
11
  == Rails 3
12
12
 
13
- This gem is now fully Rails 3 compatible.
14
-
13
+ This gem is Rails 3 compatible.
14
+
15
15
  == Demo
16
16
 
17
17
  Here's a {fully working demo on heroku}[http://textcaptcha.heroku.com]!
@@ -136,8 +136,7 @@ For more details on the code please check the {documentation}[http://rdoc.info/p
136
136
 
137
137
  == Rake Tasks
138
138
 
139
- * rake rspec (run the rspec2 tests)
140
- * rake rcov (run tests showing coverage)
139
+ * rake spec (run the rspec2 tests)
141
140
  * rake rdoc (generate docs)
142
141
 
143
142
  == Links
@@ -167,5 +166,6 @@ This code is currently used in a number of production websites and apps. It was
167
166
  * {matthewhutchinson.net}[http://matthewhutchinson.net]
168
167
  * {pmFAQtory.com}[http://pmfaqtory.com]
169
168
  * {The FAQtory}[http://faqtory.heroku.com]
169
+ * {DPT Watch, San Francisco}[http://www.dptwatch.com]
170
170
 
171
- (if you're happily using acts_as_textcaptcha in production, let me know and I'll add you to this list)
171
+ (if you're happily using acts_as_textcaptcha in production, let me know and I'll add you to this list)
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ gem 'rdoc'
2
+
3
+ require 'bundler'
4
+ require 'rdoc/task'
5
+ require 'rspec/core/rake_task'
6
+ require 'rcov/rcovtask'
7
+
8
+ # bundler tasks
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ # rspec tasks
12
+ RSpec::Core::RakeTask.new(:spec) do |t|
13
+ t.rspec_opts = "--color --format=doc"
14
+ end
15
+
16
+ # rdoc tasks
17
+ RDoc::Task.new do |rd|
18
+ rd.main = "README.rdoc"
19
+ rd.title = 'acts_as_textcaptcha'
20
+ rd.rdoc_dir = 'doc'
21
+ rd.options << "--all"
22
+ rd.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
23
+ end
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "acts_as_textcaptcha/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "acts_as_textcaptcha"
7
+ s.version = ActsAsTextcaptcha::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Matthew Hutchinson"]
10
+ s.email = ["matt@hiddenloop.com"]
11
+ s.homepage = "http://github.com/matthutchinson/acts_as_textcaptcha"
12
+ s.summary = %q{Spam protection for your models via logic questions and the excellent textcaptcha.com api}
13
+ s.description = %q{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.
14
+ 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.
15
+ For more reasons on why logic questions are useful, see here; http://textcaptcha.com/why}
16
+
17
+ s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_dependency('rails')
25
+ s.add_dependency('activerecord')
26
+ 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')
31
+ s.add_development_dependency('sqlite3')
32
+ end
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # init.rb, not included in gemspec files, but required to work as a rails plugin
2
+ require './vendor/plugins/acts_as_textcaptcha/lib/acts_as_textcaptcha'
@@ -57,11 +57,11 @@ module ActsAsTextcaptcha
57
57
  if !respond_to?('new_record?') || new_record?
58
58
  if allowed?
59
59
  if possible_answers && perform_spam_check? && !validate_spam_answer
60
- errors.add(:spam_answer, 'is incorrect, try another question instead')
60
+ errors.add(:spam_answer, :incorrect_answer, :message => "is incorrect, try another question instead")
61
61
  return false
62
62
  end
63
63
  else
64
- errors.add(:base, "Sorry, #{self.class.name.pluralize.downcase} are currently disabled")
64
+ errors.add(:base, :disabled, :message => "Sorry, adding a %{model} is currently disabled")
65
65
  return false
66
66
  end
67
67
  end
@@ -124,4 +124,4 @@ module ActsAsTextcaptcha
124
124
  end
125
125
  end
126
126
  end
127
- end
127
+ end
@@ -0,0 +1,3 @@
1
+ module ActsAsTextcaptcha
2
+ VERSION = "2.2.1"
3
+ end
@@ -1,5 +1,4 @@
1
- require 'rspec/core'
2
- require File.dirname(__FILE__) + '/spec_helper.rb'
1
+ require 'spec_helper'
3
2
 
4
3
  class Widget < ActiveRecord::Base
5
4
  # uses textcaptcha.yml file for configuration
@@ -24,14 +23,14 @@ end
24
23
  class Note < ActiveRecord::Base
25
24
  # inline options with user defined questions only (no textcaptcha service)
26
25
  acts_as_textcaptcha('questions' => [{'question' => '1+1', 'answers' => '2,two'}])
27
- end
26
+ end
28
27
 
29
28
  class Contact
30
- # non active record object
29
+ # non active record object
31
30
  include ActiveModel::Validations
32
31
  include ActiveModel::Conversion
33
- extend ActsAsTextcaptcha::Textcaptcha
34
- acts_as_textcaptcha(:questions => [{:question => '1+1', :answers => '2,two'}])
32
+ extend ActsAsTextcaptcha::Textcaptcha
33
+ acts_as_textcaptcha(:questions => [{:question => '1+1', :answers => '2,two'}])
35
34
  end
36
35
 
37
36
 
@@ -40,8 +39,8 @@ describe 'ActsAsTextcaptcha' do
40
39
  before(:each) do
41
40
  @comment = Comment.new
42
41
  @review = Review.new
43
- @note = Note.new
44
- @contact = Contact.new
42
+ @note = Note.new
43
+ @contact = Contact.new
45
44
  end
46
45
 
47
46
  describe 'validations' do
@@ -50,14 +49,14 @@ describe 'ActsAsTextcaptcha' do
50
49
  @note.generate_spam_question
51
50
  @note.validate_textcaptcha.should be_false
52
51
  @note.should_not be_valid
53
- end
54
-
52
+ end
53
+
55
54
  it "should validate non ActiveRecord object" do
56
55
  @contact.generate_spam_question
57
56
  @contact.spam_answer = 'wrong'
58
57
  @contact.validate_textcaptcha.should be_false
59
58
  @contact.should_not be_valid
60
-
59
+
61
60
  @contact.spam_answer = 'two'
62
61
  @contact.validate_textcaptcha.should be_true
63
62
  @contact.should be_valid
@@ -74,6 +73,7 @@ describe 'ActsAsTextcaptcha' do
74
73
 
75
74
  @note.spam_answer = 'wrong'
76
75
  @note.validate_textcaptcha.should be_false
76
+ @note.errors[:spam_answer].should eql(['is incorrect, try another question instead'])
77
77
  @note.should_not be_valid
78
78
  end
79
79
 
@@ -132,7 +132,7 @@ describe 'ActsAsTextcaptcha' do
132
132
  @comment.stub!(:allowed?).and_return(false)
133
133
 
134
134
  @comment.validate_textcaptcha.should be_false
135
- @comment.errors[:base].should eql(['Sorry, comments are currently disabled'])
135
+ @comment.errors[:base].should eql(['Sorry, adding a Comment is currently disabled'])
136
136
  @comment.should_not be_valid
137
137
  end
138
138
  end
@@ -144,7 +144,7 @@ describe 'ActsAsTextcaptcha' do
144
144
  @review.textcaptcha_config.should eql({:bcrypt_cost =>'3', :questions => [{'question' => '1+1', 'answers' => '2,two'},
145
145
  {'question' => 'The green hat is what color?', 'answers' => 'green'},
146
146
  {'question' => 'Which is bigger: 67, 14 or 6', 'answers' => '67,sixtyseven,sixty seven,sixty-seven'}],
147
- :bcrypt_salt => '$2a$10$j0bmycH.SVfD1b5mpEGPpe',
147
+ :bcrypt_salt => '$2a$10$j0bmycH.SVfD1b5mpEGPpe',
148
148
  :api_key => '8u5ixtdnq9csc84cok0owswgo'})
149
149
  @note.textcaptcha_config.should eql({:questions => [{:question => '1+1', :answers => '2,two'}]})
150
150
  @contact.textcaptcha_config.should eql({:questions => [{:question => '1+1', :answers => '2,two'}]})
@@ -224,4 +224,4 @@ describe 'ActsAsTextcaptcha' do
224
224
  end
225
225
  end
226
226
  end
227
- end
227
+ end
data/spec/database.yml ADDED
@@ -0,0 +1,21 @@
1
+ sqlite:
2
+ :adapter: sqlite
3
+ :database: acts_as_textcaptcha.sqlite.db
4
+
5
+ sqlite3:
6
+ :adapter: sqlite3
7
+ :database: acts_as_textcaptcha.sqlite3.db
8
+
9
+ postgresql:
10
+ :adapter: postgresql
11
+ :username: postgres
12
+ :password: postgres
13
+ :database: acts_as_textcaptcha_test
14
+ :min_messages: ERROR
15
+
16
+ mysql:
17
+ :adapter: mysql
18
+ :host: localhost
19
+ :username: root
20
+ :password:
21
+ :database: acts_as_textcaptcha_test
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ -cfs
2
+ --loadby mtime
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,8 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
-
3
- require 'rubygems'
1
+ require 'bundler'
4
2
  require 'active_record'
5
3
  require 'rails'
4
+ require 'acts_as_textcaptcha'
6
5
 
7
- require File.dirname(__FILE__) + '/../lib/acts_as_textcaptcha'
8
-
6
+ # setup db
9
7
  ActiveRecord::Base.establish_connection(YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))[ENV['DB'] || 'sqlite3'])
10
-
11
- load(File.dirname(__FILE__) + "/schema.rb")
8
+ load(File.dirname(__FILE__) + "/schema.rb")
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_textcaptcha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 2
9
- - 0
10
- version: 2.2.0
4
+ prerelease:
5
+ version: 2.2.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Matthew Hutchinson
@@ -15,57 +10,125 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-12-01 00:00:00 +00:00
19
- default_executable:
13
+ date: 2011-06-19 00:00:00 Z
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
- name: bcrypt-ruby
16
+ name: rails
23
17
  prerelease: false
24
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: activerecord
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ 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
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
43
  - - ~>
28
44
  - !ruby/object:Gem::Version
29
- hash: 15
30
- segments:
31
- - 2
32
- - 1
33
- - 2
34
45
  version: 2.1.2
35
46
  type: :runtime
36
- version_requirements: *id001
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 2.5.0
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rcov
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.9.9
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: rdoc
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 3.5.3
79
+ type: :development
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
+ name: sqlite3
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :development
91
+ version_requirements: *id007
37
92
  description: |-
38
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.
39
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.
40
95
  For more reasons on why logic questions are useful, see here; http://textcaptcha.com/why
41
- email: matt@hiddenloop.com
96
+ email:
97
+ - matt@hiddenloop.com
42
98
  executables: []
43
99
 
44
100
  extensions: []
45
101
 
46
102
  extra_rdoc_files:
47
- - LICENSE
48
103
  - README.rdoc
104
+ - LICENSE
49
105
  files:
106
+ - .gitignore
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.rdoc
110
+ - Rakefile
111
+ - acts_as_textcaptcha.gemspec
50
112
  - config/textcaptcha.yml
113
+ - init.rb
51
114
  - lib/acts_as_textcaptcha.rb
52
115
  - lib/acts_as_textcaptcha/framework/rails2.rb
53
116
  - lib/acts_as_textcaptcha/framework/rails3.rb
54
117
  - lib/acts_as_textcaptcha/textcaptcha.rb
55
118
  - lib/acts_as_textcaptcha/textcaptcha_helper.rb
119
+ - lib/acts_as_textcaptcha/version.rb
56
120
  - lib/tasks/textcaptcha.rake
57
- - LICENSE
58
- - README.rdoc
59
121
  - spec/acts_as_textcaptcha_spec.rb
122
+ - spec/database.yml
60
123
  - spec/schema.rb
124
+ - spec/spec.opts
61
125
  - spec/spec_helper.rb
62
- has_rdoc: true
63
126
  homepage: http://github.com/matthutchinson/acts_as_textcaptcha
64
127
  licenses: []
65
128
 
66
129
  post_install_message:
67
- rdoc_options:
68
- - --charset=UTF-8
130
+ rdoc_options: []
131
+
69
132
  require_paths:
70
133
  - lib
71
134
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -73,27 +136,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
136
  requirements:
74
137
  - - ">="
75
138
  - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
139
  version: "0"
80
140
  required_rubygems_version: !ruby/object:Gem::Requirement
81
141
  none: false
82
142
  requirements:
83
143
  - - ">="
84
144
  - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
145
  version: "0"
89
146
  requirements: []
90
147
 
91
148
  rubyforge_project:
92
- rubygems_version: 1.3.7
149
+ rubygems_version: 1.8.5
93
150
  signing_key:
94
151
  specification_version: 3
95
152
  summary: Spam protection for your models via logic questions and the excellent textcaptcha.com api
96
153
  test_files:
97
154
  - spec/acts_as_textcaptcha_spec.rb
155
+ - spec/database.yml
98
156
  - spec/schema.rb
157
+ - spec/spec.opts
99
158
  - spec/spec_helper.rb