invisible_captcha 0.1.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/.document +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +39 -0
- data/README.md +25 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/invisible_captcha.gemspec +57 -0
- data/lib/invisible_captcha.rb +3 -0
- data/lib/invisible_captcha/validator.rb +21 -0
- data/lib/invisible_captcha/view_helpers.rb +21 -0
- metadata +124 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.2.9)
|
5
|
+
activesupport (= 3.2.9)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activesupport (3.2.9)
|
8
|
+
i18n (~> 0.6)
|
9
|
+
multi_json (~> 1.0)
|
10
|
+
builder (3.0.4)
|
11
|
+
columnize (0.3.6)
|
12
|
+
debugger (1.2.1)
|
13
|
+
columnize (>= 0.3.1)
|
14
|
+
debugger-linecache (~> 1.1.1)
|
15
|
+
debugger-ruby_core_source (~> 1.1.4)
|
16
|
+
debugger-linecache (1.1.2)
|
17
|
+
debugger-ruby_core_source (>= 1.1.1)
|
18
|
+
debugger-ruby_core_source (1.1.4)
|
19
|
+
git (1.2.5)
|
20
|
+
i18n (0.6.1)
|
21
|
+
jeweler (1.8.4)
|
22
|
+
bundler (~> 1.0)
|
23
|
+
git (>= 1.2.5)
|
24
|
+
rake
|
25
|
+
rdoc
|
26
|
+
json (1.7.5)
|
27
|
+
multi_json (1.3.7)
|
28
|
+
rake (10.0.2)
|
29
|
+
rdoc (3.12)
|
30
|
+
json (~> 1.4)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
activemodel
|
37
|
+
bundler
|
38
|
+
debugger
|
39
|
+
jeweler
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Invisible Captcha
|
2
|
+
Don't disturb users. Simple protection for ActiveModel forms using honeypot strategy.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to you Gemfile:
|
6
|
+
```
|
7
|
+
gem 'invisible_captcha', :require => 'invisible_captcha', :git => 'git@github.com:markets/invisible_captcha.git'
|
8
|
+
```
|
9
|
+
## Usage
|
10
|
+
In your form:
|
11
|
+
```ruby
|
12
|
+
<%= form_for(@topic) do |f| %>
|
13
|
+
<%= invisible_captcha 'topic', 'subtitle' %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
```
|
17
|
+
In your ActiveModel:
|
18
|
+
```ruby
|
19
|
+
attr_accessor :subtitle
|
20
|
+
|
21
|
+
validates :subtitle, :invisible_captcha => true
|
22
|
+
```
|
23
|
+
|
24
|
+
## License
|
25
|
+
Invisible Captcha is released under the [MIT](http://opensource.org/licenses/MIT) License.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "invisible_captcha"
|
18
|
+
gem.homepage = "http://github.com/markets/invisible_captcha"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Simple honeypot protection}
|
21
|
+
gem.description = %Q{Don't disturb users. Simple protection for ActiveModel forms using honeypot strategy.}
|
22
|
+
gem.email = "srmarc.ai@gmail.com"
|
23
|
+
gem.authors = ["Marc Anguera Insa"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
namespace :release do
|
29
|
+
desc "create a patch release, create tag and push to github"
|
30
|
+
task :patch do
|
31
|
+
Rake::Task['version:bump:patch'].invoke
|
32
|
+
Rake::Task['gemspec'].invoke
|
33
|
+
`git commit -am 'Regenerate gemspec'`
|
34
|
+
Rake::Task['git:release'].invoke
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "create a minor, create tag and push to github"
|
38
|
+
task :minor do
|
39
|
+
Rake::Task['version:bump:minor'].invoke
|
40
|
+
Rake::Task['gemspec'].invoke
|
41
|
+
`git commit -am 'Regenerate gemspec'`
|
42
|
+
Rake::Task['git:release'].invoke
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "create a major, create tag and push to github"
|
46
|
+
task :major do
|
47
|
+
Rake::Task['version:bump:major'].invoke
|
48
|
+
Rake::Task['gemspec'].invoke
|
49
|
+
`git commit -am 'Regenerate gemspec'`
|
50
|
+
Rake::Task['git:release'].invoke
|
51
|
+
end
|
52
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,57 @@
|
|
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 = "invisible_captcha"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Marc Anguera Insa"]
|
12
|
+
s.date = "2012-11-22"
|
13
|
+
s.description = "Don't disturb users. Simple protection for ActiveModel forms using honeypot strategy."
|
14
|
+
s.email = "srmarc.ai@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"invisible_captcha.gemspec",
|
26
|
+
"lib/invisible_captcha.rb",
|
27
|
+
"lib/invisible_captcha/validator.rb",
|
28
|
+
"lib/invisible_captcha/view_helpers.rb"
|
29
|
+
]
|
30
|
+
s.homepage = "http://github.com/markets/invisible_captcha"
|
31
|
+
s.licenses = ["MIT"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.24"
|
34
|
+
s.summary = "Simple honeypot protection"
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_runtime_dependency(%q<activemodel>, [">= 0"])
|
41
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
42
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
46
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
47
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
48
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
52
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
53
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
54
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_model/validator'
|
2
|
+
|
3
|
+
module InvisibleCaptcha
|
4
|
+
class InvisibleCaptchaValidator < ActiveModel::EachValidator
|
5
|
+
|
6
|
+
def validate_each(record, attribute, value)
|
7
|
+
if robot_presence?(record, attribute)
|
8
|
+
record.errors.clear
|
9
|
+
record.errors[:base] = "YOU ARE A ROBOT!!"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def robot_presence? object, attribute
|
15
|
+
object.send(attribute).present?
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveModel::Validations::InvisibleCaptchaValidator = InvisibleCaptcha::InvisibleCaptchaValidator
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module InvisibleCaptcha
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
def invisible_captcha model_name, attr_name
|
5
|
+
html_ids = []
|
6
|
+
{ :"#{model_name}" => 'If you are a human, do not fill in this field' }.collect do |field, label|
|
7
|
+
html_ids << (html_id = "#{field}_#{Time.now.to_i}")
|
8
|
+
content_tag :div, :id => html_id do
|
9
|
+
content_tag(:style, :type => 'text/css', :media => 'screen', :scoped => "scoped") do
|
10
|
+
"#{html_ids.map { |i| "##{i}" }.join(', ')} { display:none; }"
|
11
|
+
end +
|
12
|
+
label_tag("#{field}_#{attr_name}", label) +
|
13
|
+
text_field_tag("#{model_name}[#{attr_name}]")
|
14
|
+
end
|
15
|
+
end.join.html_safe
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActionView::Base.send :include, InvisibleCaptcha::ViewHelpers
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: invisible_captcha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marc Anguera Insa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: debugger
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Don't disturb users. Simple protection for ActiveModel forms using honeypot
|
79
|
+
strategy.
|
80
|
+
email: srmarc.ai@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files:
|
84
|
+
- README.md
|
85
|
+
files:
|
86
|
+
- .document
|
87
|
+
- Gemfile
|
88
|
+
- Gemfile.lock
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- VERSION
|
92
|
+
- invisible_captcha.gemspec
|
93
|
+
- lib/invisible_captcha.rb
|
94
|
+
- lib/invisible_captcha/validator.rb
|
95
|
+
- lib/invisible_captcha/view_helpers.rb
|
96
|
+
homepage: http://github.com/markets/invisible_captcha
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: 4332315930115636745
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 1.8.24
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: Simple honeypot protection
|
124
|
+
test_files: []
|