spamtrap 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,16 +1,19 @@
1
- module Spamtrap
1
+ module Spamtrap::Controller
2
2
 
3
3
  def self.included(base)
4
4
  base.extend ActsAsMethods
5
5
  end
6
6
 
7
7
  module ActsAsMethods
8
- def spamtrap(actions, parameter='spamtrap')
8
+ def spamtrap(actions, honeypot='spamtrap', &block)
9
9
  actions = [actions] unless actions.is_a?(Array)
10
10
  raise 'Spamtrap must have actions defined.' if actions.empty?
11
11
  before_filter(:only => actions) do |controller|
12
+ if block_given?
13
+ controller.instance_eval(&block)
14
+ end
12
15
  controller.instance_eval do
13
- if params[parameter.to_s].present?
16
+ if params[honeypot].present?
14
17
  Rails.logger.warn "Spamtrap triggered by #{request.remote_ip}."
15
18
  render :nothing => true, :status => 200
16
19
  end
@@ -21,4 +24,4 @@ module Spamtrap
21
24
 
22
25
  end
23
26
 
24
- ActionController::Base.send :include, Spamtrap
27
+ ActionController::Base.send :include, Spamtrap::Controller
@@ -1,9 +1,6 @@
1
1
  class ActionView::Helpers::FormBuilder
2
2
  def spamtrap(parameter='spamtrap', options={})
3
- options.reverse_merge({:class => 'spamtrap'})
4
- @template.content_tag(:div, options) do
5
- @template.label_tag(parameter) +
6
- @template.text_field_tag(parameter)
7
- end
3
+ options.reverse_merge!({:class => 'spamtrap'})
4
+ @template.text_area_tag(parameter, nil, options)
8
5
  end
9
6
  end
@@ -1,5 +1,5 @@
1
1
  module Spamtrap
2
2
 
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
 
5
5
  end
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class ControllerTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_foobar
12
+ assert true
13
+ assert_equal "hello", "hello"
14
+ end
15
+
16
+ end
@@ -0,0 +1,12 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ $: << File.join(File.dirname(__FILE__))
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ # require 'active_support'
7
+ require 'action_controller'
8
+ # require 'action_controller/test_case'
9
+ # require 'action_view'
10
+ # require 'active_record'
11
+ # require 'ruby-debug'
12
+ require 'spamtrap'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spamtrap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
4
+ hash: 21
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Cedric Howe
@@ -15,23 +15,24 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-26 00:00:00 -04:00
18
+ date: 2011-08-10 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
27
+ hash: 5
30
28
  segments:
31
- - 0
32
- version: "0"
29
+ - 2
30
+ - 3
31
+ version: "2.3"
32
+ name: rails
33
33
  type: :runtime
34
- version_requirements: *id001
34
+ prerelease: false
35
+ requirement: *id001
35
36
  description: Create bogus form fields (honeypots) that will be filled-in by spambots. When submitted, the form data will be discarded while still returning a 200 response.
36
37
  email: cedric@freezerbox.com
37
38
  executables: []
@@ -45,6 +46,8 @@ files:
45
46
  - lib/spamtrap/helper.rb
46
47
  - lib/spamtrap/version.rb
47
48
  - lib/spamtrap.rb
49
+ - test/controller_test.rb
50
+ - test/test_helper.rb
48
51
  has_rdoc: true
49
52
  homepage: http://github.com/cedric/spamtrap/
50
53
  licenses: []
@@ -68,16 +71,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
71
  requirements:
69
72
  - - ">="
70
73
  - !ruby/object:Gem::Version
71
- hash: 3
74
+ hash: 23
72
75
  segments:
73
- - 0
74
- version: "0"
76
+ - 1
77
+ - 3
78
+ - 6
79
+ version: 1.3.6
75
80
  requirements: []
76
81
 
77
82
  rubyforge_project: spamtrap
78
- rubygems_version: 1.3.7
83
+ rubygems_version: 1.6.2
79
84
  signing_key:
80
85
  specification_version: 3
81
86
  summary: Simple spamtrap for spambots.
82
- test_files: []
83
-
87
+ test_files:
88
+ - test/controller_test.rb
89
+ - test/test_helper.rb