molasses_jar 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- = molasses_jar
1
+ # molasses_jar
2
2
 
3
- A simple ActiveRecord extension for creating honeypot style captchas.
3
+ A simple ActiveRecord extension for creating inverse captchas using the Honeypot pattern.
4
4
 
5
- == Nuts and Bolts
5
+ An inverse captcha uses a specific form field that the user does not see, but bots and spiders will. If a value is set on the input, then the model is marked as being either spam or invalid depending on how you chose to implement the gem.
6
+
7
+ ## Nuts and Bolts
6
8
 
7
9
  MolassesJar will add simple honeypot verification to any model you wish. It creates an attribute called :molasses_jar on the desired object and then checks to see if there is a value assigned to it.
8
10
 
@@ -10,13 +12,13 @@ MolassesJar will look for a boolean attribute called ```spam``` on your model.
10
12
 
11
13
  If it does not find a ```spam``` attribute on your model, it will add an error to the molasses_jar attribute, thus preventing the model from validating and saving.
12
14
 
13
- == How To Use
15
+ ## How To Use
14
16
 
15
- === Install the gem through Bundler
17
+ ### Install the gem through Bundler
16
18
 
17
19
  gem "molasses_jar"
18
20
 
19
- === If flagging is desired, add a spam attribute to your Model
21
+ ### If flagging is desired, add a spam attribute to your Model
20
22
 
21
23
  Generate a migration to add the spam attribute to your model. It is recommended that you index the attribute sice it will appear in a where clause through the included scope
22
24
 
@@ -26,13 +28,13 @@ Generate a migration to add the spam attribute to your model. It is recommended
26
28
  ContactForm.update_all(:spam => false)
27
29
  end
28
30
 
29
- === Add the Extensions to your Model
31
+ ### Add the Extensions to your Model
30
32
 
31
33
  class ContactForm < ActiveRecord::Base
32
34
  include MolassesJar::Extensions
33
35
  end
34
36
 
35
- === Add the input to your forms
37
+ ### Add the input to your forms
36
38
 
37
39
  You will need to add an input to your object's form with the attribute :molasses_jar. Then use css, to either ```display: none;``` or move the form off the screen using absolute positioning. Best practices suggests you include a label with your input field and include some sort of message that says "If you're a human, please leave this field blank" to insure accessability.
38
40
 
@@ -47,18 +49,23 @@ CSS
47
49
  display: none;
48
50
  }
49
51
 
50
- == Coming Soon
52
+ ## Testing
53
+
54
+ Specs are current. Please refer to spec/molasses_jar_spec.rb for testing examples. More to come soon.
55
+
56
+
57
+ ## Coming Soon
51
58
 
52
59
  * Form Helper to create the form input
53
60
  * Migration generator for the spam attribute
54
61
  * Stylesheet generator to create the stylesheet
55
62
 
56
- == Interesting Reads on the Honeypot Approach
63
+ ## Interesting Reads on the Honeypot Approach
57
64
 
58
65
  * http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx/
59
66
  * http://www.londonswebdesign.com/articles/Web-articles-Honeypot-CAPTCHA-vs-Spambots.html
60
67
 
61
- == Contributing to molasses_jar
68
+ ## Contributing to molasses_jar
62
69
 
63
70
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
64
71
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -68,7 +75,7 @@ CSS
68
75
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
69
76
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
70
77
 
71
- == Copyright
78
+ ## Copyright
72
79
 
73
80
  Copyright (c) 2012 mindtonic. See LICENSE.txt for
74
81
  further details.
@@ -1,39 +1,39 @@
1
1
  module MolassesJar
2
- module Extensions
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- attr_accessor :molasses_jar
7
-
8
- scope :spammy, where(:spam => true)
9
- scope :not_spammy, where(:spam => false)
10
-
11
- validate :mark_as_spam?
12
-
13
- def mark_as_spam?
14
- if has_spam_attribute? and caught_something?
15
- self.spam = true
16
- elsif !has_spam_attribute? and caught_something?
17
- errors.add(:molasses_jar, "")
18
- end
19
- end
20
-
21
- def spam?
22
- if has_spam_attribute?
23
- self.spam
24
- else
25
- caught_something?
26
- end
27
- end
28
-
29
- def caught_something?
30
- self.molasses_jar.present?
31
- end
32
-
33
- def has_spam_attribute?
34
- self.attributes.include?("spam")
35
- end
36
-
37
- end
38
- end
39
- end
2
+ module Extensions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ attr_accessor :molasses_jar
7
+
8
+ scope :spammy, -> { where(:spam => true) }
9
+ scope :not_spammy, -> { where(:spam => false) }
10
+
11
+ validate :mark_as_spam?
12
+
13
+ def mark_as_spam?
14
+ if has_spam_attribute? and caught_something?
15
+ self.spam = true
16
+ elsif !has_spam_attribute? and caught_something?
17
+ errors.add(:molasses_jar, "")
18
+ end
19
+ end
20
+
21
+ def spam?
22
+ if has_spam_attribute?
23
+ self.spam
24
+ else
25
+ caught_something?
26
+ end
27
+ end
28
+
29
+ def caught_something?
30
+ self.molasses_jar.present?
31
+ end
32
+
33
+ def has_spam_attribute?
34
+ self.attributes.include?("spam")
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "molasses_jar"
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mindtonic"]
12
- s.date = "2012-07-31"
12
+ s.date = "2013-08-28"
13
13
  s.description = "A honeypot style captcha extension for ActiveRecord. Simple one-line inclusion in the model combined with a simple form field should trap the bad guys in the molasses."
14
14
  s.email = "mindtonic@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
22
22
  "LICENSE.txt",
23
23
  "README.md",
24
24
  "Rakefile",
25
- "VERSION",
26
25
  "lib/molasses_jar.rb",
27
26
  "lib/molasses_jar/extensions.rb",
28
27
  "lib/molasses_jar/helpers.rb",
@@ -15,7 +15,7 @@ describe MolassesJar do
15
15
  it "should initialize as nil" do
16
16
  @model.molasses_jar.nil?.should be true
17
17
  end
18
-
18
+
19
19
  it "should not have a spam attribute" do
20
20
  @model.has_spam_attribute?.should be false
21
21
  end
@@ -43,7 +43,7 @@ describe MolassesJar do
43
43
  it "should return true for spam?" do
44
44
  @model.spam?.should be true
45
45
  end
46
-
46
+
47
47
  it "should have caught_something?" do
48
48
  @model.caught_something?.should be true
49
49
  end
@@ -61,7 +61,7 @@ describe MolassesJar do
61
61
  it "should return false for spam?" do
62
62
  @model.spam?.should be false
63
63
  end
64
-
64
+
65
65
  it "should not have caught_something?" do
66
66
  @model.caught_something?.should be false
67
67
  end
@@ -81,7 +81,7 @@ describe MolassesJar do
81
81
  it "should initialize as nil" do
82
82
  @model.molasses_jar.nil?.should be true
83
83
  end
84
-
84
+
85
85
  it "should have a spam attribute" do
86
86
  @model.has_spam_attribute?.should be true
87
87
  end
@@ -117,7 +117,7 @@ describe MolassesJar do
117
117
  it "should return true for spam?" do
118
118
  @model.spam?.should be true
119
119
  end
120
-
120
+
121
121
  it "should have caught_something?" do
122
122
  @model.caught_something?.should be true
123
123
  end
@@ -139,7 +139,7 @@ describe MolassesJar do
139
139
  it "should return false for spam?" do
140
140
  @model.spam?.should be (false || nil)
141
141
  end
142
-
142
+
143
143
  it "should not have caught_something?" do
144
144
  @model.caught_something?.should be false
145
145
  end
metadata CHANGED
@@ -1,160 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: molasses_jar
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - mindtonic
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-08-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: activesupport
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '3.0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
30
- - !ruby/object:Gem::Dependency
31
- name: activerecord
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '3.0'
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 7
29
+ segments:
30
+ - 3
31
+ - 0
32
+ version: "3.0"
38
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: activerecord
39
37
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '3.0'
46
- - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 3
46
+ - 0
47
+ version: "3.0"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
47
51
  name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
52
  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: shoulda
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
70
62
  type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: shoulda
71
66
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: rdoc
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
86
76
  type: :development
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
87
80
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: bundler
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
102
90
  type: :development
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: bundler
103
94
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: jeweler
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
118
104
  type: :development
105
+ version_requirements: *id006
106
+ - !ruby/object:Gem::Dependency
107
+ name: jeweler
119
108
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: sqlite3
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
109
+ requirement: &id007 !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
134
118
  type: :development
119
+ version_requirements: *id007
120
+ - !ruby/object:Gem::Dependency
121
+ name: sqlite3
135
122
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- description: A honeypot style captcha extension for ActiveRecord. Simple one-line
143
- inclusion in the model combined with a simple form field should trap the bad guys
144
- in the molasses.
123
+ requirement: &id008 !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ hash: 3
129
+ segments:
130
+ - 0
131
+ version: "0"
132
+ type: :development
133
+ version_requirements: *id008
134
+ description: A honeypot style captcha extension for ActiveRecord. Simple one-line inclusion in the model combined with a simple form field should trap the bad guys in the molasses.
145
135
  email: mindtonic@gmail.com
146
136
  executables: []
137
+
147
138
  extensions: []
148
- extra_rdoc_files:
139
+
140
+ extra_rdoc_files:
149
141
  - LICENSE.txt
150
142
  - README.md
151
- files:
143
+ files:
152
144
  - .document
153
145
  - Gemfile
154
146
  - LICENSE.txt
155
147
  - README.md
156
148
  - Rakefile
157
- - VERSION
158
149
  - lib/molasses_jar.rb
159
150
  - lib/molasses_jar/extensions.rb
160
151
  - lib/molasses_jar/helpers.rb
@@ -162,31 +153,37 @@ files:
162
153
  - spec/molasses_jar_spec.rb
163
154
  - spec/spec_helper.rb
164
155
  homepage: http://github.com/mindtonic/molasses_jar
165
- licenses:
156
+ licenses:
166
157
  - BEER
167
158
  post_install_message:
168
159
  rdoc_options: []
169
- require_paths:
160
+
161
+ require_paths:
170
162
  - lib
171
- required_ruby_version: !ruby/object:Gem::Requirement
163
+ required_ruby_version: !ruby/object:Gem::Requirement
172
164
  none: false
173
- requirements:
174
- - - ! '>='
175
- - !ruby/object:Gem::Version
176
- version: '0'
177
- segments:
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
178
170
  - 0
179
- hash: -4059900841103394163
180
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ version: "0"
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
173
  none: false
182
- requirements:
183
- - - ! '>='
184
- - !ruby/object:Gem::Version
185
- version: '0'
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 3
178
+ segments:
179
+ - 0
180
+ version: "0"
186
181
  requirements: []
182
+
187
183
  rubyforge_project:
188
184
  rubygems_version: 1.8.24
189
185
  signing_key:
190
186
  specification_version: 3
191
187
  summary: A honeypot style captcha extension for ActiveRecord
192
188
  test_files: []
189
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.3