despamilator_rails 1.0
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/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +51 -0
- data/History.txt +7 -0
- data/Manifest.txt +15 -0
- data/README.rdoc +92 -0
- data/Rakefile +30 -0
- data/despamilator-rails.gemspec +39 -0
- data/lib/despamilator_rails.rb +103 -0
- data/spec/active_record_integration_spec.rb +8 -0
- data/spec/despamilator_rails_spec.rb +120 -0
- data/spec/fixtures/active_record_test_class.rb +5 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/test_db_migrations/create_test_model_table.rb +10 -0
- metadata +125 -0
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use 1.9.2@despamilator-rails
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# A sample Gemfile
|
2
|
+
source "http://rubygems.org"
|
3
|
+
|
4
|
+
gem 'hoe', '>= 2.7.0'
|
5
|
+
gem 'newgem', '>= 1.5.3'
|
6
|
+
gem 'activesupport', '>= 2.3.10'
|
7
|
+
|
8
|
+
# while we're fetching from git, we need to execute everything with 'bundle exec'
|
9
|
+
#gem 'despamilator', :git => 'git://github.com/moowahaha/despamilator.git'
|
10
|
+
gem 'despamilator', '>= 1.0'
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'rspec', '>= 2.4.0'
|
14
|
+
gem 'sqlite3', '>= 0.1.1'
|
15
|
+
gem 'activerecord', '>= 2.3.10'
|
16
|
+
gem 'one_hundred_percent_coverage'
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
RedCloth (4.2.3)
|
5
|
+
activerecord (2.3.10)
|
6
|
+
activesupport (= 2.3.10)
|
7
|
+
activesupport (2.3.10)
|
8
|
+
despamilator (1.0)
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
ffi (1.0.4)
|
11
|
+
rake (>= 0.8.7)
|
12
|
+
hoe (2.8.0)
|
13
|
+
rake (>= 0.8.7)
|
14
|
+
newgem (1.5.3)
|
15
|
+
RedCloth (>= 4.1.1)
|
16
|
+
activesupport (~> 2.3.4)
|
17
|
+
hoe (>= 2.4.0)
|
18
|
+
rubigen (>= 1.5.3)
|
19
|
+
syntax (>= 1.0.0)
|
20
|
+
one_hundred_percent_coverage (0.0.2)
|
21
|
+
simplecov (>= 0.3.7)
|
22
|
+
rake (0.8.7)
|
23
|
+
rspec (2.4.0)
|
24
|
+
rspec-core (~> 2.4.0)
|
25
|
+
rspec-expectations (~> 2.4.0)
|
26
|
+
rspec-mocks (~> 2.4.0)
|
27
|
+
rspec-core (2.4.0)
|
28
|
+
rspec-expectations (2.4.0)
|
29
|
+
diff-lcs (~> 1.1.2)
|
30
|
+
rspec-mocks (2.4.0)
|
31
|
+
rubigen (1.5.5)
|
32
|
+
activesupport (~> 2.3.5)
|
33
|
+
simplecov (0.3.7)
|
34
|
+
simplecov-html (>= 0.3.7)
|
35
|
+
simplecov-html (0.3.9)
|
36
|
+
sqlite3 (0.1.1)
|
37
|
+
ffi (>= 0.6.3)
|
38
|
+
syntax (1.0.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
activerecord (>= 2.3.10)
|
45
|
+
activesupport (>= 2.3.10)
|
46
|
+
despamilator (>= 1.0)
|
47
|
+
hoe (>= 2.7.0)
|
48
|
+
newgem (>= 1.5.3)
|
49
|
+
one_hundred_percent_coverage
|
50
|
+
rspec (>= 2.4.0)
|
51
|
+
sqlite3 (>= 0.1.1)
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
.rspec
|
2
|
+
.rvmrc
|
3
|
+
Gemfile
|
4
|
+
Gemfile.lock
|
5
|
+
History.txt
|
6
|
+
Manifest.txt
|
7
|
+
README.rdoc
|
8
|
+
Rakefile
|
9
|
+
despamilator-rails.gemspec
|
10
|
+
lib/despamilator_rails.rb
|
11
|
+
spec/active_record_integration_spec.rb
|
12
|
+
spec/despamilator_rails_spec.rb
|
13
|
+
spec/fixtures/active_record_test_class.rb
|
14
|
+
spec/spec_helper.rb
|
15
|
+
spec/test_db_migrations/create_test_model_table.rb
|
data/README.rdoc
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
= despamilator_rails
|
2
|
+
|
3
|
+
* https://github.com/moowahaha/despamilator-rails
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Spam detection plugin for Rails & ActiveRecord. Uses all the standard Rails conventions and
|
8
|
+
my Despamilator gem.
|
9
|
+
|
10
|
+
== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* To fix the iconv error when developing with Ruby 1.9.2 and RVM,
|
13
|
+
see: http://blog.footle.org/2010/07/29/installing-ruby-1-9-2-via-rvm-on-os-x/ .
|
14
|
+
|
15
|
+
* Stuck with lower version of ActiveRecord in Gemfile until Hoe is fixed to support
|
16
|
+
newer versions.
|
17
|
+
|
18
|
+
* DataMapper not yet supported. That's on the list!
|
19
|
+
|
20
|
+
|
21
|
+
== SYNOPSIS:
|
22
|
+
|
23
|
+
Somewhere (such as your environment.rb...)
|
24
|
+
|
25
|
+
require 'despamilator_rails'
|
26
|
+
|
27
|
+
In your model (basic example):
|
28
|
+
|
29
|
+
class YourModel < ActiveRecord::Base
|
30
|
+
validate_with_despamilator :attributes => [:some_field]
|
31
|
+
end
|
32
|
+
|
33
|
+
When "some_field" is assigned a spammy value, it will add to the errors. For example...
|
34
|
+
|
35
|
+
YourModel.new(:some_field => spammy_value).save! #=> ActiveRecord::RecordInvalid exception!
|
36
|
+
|
37
|
+
Or...
|
38
|
+
|
39
|
+
your_instance = YourModel.new(:some_field => spammy_value)
|
40
|
+
your_instance.save
|
41
|
+
your_instance.errors.full_messages.should #=> ["Some field looks like spam"]
|
42
|
+
|
43
|
+
If you want to configure the threshold (which defaults to 1) or add your own callback, you can do the following:
|
44
|
+
|
45
|
+
class YourModel < ActiveRecord::Base
|
46
|
+
validate_with_despamilator :attributes => [:some_field], :threshold => 1 do |field, value, despamilator|
|
47
|
+
raise "spam! field: #{field}, value: #{value}, score: #{despamailtor.score}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
This example will...
|
52
|
+
|
53
|
+
your_instance = YourModel.new(:some_field => "spammy string")
|
54
|
+
your_instance.save! #=> Exception "spam! field: some_field, value: spammy string, score: 123"
|
55
|
+
|
56
|
+
The callback will receive the field name, the value and the instance of the Despamilator class.
|
57
|
+
|
58
|
+
See the various examples in "spec/fixtures".
|
59
|
+
|
60
|
+
== REQUIREMENTS:
|
61
|
+
|
62
|
+
* ActiveRecord >= 2.3.2
|
63
|
+
* Despamilator >= 1.0
|
64
|
+
|
65
|
+
== INSTALL:
|
66
|
+
|
67
|
+
* gem install despamilator_rails
|
68
|
+
|
69
|
+
== LICENSE:
|
70
|
+
|
71
|
+
(The MIT License)
|
72
|
+
|
73
|
+
Copyright (c) 2011 Stephen Hardisty
|
74
|
+
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
76
|
+
a copy of this software and associated documentation files (the
|
77
|
+
'Software'), to deal in the Software without restriction, including
|
78
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
79
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
80
|
+
permit persons to whom the Software is furnished to do so, subject to
|
81
|
+
the following conditions:
|
82
|
+
|
83
|
+
The above copyright notice and this permission notice shall be
|
84
|
+
included in all copies or substantial portions of the Software.
|
85
|
+
|
86
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
87
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
88
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
89
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
90
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
91
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
92
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/despamilator_rails'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
|
9
|
+
$hoe = Hoe.spec 'despamilator_rails' do
|
10
|
+
self.developer 'Stephen Hardisty', 'moowahaha@hotmail.com'
|
11
|
+
self.rubyforge_name = self.name
|
12
|
+
self.extra_deps = [['despamilator','>= 1.0'], ['activesupport', '>= 2.3.2']]
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'newgem/tasks'
|
16
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
17
|
+
|
18
|
+
task :default => [:spec]
|
19
|
+
task :test => [:spec]
|
20
|
+
|
21
|
+
desc "Generate appropriate rdoc"
|
22
|
+
task :rdoc do
|
23
|
+
sh "rdoc README.rdoc lib/despamilator_rails.rb"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :cultivate do
|
27
|
+
sh "rm -f *.sqlite3"
|
28
|
+
sh "touch Manifest.txt; rake check_manifest |grep -v \"(in \" | patch"
|
29
|
+
sh "rake debug_gem | grep -v \"(in \" > `basename \\`pwd\\``.gemspec"
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{despamilator_rails}
|
5
|
+
s.version = "1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Stephen Hardisty"]
|
9
|
+
s.date = %q{2011-01-09}
|
10
|
+
s.description = %q{FIX (describe your package)}
|
11
|
+
s.email = ["moowahaha@hotmail.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
13
|
+
s.files = [".rspec", ".rvmrc", "Gemfile", "Gemfile.lock", "History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "despamilator-rails.gemspec", "lib/despamilator_rails.rb", "spec/active_record_integration_spec.rb", "spec/despamilator_rails_spec.rb", "spec/fixtures/active_record_test_class.rb", "spec/spec_helper.rb", "spec/test_db_migrations/create_test_model_table.rb"]
|
14
|
+
s.homepage = %q{https://github.com/moowahaha/despamilator-rails}
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{despamilator_rails}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{FIX (describe your package)}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<despamilator>, [">= 1.0"])
|
27
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
|
28
|
+
s.add_development_dependency(%q<hoe>, [">= 2.8.0"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<despamilator>, [">= 1.0"])
|
31
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
32
|
+
s.add_dependency(%q<hoe>, [">= 2.8.0"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<despamilator>, [">= 1.0"])
|
36
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
37
|
+
s.add_dependency(%q<hoe>, [">= 2.8.0"])
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'despamilator'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
module DespamilatorRails
|
6
|
+
VERSION = "1.0"
|
7
|
+
end
|
8
|
+
|
9
|
+
module ActiveRecord
|
10
|
+
|
11
|
+
class Base
|
12
|
+
|
13
|
+
# Somewhere (such as your environment.rb...)
|
14
|
+
#
|
15
|
+
# require 'despamilator_rails'
|
16
|
+
#
|
17
|
+
# In your model (basic example):
|
18
|
+
#
|
19
|
+
# class YourModel < ActiveRecord::Base
|
20
|
+
# validate_with_despamilator :attributes => [:some_field]
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# When "some_field" is assigned a spammy value, it will add to the errors. For example...
|
24
|
+
#
|
25
|
+
# YourModel.new(:some_field => spammy_value).save! #=> ActiveRecord::RecordInvalid exception!
|
26
|
+
#
|
27
|
+
# Or...
|
28
|
+
#
|
29
|
+
# your_instance = YourModel.new(:some_field => spammy_value)
|
30
|
+
# your_instance.save
|
31
|
+
# your_instance.errors.full_messages.should #=> ["Some field looks like spam"]
|
32
|
+
#
|
33
|
+
# If you want to configure the threshold (which defaults to 1) or add your own callback, you can do the following:
|
34
|
+
#
|
35
|
+
# class YourModel < ActiveRecord::Base
|
36
|
+
# validate_with_despamilator :attributes => [:some_field], :threshold => 1 do |field, value, despamilator|
|
37
|
+
# raise "spam! field: #{field}, value: #{value}, score: #{despamailtor.score}"
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# This example will...
|
42
|
+
#
|
43
|
+
# your_instance = YourModel.new(:some_field => "spammy string")
|
44
|
+
# your_instance.save! #=> Exception "spam! field: some_field, value: spammy string, score: 123"
|
45
|
+
#
|
46
|
+
# The callback will receive the field name, the value and the instance of the Despamilator class.
|
47
|
+
|
48
|
+
def self.validate_with_despamilator settings, &block
|
49
|
+
assign_despamilator_attributes settings
|
50
|
+
assign_despamilator_threshold settings
|
51
|
+
assign_despamilator_callback block
|
52
|
+
|
53
|
+
add_despamilator_validation settings
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
class << self
|
59
|
+
|
60
|
+
def add_despamilator_validation settings
|
61
|
+
|
62
|
+
send(validation_method(:save), settings) do |record|
|
63
|
+
|
64
|
+
record.despamilator_checked_attributes.each do |attribute|
|
65
|
+
text = record.send(attribute)
|
66
|
+
dspam = Despamilator.new(text)
|
67
|
+
|
68
|
+
record.despamilator_callback(attribute, text, dspam) if dspam.score >= record.despamilator_threshold
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def assign_despamilator_attributes(settings)
|
76
|
+
clean_attributes = settings[:attributes].reject do |attribute|
|
77
|
+
attribute.blank?
|
78
|
+
end
|
79
|
+
|
80
|
+
raise('At least one attribute must be defined') if clean_attributes.empty?
|
81
|
+
|
82
|
+
define_method(:despamilator_checked_attributes, lambda { clean_attributes })
|
83
|
+
end
|
84
|
+
|
85
|
+
def assign_despamilator_threshold(settings)
|
86
|
+
define_method(:despamilator_threshold, lambda { settings[:threshold] || 1 })
|
87
|
+
end
|
88
|
+
|
89
|
+
def assign_despamilator_callback(block)
|
90
|
+
define_method(:despamilator_callback, block || default_despamilator_detection_response)
|
91
|
+
end
|
92
|
+
|
93
|
+
def default_despamilator_detection_response
|
94
|
+
lambda { |attribute, value, dspam|
|
95
|
+
errors.add(attribute, "looks like spam")
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
describe "despamilator_rails" do
|
2
|
+
|
3
|
+
it "should notify of spam detection in a railsy way" do
|
4
|
+
|
5
|
+
class SomeModelWithSpam < ActiveRecord::Base
|
6
|
+
set_table_name 'some_models'
|
7
|
+
validate_with_despamilator :attributes => [:some_field]
|
8
|
+
end
|
9
|
+
|
10
|
+
some_model = SomeModelWithSpam.new
|
11
|
+
some_model.some_field = Despamilator.gtubs_test_string
|
12
|
+
|
13
|
+
-> {some_model.save!}.should raise_error(ActiveRecord::RecordInvalid)
|
14
|
+
some_model.errors.full_messages.should == ["Some field looks like spam"]
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "threshold" do
|
18
|
+
|
19
|
+
it "should default to 1" do
|
20
|
+
|
21
|
+
class SomeModelWithDefaultThreshold < ActiveRecord::Base
|
22
|
+
set_table_name 'some_models'
|
23
|
+
validate_with_despamilator :attributes => [:some_field]
|
24
|
+
end
|
25
|
+
|
26
|
+
some_model = SomeModelWithDefaultThreshold.new
|
27
|
+
some_model.despamilator_threshold.should == 1
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should be settable" do
|
31
|
+
|
32
|
+
class SomeModelWithDefinedThreshold < ActiveRecord::Base
|
33
|
+
set_table_name 'some_models'
|
34
|
+
validate_with_despamilator :attributes => [:some_field], :threshold => 9
|
35
|
+
end
|
36
|
+
|
37
|
+
some_model = SomeModelWithDefinedThreshold.new
|
38
|
+
some_model.despamilator_threshold.should == 9
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "attributes" do
|
45
|
+
|
46
|
+
it "should cause an exception when an empty array is passed" do
|
47
|
+
|
48
|
+
->{
|
49
|
+
class SomeModelWithMissingAttributes < ActiveRecord::Base
|
50
|
+
validate_with_despamilator :attributes => []
|
51
|
+
end
|
52
|
+
}.should raise_error('At least one attribute must be defined')
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should cause an exception when an empty string is passed" do
|
57
|
+
|
58
|
+
-> {
|
59
|
+
class SomeModelWithEmptyAttributes < ActiveRecord::Base
|
60
|
+
validate_with_despamilator :attributes => ['']
|
61
|
+
end
|
62
|
+
}.should raise_error('At least one attribute must be defined')
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should allow a block to be specified" do
|
69
|
+
|
70
|
+
class SomeModelWithABlock < ActiveRecord::Base
|
71
|
+
set_table_name 'some_models'
|
72
|
+
|
73
|
+
def do_something field, value, despamilator
|
74
|
+
end
|
75
|
+
|
76
|
+
validate_with_despamilator :attributes => [:some_field] do |field, value, despamilator|
|
77
|
+
do_something(field, value, despamilator)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
fake_despamilator = mock('despamilator')
|
82
|
+
Despamilator.should_receive(:new).and_return(fake_despamilator)
|
83
|
+
fake_despamilator.should_receive(:score).and_return(10000)
|
84
|
+
|
85
|
+
some_model = SomeModelWithABlock.new
|
86
|
+
some_model.should_receive(:do_something).with(:some_field, 'blah', fake_despamilator)
|
87
|
+
some_model.some_field = 'blah'
|
88
|
+
some_model.save
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should work nicely with other validate methods" do
|
93
|
+
class SomeModelWithAnotherValidate < ActiveRecord::Base
|
94
|
+
set_table_name 'some_models'
|
95
|
+
|
96
|
+
validate_with_despamilator :attributes => [:some_field] do |field, value, despamilator|
|
97
|
+
do_something
|
98
|
+
end
|
99
|
+
|
100
|
+
def do_something
|
101
|
+
end
|
102
|
+
|
103
|
+
def do_something_else
|
104
|
+
end
|
105
|
+
|
106
|
+
def validate
|
107
|
+
do_something_else
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
some_model = SomeModelWithAnotherValidate.new
|
113
|
+
some_model.should_receive(:do_something)
|
114
|
+
some_model.should_receive(:do_something_else)
|
115
|
+
some_model.some_field = Despamilator.gtubs_test_string
|
116
|
+
some_model.save
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'one_hundred_percent_coverage'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'despamilator_rails')
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'test_db_migrations', '*.rb')).each do |file|
|
6
|
+
require file
|
7
|
+
end
|
8
|
+
|
9
|
+
db_file = 'test.sqlite3'
|
10
|
+
|
11
|
+
File.unlink(db_file) if File.exists?(db_file)
|
12
|
+
|
13
|
+
ActiveRecord::Base.establish_connection(
|
14
|
+
:adapter => 'sqlite3',
|
15
|
+
:database => db_file
|
16
|
+
)
|
17
|
+
|
18
|
+
CreateSomeModel.migrate(:up)
|
19
|
+
|
20
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'fixtures', '*.rb')).each do |file|
|
21
|
+
require file
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: despamilator_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
version: "1.0"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Stephen Hardisty
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-01-09 00:00:00 +11:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: despamilator
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
version: "1.0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 3
|
44
|
+
- 2
|
45
|
+
version: 2.3.2
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: hoe
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 2
|
58
|
+
- 8
|
59
|
+
- 0
|
60
|
+
version: 2.8.0
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: |-
|
64
|
+
Spam detection plugin for Rails & ActiveRecord. Uses all the standard Rails conventions and
|
65
|
+
my Despamilator gem.
|
66
|
+
email:
|
67
|
+
- moowahaha@hotmail.com
|
68
|
+
executables: []
|
69
|
+
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files:
|
73
|
+
- History.txt
|
74
|
+
- Manifest.txt
|
75
|
+
files:
|
76
|
+
- .rspec
|
77
|
+
- .rvmrc
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- History.txt
|
81
|
+
- Manifest.txt
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- despamilator-rails.gemspec
|
85
|
+
- lib/despamilator_rails.rb
|
86
|
+
- spec/active_record_integration_spec.rb
|
87
|
+
- spec/despamilator_rails_spec.rb
|
88
|
+
- spec/fixtures/active_record_test_class.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/test_db_migrations/create_test_model_table.rb
|
91
|
+
has_rdoc: true
|
92
|
+
homepage: https://github.com/moowahaha/despamilator-rails
|
93
|
+
licenses: []
|
94
|
+
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options:
|
97
|
+
- --main
|
98
|
+
- README.rdoc
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
requirements: []
|
118
|
+
|
119
|
+
rubyforge_project: despamilator_rails
|
120
|
+
rubygems_version: 1.3.7
|
121
|
+
signing_key:
|
122
|
+
specification_version: 3
|
123
|
+
summary: Spam detection plugin for Rails & ActiveRecord
|
124
|
+
test_files: []
|
125
|
+
|