is_bot 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 849e58586c900fd82b99fb6e23a71864a96705c9
4
- data.tar.gz: d5364a96402941bd52306e5a97982faa91b1ad01
3
+ metadata.gz: 505715c9c3395a5c9cc3c957a750d1cff0924b96
4
+ data.tar.gz: d30f5860c2e540df8bb59cfdfe00b4c87a8adfc1
5
5
  SHA512:
6
- metadata.gz: 8318b8e5cfd3d7db40bb19d40df0c8e50fc6bde28c3222f9c4c853a70ce4524660c3b0105182b36762741d13138ac42d96dc8fcaeeeb9f950cfd195c00b9b1d4
7
- data.tar.gz: fb9dfff0eb0002959997ba7a08d43a4e7761beec19a241cc6ab438406760e577d36fc0be9ed46fb391bc1964a39207f0abe5c9a13000bac389f7882618019a94
6
+ metadata.gz: 546617e0b29addfea6d80b09e541bab8b5b53686ad51a2bd6062303e34f6524414a12ca16ef10228618ae35c9c8a50ba32d1a79269d706a57b7df2de8e271791
7
+ data.tar.gz: 8123701953906108237bbad146487421f9308862b3ed792dbcc323162dec575e01aea53d3d809b26ec6fe7a4aefb2742904195fe39664b560fa0abed6cc2381e
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ vendor/
2
+ .bundle/
3
+ .rvmrc
4
+ pkg/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ is_bot
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in is_bot.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ is_bot (2.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionview (4.2.4)
10
+ activesupport (= 4.2.4)
11
+ builder (~> 3.1)
12
+ erubis (~> 2.7.0)
13
+ rails-dom-testing (~> 1.0, >= 1.0.5)
14
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
15
+ activemodel (4.2.4)
16
+ activesupport (= 4.2.4)
17
+ builder (~> 3.1)
18
+ activerecord (4.2.4)
19
+ activemodel (= 4.2.4)
20
+ activesupport (= 4.2.4)
21
+ arel (~> 6.0)
22
+ activesupport (4.2.4)
23
+ i18n (~> 0.7)
24
+ json (~> 1.7, >= 1.7.7)
25
+ minitest (~> 5.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
27
+ tzinfo (~> 1.1)
28
+ arel (6.0.3)
29
+ builder (3.2.2)
30
+ diff-lcs (1.2.5)
31
+ erubis (2.7.0)
32
+ i18n (0.7.0)
33
+ json (1.8.3)
34
+ loofah (2.0.3)
35
+ nokogiri (>= 1.5.9)
36
+ mini_portile (0.6.2)
37
+ minitest (5.8.1)
38
+ nokogiri (1.6.6.2)
39
+ mini_portile (~> 0.6.0)
40
+ rails-deprecated_sanitizer (1.0.3)
41
+ activesupport (>= 4.2.0.alpha)
42
+ rails-dom-testing (1.0.7)
43
+ activesupport (>= 4.2.0.beta, < 5.0)
44
+ nokogiri (~> 1.6.0)
45
+ rails-deprecated_sanitizer (>= 1.0.1)
46
+ rails-html-sanitizer (1.0.2)
47
+ loofah (~> 2.0)
48
+ rake (10.4.2)
49
+ rspec (3.3.0)
50
+ rspec-core (~> 3.3.0)
51
+ rspec-expectations (~> 3.3.0)
52
+ rspec-mocks (~> 3.3.0)
53
+ rspec-core (3.3.2)
54
+ rspec-support (~> 3.3.0)
55
+ rspec-expectations (3.3.1)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.3.0)
58
+ rspec-mocks (3.3.2)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.3.0)
61
+ rspec-support (3.3.0)
62
+ sqlite3 (1.3.10)
63
+ thread_safe (0.3.5)
64
+ tzinfo (1.2.2)
65
+ thread_safe (~> 0.1)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ actionview
72
+ activerecord
73
+ activesupport
74
+ bundler (~> 1.10)
75
+ is_bot!
76
+ rake (~> 10.0)
77
+ rspec
78
+ sqlite3
79
+
80
+ BUNDLED WITH
81
+ 1.10.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Anuj Dutta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1,16 +1,14 @@
1
- is_bot
2
- ======
1
+ is_bot
3
2
 
4
- About
5
- -----
3
+ ## About
6
4
 
7
5
  **is_bot** is a clean rewrite of **less_reverse_captcha**
8
6
 
9
7
  It is a simple way to make your forms bot-proof. The effectiveness of the solution is open to discussion. I have used it on a low traffic site and it seems to have reduced the bot-attack considerably.
10
8
 
11
9
 
12
- Usage
13
- -----
10
+ ## Usage
11
+
14
12
  It is very simple to use. Just install it in your rails app and perform the following steps.
15
13
 
16
14
  In your model class:
@@ -27,14 +25,24 @@ In your model's view:
27
25
 
28
26
  And that's it.
29
27
 
28
+ ## Rails 3
29
+
30
+ Use version 1.0.0
31
+
32
+ ## Rails 4
33
+
34
+ Use version 2.0.0
35
+
36
+ ## Versioning
37
+
38
+ The project uses semantic versioning.
39
+
40
+ ## Bugs
30
41
 
31
- Bugs
32
- ----
42
+ Please report the issues through [Github's issues](https://github.com/andhapp/is_bot/issues).
33
43
 
34
- Please report the issues through gitHub's issues.
35
44
 
45
+ ## Authors
36
46
 
37
- Authors
38
- -------
47
+ * Anuj Dutta - [andHapp.com](http://www.andhapp.com/blog)
39
48
 
40
- * Anuj Dutta - [andHapp.com](http://www.andhapp.com/blog)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "is_bot"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/is_bot.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'is_bot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "is_bot"
8
+ spec.version = IsBot::VERSION
9
+ spec.authors = ["Anuj Dutta"]
10
+ spec.email = ["anuj@andhapp.com"]
11
+
12
+ spec.summary = %q{Protects web forms from spammers}
13
+ spec.description = %q{Simple gem to reduce the spam attacks on sign-up, sign-in and other similar sorts of forms.}
14
+ spec.homepage = "https://github.com/andhapp"
15
+ spec.license = "MIT"
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "sqlite3"
25
+ spec.add_development_dependency "activerecord"
26
+ spec.add_development_dependency "actionview"
27
+ spec.add_development_dependency "activesupport"
28
+ end
@@ -0,0 +1,3 @@
1
+ module IsBot
2
+ VERSION = "2.0.0"
3
+ end
data/lib/is_bot.rb CHANGED
@@ -1,6 +1,35 @@
1
- $: << File.join(File.dirname(__FILE__), "..", "lib")
1
+ require "is_bot/version"
2
+ require 'active_record'
3
+ require 'action_view'
4
+ require 'active_support'
2
5
 
3
- require "is_bot/is_bot"
6
+ module IsBot
7
+ module CaptchaInReverse
8
+ extend ::ActiveSupport::Concern
9
+
10
+ included do
11
+ class_attribute :captcha_in_reverse
12
+ end
13
+
14
+ module ClassMethods
15
+ def validate_captcha(options = {})
16
+ validates_each :captcha_in_reverse do |record, attr, value|
17
+ record.errors[attr] << (options[:message] || "You are a bot!") unless value.blank?
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ module ViewHelper
24
+ def captcha_reverse_field(object, options={})
25
+ style = (options.delete(:style) || '') << ";"
26
+ style << "visibility: hidden;"
27
+ ActionView::Helpers::Tags::TextField.new(
28
+ object, :captcha_in_reverse, self, options.merge(:style => style)
29
+ ).render
30
+ end
31
+ end
32
+ end
4
33
 
5
34
  ActiveRecord::Base.send(:include, IsBot::CaptchaInReverse)
6
- ActionView::Base.send(:include, IsBot::ViewHelper)
35
+ ActionView::Base.send(:include, IsBot::ViewHelper)
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anuj Dutta
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2015-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.1
20
- type: :runtime
19
+ version: '1.10'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.1
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -31,7 +45,63 @@ dependencies:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
- type: :runtime
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: actionview
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: activesupport
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
35
105
  prerelease: false
36
106
  version_requirements: !ruby/object:Gem::Requirement
37
107
  requirements:
@@ -40,19 +110,30 @@ dependencies:
40
110
  version: '0'
41
111
  description: Simple gem to reduce the spam attacks on sign-up, sign-in and other similar
42
112
  sorts of forms.
43
- email: anuj@andhapp.com
113
+ email:
114
+ - anuj@andhapp.com
44
115
  executables: []
45
116
  extensions: []
46
- extra_rdoc_files:
47
- - LICENSE
48
- - README.markdown
117
+ extra_rdoc_files: []
49
118
  files:
50
- - LICENSE
51
- - README.markdown
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".ruby-gemset"
122
+ - ".ruby-version"
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - is_bot.gemspec
52
132
  - lib/is_bot.rb
53
- - lib/is_bot/is_bot.rb
54
- homepage: http://github.com/andhapp/is_bot
55
- licenses: []
133
+ - lib/is_bot/version.rb
134
+ homepage: https://github.com/andhapp
135
+ licenses:
136
+ - MIT
56
137
  metadata: {}
57
138
  post_install_message:
58
139
  rdoc_options: []
@@ -73,5 +154,5 @@ rubyforge_project:
73
154
  rubygems_version: 2.2.2
74
155
  signing_key:
75
156
  specification_version: 4
76
- summary: Fight the bot.
157
+ summary: Protects web forms from spammers
77
158
  test_files: []
data/LICENSE DELETED
File without changes
data/lib/is_bot/is_bot.rb DELETED
@@ -1,26 +0,0 @@
1
- module IsBot
2
- module CaptchaInReverse
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- class_attribute :captcha_in_reverse
7
- end
8
-
9
- module ClassMethods
10
- def validate_captcha(options = {})
11
- validates_each :captcha_in_reverse do |record, attr, value|
12
- record.errors[attr] << (options[:message] || "You are a bot!") unless value.blank?
13
- end
14
- end
15
- end
16
- end
17
-
18
- module ViewHelper
19
- def captcha_reverse_field(object, options={})
20
- style = (options.delete(:style) || '') << ";"
21
- style << "display: none;"
22
- ActionView::Helpers::InstanceTag.new(object, :captcha_in_reverse, self).to_input_field_tag("text", options.merge(:style => style) )
23
- end
24
- end
25
-
26
- end