is_bot 0.3.0 → 0.3.1

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.
data/README.markdown CHANGED
@@ -21,8 +21,8 @@ In your model class:
21
21
 
22
22
  In your model's view:
23
23
 
24
- form_for @user do |F|
25
- f.captcha_reverse_field :user
24
+ form_for @user do |f|
25
+ captcha_reverse_field :user
26
26
  end
27
27
 
28
28
  And that's it.
data/lib/is_bot/is_bot.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  module IsBot
2
2
  module CaptchaInReverse
3
- def self.included(base)
4
- base.class_eval do
5
- extend ClassMethods
6
- class_attribute :captcha_in_reverse
7
- end
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ class_attribute :captcha_in_reverse
8
7
  end
9
8
 
10
9
  module ClassMethods
data/lib/is_bot.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  $: << File.join(File.dirname(__FILE__), "..", "lib")
2
2
 
3
- require "is_bot/is_bot"
3
+ require "is_bot/is_bot"
4
+
5
+ ActiveRecord::Base.send(:include, IsBot::CaptchaInReverse)
6
+ ActionView::Base.send(:include, IsBot::ViewHelper)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: is_bot
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Anuj Dutta
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-19 00:00:00 +01:00
13
+ date: 2011-06-26 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -35,17 +35,6 @@ dependencies:
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: sqlite3
40
- requirement: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - "="
44
- - !ruby/object:Gem::Version
45
- version: 1.3.3
46
- type: :runtime
47
- prerelease: false
48
- version_requirements: *id003
49
38
  description: Simple gem to reduce the spam attacks on sign-up, sign-in and other similar sorts of forms.
50
39
  email: anuj@andhapp.com
51
40
  executables: []
@@ -56,25 +45,10 @@ extra_rdoc_files:
56
45
  - LICENSE
57
46
  - README.markdown
58
47
  files:
59
- - .rspec
60
- - Gemfile
61
- - Gemfile.lock
62
- - HISTORY
63
- - LICENSE
64
- - README.markdown
65
- - Rakefile
66
- - VERSION
67
- - init.rb
68
- - is_bot.gemspec
69
48
  - lib/is_bot.rb
70
49
  - lib/is_bot/is_bot.rb
71
- - pkg/is_bot-0.1.0.gem
72
- - pkg/is_bot-0.2.0.gem
73
- - spec/database.yml
74
- - spec/is_bot_spec.rb
75
- - spec/models.rb
76
- - spec/schema.db
77
- - spec/spec_helper.rb
50
+ - LICENSE
51
+ - README.markdown
78
52
  has_rdoc: true
79
53
  homepage: http://github.com/andhapp/is_bot
80
54
  licenses: []
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format nested
2
- --color
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- gem "rails", "3.1.0.rc4"
5
- gem "rspec", "2.6.0"
6
- gem "sqlite3", "1.3.3"
data/Gemfile.lock DELETED
@@ -1,99 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- actionmailer (3.1.0.rc4)
5
- actionpack (= 3.1.0.rc4)
6
- mail (~> 2.3.0)
7
- actionpack (3.1.0.rc4)
8
- activemodel (= 3.1.0.rc4)
9
- activesupport (= 3.1.0.rc4)
10
- builder (~> 3.0.0)
11
- erubis (~> 2.7.0)
12
- i18n (~> 0.6)
13
- rack (~> 1.3.0)
14
- rack-cache (~> 1.0.1)
15
- rack-mount (~> 0.8.1)
16
- rack-test (~> 0.6.0)
17
- sprockets (~> 2.0.0.beta.10)
18
- tzinfo (~> 0.3.27)
19
- activemodel (3.1.0.rc4)
20
- activesupport (= 3.1.0.rc4)
21
- bcrypt-ruby (~> 2.1.4)
22
- builder (~> 3.0.0)
23
- i18n (~> 0.6)
24
- activerecord (3.1.0.rc4)
25
- activemodel (= 3.1.0.rc4)
26
- activesupport (= 3.1.0.rc4)
27
- arel (~> 2.1.1)
28
- tzinfo (~> 0.3.27)
29
- activeresource (3.1.0.rc4)
30
- activemodel (= 3.1.0.rc4)
31
- activesupport (= 3.1.0.rc4)
32
- activesupport (3.1.0.rc4)
33
- multi_json (~> 1.0)
34
- arel (2.1.1)
35
- bcrypt-ruby (2.1.4)
36
- builder (3.0.0)
37
- diff-lcs (1.1.2)
38
- erubis (2.7.0)
39
- hike (1.1.0)
40
- i18n (0.6.0)
41
- mail (2.3.0)
42
- i18n (>= 0.4.0)
43
- mime-types (~> 1.16)
44
- treetop (~> 1.4.8)
45
- mime-types (1.16)
46
- multi_json (1.0.3)
47
- polyglot (0.3.1)
48
- rack (1.3.0)
49
- rack-cache (1.0.2)
50
- rack (>= 0.4)
51
- rack-mount (0.8.1)
52
- rack (>= 1.0.0)
53
- rack-ssl (1.3.2)
54
- rack
55
- rack-test (0.6.0)
56
- rack (>= 1.0)
57
- rails (3.1.0.rc4)
58
- actionmailer (= 3.1.0.rc4)
59
- actionpack (= 3.1.0.rc4)
60
- activerecord (= 3.1.0.rc4)
61
- activeresource (= 3.1.0.rc4)
62
- activesupport (= 3.1.0.rc4)
63
- bundler (~> 1.0)
64
- railties (= 3.1.0.rc4)
65
- railties (3.1.0.rc4)
66
- actionpack (= 3.1.0.rc4)
67
- activesupport (= 3.1.0.rc4)
68
- rack-ssl (~> 1.3.2)
69
- rake (>= 0.8.7)
70
- rdoc (~> 3.4)
71
- thor (~> 0.14.6)
72
- rake (0.9.2)
73
- rdoc (3.6.1)
74
- rspec (2.6.0)
75
- rspec-core (~> 2.6.0)
76
- rspec-expectations (~> 2.6.0)
77
- rspec-mocks (~> 2.6.0)
78
- rspec-core (2.6.4)
79
- rspec-expectations (2.6.0)
80
- diff-lcs (~> 1.1.2)
81
- rspec-mocks (2.6.0)
82
- sprockets (2.0.0.beta.10)
83
- hike (~> 1.0)
84
- rack (~> 1.0)
85
- tilt (!= 1.3.0, ~> 1.1)
86
- sqlite3 (1.3.3)
87
- thor (0.14.6)
88
- tilt (1.3.2)
89
- treetop (1.4.9)
90
- polyglot (>= 0.3.1)
91
- tzinfo (0.3.28)
92
-
93
- PLATFORMS
94
- ruby
95
-
96
- DEPENDENCIES
97
- rails (= 3.1.0.rc4)
98
- rspec (= 2.6.0)
99
- sqlite3 (= 1.3.3)
data/HISTORY DELETED
@@ -1,16 +0,0 @@
1
- 19 June 2011
2
- ---------------
3
-
4
- * Upgraded to Rails 3.1.0.rc4
5
- * Upgraded to Rspec 2.6.0
6
- * class_inheritable_accessor changed to class_attribute
7
-
8
-
9
- 23 January 2011
10
- ---------------
11
-
12
- * Moved to Ruby 1.9.2
13
- * Upgraded to Rails3
14
- * Upgraded to Bundler
15
- * Cleaned up code
16
- * Slightly improved the specs
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
- begin
2
- require 'jeweler'
3
- Jeweler::Tasks.new do |gemspec|
4
- gemspec.name = "is_bot"
5
- gemspec.summary = "Fight the bot."
6
- gemspec.description = "Simple gem to reduce the spam attacks on sign-up, sign-in and other similar sorts of forms."
7
- gemspec.email = "anuj@andhapp.com"
8
- gemspec.homepage = "http://github.com/andhapp/is_bot"
9
- gemspec.authors = ["Anuj Dutta"]
10
- end
11
- Jeweler::GemcutterTasks.new
12
- rescue LoadError
13
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
14
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
data/init.rb DELETED
@@ -1,4 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "lib", "is_bot")
2
-
3
- ActiveRecord::Base.send(:include, IsBot::CaptchaInReverse)
4
- ActionView::Base.send(:include, IsBot::ViewHelper)
data/is_bot.gemspec DELETED
@@ -1,63 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{is_bot}
8
- s.version = "0.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Anuj Dutta"]
12
- s.date = %q{2011-06-19}
13
- s.description = %q{Simple gem to reduce the spam attacks on sign-up, sign-in and other similar sorts of forms.}
14
- s.email = %q{anuj@andhapp.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".rspec",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "HISTORY",
24
- "LICENSE",
25
- "README.markdown",
26
- "Rakefile",
27
- "VERSION",
28
- "init.rb",
29
- "is_bot.gemspec",
30
- "lib/is_bot.rb",
31
- "lib/is_bot/is_bot.rb",
32
- "pkg/is_bot-0.1.0.gem",
33
- "pkg/is_bot-0.2.0.gem",
34
- "spec/database.yml",
35
- "spec/is_bot_spec.rb",
36
- "spec/models.rb",
37
- "spec/schema.db",
38
- "spec/spec_helper.rb"
39
- ]
40
- s.homepage = %q{http://github.com/andhapp/is_bot}
41
- s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.6.2}
43
- s.summary = %q{Fight the bot.}
44
-
45
- if s.respond_to? :specification_version then
46
- s.specification_version = 3
47
-
48
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<rails>, ["= 3.1.0.rc4"])
50
- s.add_runtime_dependency(%q<rspec>, ["= 2.6.0"])
51
- s.add_runtime_dependency(%q<sqlite3>, ["= 1.3.3"])
52
- else
53
- s.add_dependency(%q<rails>, ["= 3.1.0.rc4"])
54
- s.add_dependency(%q<rspec>, ["= 2.6.0"])
55
- s.add_dependency(%q<sqlite3>, ["= 1.3.3"])
56
- end
57
- else
58
- s.add_dependency(%q<rails>, ["= 3.1.0.rc4"])
59
- s.add_dependency(%q<rspec>, ["= 2.6.0"])
60
- s.add_dependency(%q<sqlite3>, ["= 1.3.3"])
61
- end
62
- end
63
-
data/pkg/is_bot-0.1.0.gem DELETED
Binary file
data/pkg/is_bot-0.2.0.gem DELETED
Binary file
data/spec/database.yml DELETED
@@ -1,3 +0,0 @@
1
- test:
2
- :adapter: sqlite3
3
- :database: ':memory:'
data/spec/is_bot_spec.rb DELETED
@@ -1,93 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # ********************* SET-UP **************************
4
- # ---------- Models
5
- # There are two models that are used for describing IsBot
6
- # 1. Bot
7
- # 2. Robot
8
- # Both the models can be found in the models.rb file
9
- #
10
- # ---------- Schema
11
- # The schema is described in scehma.rb
12
- #
13
- # ---------- Database configuration
14
- # The specs use sqlite3 adapter and the configuration is described in database.yml
15
-
16
- describe IsBot do
17
- context "ClassMethods" do
18
- context "Set up" do
19
-
20
- it "should be in the list of included modules" do
21
- Bot.included_modules.should include(IsBot::CaptchaInReverse)
22
- end
23
-
24
- it "should add a virtual accessor 'captcha_in_reverse' to the class" do
25
- bot = Bot.new
26
- bot.should.respond_to?(:captcha_in_reverse)
27
- bot.should.respond_to?(:captcha_in_reverse=)
28
- end
29
-
30
- it "should add a class method 'validate_captcha'" do
31
- Bot.should.respond_to?(:validate_captcha)
32
- end
33
- end
34
-
35
- context "Validation" do
36
-
37
- before(:each) do
38
- @bot = Bot.new
39
- end
40
-
41
- # because a bot would fill in the hidden field
42
- it "should add to the errors if 'captcha_in_reverse' is not blank?" do
43
- lambda {
44
- @bot.captcha_in_reverse = "I am a Bot!"
45
- @bot.valid?
46
- }.should change(@bot.errors, :size).by(1)
47
- @bot.errors[:captcha_in_reverse] == "You are a bot!"
48
- end
49
-
50
- # because human is not expected to fill this field
51
- it "should not add to errors when 'captcha_in_reverse' is blank? " do
52
- lambda {
53
- @bot.captcha_in_reverse = nil
54
- @bot.valid?
55
- }.should_not change(@bot.errors, :size).by(1)
56
- end
57
-
58
- context "Custom validation" do
59
- it "should accept a custom error message" do
60
- robot = Robot.new(:captcha_in_reverse => "I am a Bot!")
61
- robot.valid?
62
- robot.errors[:captcha_in_reverse] == "You are a BOT. Go away"
63
- end
64
- end
65
-
66
- end
67
- end
68
-
69
- context "Helper" do
70
- context "set up" do
71
- it "should include the defined custom helper module" do
72
- ViewHelper::ViewField.included_modules.should include(IsBot::ViewHelper)
73
- end
74
- end
75
-
76
- context "input tag" do
77
- it "should create one for adding captcha" do
78
- ViewHelper::ViewField.new.should.respond_to?(:captcha_reverse_field)
79
- end
80
-
81
- it "should be hidden" do
82
- captcha_field = ViewHelper::ViewField.new.captcha_reverse_field(:bot)
83
- captcha_field.should include("style=\";display: none;\"")
84
- end
85
-
86
- it "should include the custom defined styles" do
87
- captcha_field = ViewHelper::ViewField.new.captcha_reverse_field(:bot, {:style => "color:red"})
88
- captcha_field.should include("style=\"color:red;display: none;\"")
89
- end
90
- end
91
- end
92
-
93
- end
data/spec/models.rb DELETED
@@ -1,7 +0,0 @@
1
- class Bot < ActiveRecord::Base
2
- validate_captcha
3
- end
4
-
5
- class Robot < ActiveRecord::Base
6
- validate_captcha :message => "You are a BOT. Go away."
7
- end
data/spec/schema.db DELETED
@@ -1,14 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 1) do
2
- create_table "bots", :force => true do |t|
3
- t.string "name"
4
- t.datetime "created_at"
5
- t.datetime "updated_at"
6
- end
7
-
8
- create_table "robots", :force => true do |t|
9
- t.string "name"
10
- t.datetime "created_at"
11
- t.datetime "updated_at"
12
- end
13
-
14
- end
data/spec/spec_helper.rb DELETED
@@ -1,22 +0,0 @@
1
- require 'bundler'
2
- Bundler.require(:default)
3
-
4
- require 'active_record'
5
- require 'action_view'
6
-
7
- require File.expand_path("../../init", __FILE__)
8
- require File.expand_path("../models", __FILE__)
9
-
10
- def connect(environment)
11
- conf = YAML::load(File.open(File.dirname(__FILE__) + '/database.yml'))
12
- ActiveRecord::Base.establish_connection(conf[environment])
13
- end
14
-
15
- connect('test')
16
- load(File.join(File.dirname(__FILE__), "schema.db"))
17
-
18
- module ViewHelper; class ViewField < ActionView::Base; end end
19
-
20
- RSpec.configure do |config|
21
- config.include(ViewHelper)
22
- end