green_eggs_and_spam 0.2.0 → 0.2.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.md CHANGED
@@ -15,7 +15,7 @@ Install the gem just like you would any other:
15
15
 
16
16
  # or with bundler
17
17
 
18
- gem 'green_eggs_and_spam', '>= 0.2.0'
18
+ gem 'green_eggs_and_spam', '>= 0.2.1'
19
19
 
20
20
 
21
21
  Create a handful of color coded images and name them something other than their color or design. `1.png`, `banana.png` or `firetruck.png` for example. Tell GreenEggsandSpam which ones which with an initializer:
@@ -53,18 +53,21 @@ Chances are your form is interacting with a model. If that's the case, hook up t
53
53
 
54
54
  validates_anti_spam
55
55
 
56
+ # with options
57
+ # validates_anti_spam :on => :create, :unless => proc{|r| # some logic }
58
+
56
59
  end
57
60
 
58
61
 
59
62
 
63
+
64
+
60
65
  Next, setup your controller with the `has_anti_spam` method. This will prepare the controller and give you access to the helper methods.
61
66
 
62
67
  class EggsController < ApplicationController
63
68
 
64
69
  has_anti_spam
65
70
 
66
- ...
67
-
68
71
  def create
69
72
 
70
73
  # merge the antispam params into your model's params before validation
@@ -90,12 +93,8 @@ But what if my form isn't validating a model? No big deal, just use the `anti_sp
90
93
 
91
94
  has_anti_spam
92
95
 
93
- ...
94
-
95
- # merge the antispam params into your model's params before validation
96
96
  def create
97
97
 
98
- # validate with the anti spam helper method
99
98
  if anti_spam_valid?
100
99
  # do something
101
100
  end
@@ -121,11 +120,10 @@ So you're using `.gif`'s or you're images aren't stored in `/images/antispam`. H
121
120
  :extension => 'jpg'
122
121
  }
123
122
 
124
- # usage
123
+ # inline
125
124
  anti_spam_form, "Your custom color question?", { :extension => 'png', :path => '/images' }
126
125
 
127
126
  # or set globally in your initializer
128
-
129
127
  GreenEggsAndSpam.options[:form_options] = { :extension => 'png', :path => '/images' }
130
128
 
131
129
 
@@ -155,15 +153,7 @@ Tests can be run with `rake test` or just `rake`.
155
153
  rake
156
154
 
157
155
 
158
-
159
- To Do
160
- -----
161
-
162
- * Write more tests
163
- * Write more documentation
164
- * Include default images
165
-
166
-
156
+
167
157
  License
168
158
  -------
169
159
 
@@ -12,10 +12,10 @@ module GreenEggsAndSpam
12
12
  module ClassMethods
13
13
 
14
14
  # Installs GreenEggsAndSpam's validation functionality into the supplied model
15
- def validates_anti_spam
15
+ def validates_anti_spam(options={})
16
16
  self.class_eval do
17
17
  attr_accessor :antispam
18
- validates_with GreenEggsAndSpam::AntiSpamValidator
18
+ validates_with GreenEggsAndSpam::AntiSpamValidator, options
19
19
  end
20
20
  end
21
21
 
@@ -1,3 +1,3 @@
1
1
  module GreenEggsAndSpam
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,13 @@
1
+ require 'helper'
2
+
3
+ class TestActiveRecord < MiniTest::Unit::TestCase
4
+
5
+ should "ensure active record includes module" do
6
+ assert ActiveRecord::Base.included_modules.include?(GreenEggsAndSpam::ActiveRecord)
7
+ end
8
+
9
+ should "respond to validates_anti_spam" do
10
+ assert ActiveRecord::Base.respond_to?(:validates_anti_spam)
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: green_eggs_and_spam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-08 00:00:00.000000000Z
12
+ date: 2011-11-09 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2157479080 !ruby/object:Gem::Requirement
16
+ requirement: &2156014280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157479080
24
+ version_requirements: *2156014280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &2157478320 !ruby/object:Gem::Requirement
27
+ requirement: &2156013780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157478320
35
+ version_requirements: *2156013780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest_should
38
- requirement: &2157477800 !ruby/object:Gem::Requirement
38
+ requirement: &2156013260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157477800
46
+ version_requirements: *2156013260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2157477340 !ruby/object:Gem::Requirement
49
+ requirement: &2156012700 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 1.3.3
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157477340
57
+ version_requirements: *2156012700
58
58
  description: ! 'Green eggs and spam presents the user with a simple question: What
59
59
  color is this image? You''ll supply the images and a key of which one''s which,
60
60
  and the gem will help with the rest.'
@@ -120,6 +120,7 @@ files:
120
120
  - test/dummy/public/images/named/ocean.png
121
121
  - test/dummy/script/rails
122
122
  - test/helper.rb
123
+ - test/test_active_record.rb
123
124
  - test/test_green_eggs_and_ham.rb
124
125
  - test/test_options.rb
125
126
  homepage: https://github.com/citrus/green_eggs_and_spam
@@ -187,5 +188,6 @@ test_files:
187
188
  - test/dummy/public/images/named/ocean.png
188
189
  - test/dummy/script/rails
189
190
  - test/helper.rb
191
+ - test/test_active_record.rb
190
192
  - test/test_green_eggs_and_ham.rb
191
193
  - test/test_options.rb