acts_as_abusable 0.0.2
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/MIT-LICENSE +20 -0
- data/README.markdown +72 -0
- data/Rakefile +22 -0
- data/acts_as_abusable.gemspec +22 -0
- data/generators/acts_as_abusable_migration/acts_as_abusable_migration_generator.rb +11 -0
- data/generators/acts_as_abusable_migration/templates/migration.rb +20 -0
- data/init.rb +1 -0
- data/lib/abuse.rb +9 -0
- data/lib/acts_as_abusable.rb +39 -0
- data/tasks/acts_as_abusable_tasks.rake +4 -0
- data/test/acts_as_abusable_test.rb +8 -0
- metadata +69 -0
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
acts\_as\_abusable
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
* Traditionally
|
|
10
|
+
|
|
11
|
+
<pre>
|
|
12
|
+
script/plugin install git://github.com/linkingpaths/acts_as_abusable.git
|
|
13
|
+
</pre>
|
|
14
|
+
|
|
15
|
+
* Gemplugin:
|
|
16
|
+
|
|
17
|
+
If you prefer the new "gemplugin" management system just insert the dependency on environment.rb:
|
|
18
|
+
<pre>
|
|
19
|
+
config.gem "linkingpaths-acts_as_abusable", :lib => "acts_as_abusable"
|
|
20
|
+
</pre>
|
|
21
|
+
... and install it:
|
|
22
|
+
<pre>
|
|
23
|
+
rake gems:install
|
|
24
|
+
</pre>
|
|
25
|
+
|
|
26
|
+
* Finally use the builtin generator for the needed migration:
|
|
27
|
+
|
|
28
|
+
<pre>
|
|
29
|
+
script/generate acts_as_abusable_migration
|
|
30
|
+
rake db:migrate
|
|
31
|
+
</pre>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Example
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
<pre>
|
|
38
|
+
class Photo < ActiveRecord::Base
|
|
39
|
+
acts_as_abusable
|
|
40
|
+
end
|
|
41
|
+
</pre>
|
|
42
|
+
|
|
43
|
+
This gives you:
|
|
44
|
+
|
|
45
|
+
<pre>
|
|
46
|
+
# All abuse reports about this photo
|
|
47
|
+
penthouse_sweetie_photo.reported_abuses
|
|
48
|
+
|
|
49
|
+
# Positive abuses
|
|
50
|
+
penthouse_sweetie_photo.reported_abuses.confirmed
|
|
51
|
+
|
|
52
|
+
# Still not evaluated abuse reports
|
|
53
|
+
penthouse_sweetie_photo.reported_abuses.pending
|
|
54
|
+
|
|
55
|
+
# Check if this photo has been positively marked as an abuse.
|
|
56
|
+
penthouse_sweetie_photo.is_an_abuse?
|
|
57
|
+
</pre>
|
|
58
|
+
|
|
59
|
+
And a new ´Abuse´ model:
|
|
60
|
+
|
|
61
|
+
<pre>
|
|
62
|
+
abuse.confirmed?
|
|
63
|
+
abuse.confirm!
|
|
64
|
+
|
|
65
|
+
# URL used as base for the abuse report
|
|
66
|
+
abuse.referer
|
|
67
|
+
|
|
68
|
+
# Resource that is linked to the abuse report
|
|
69
|
+
abuse.resource
|
|
70
|
+
</pre>
|
|
71
|
+
|
|
72
|
+
Copyright (c) 2008 Linking Paths, released under the MIT license
|
data/Rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'rake/rdoctask'
|
|
4
|
+
|
|
5
|
+
desc 'Default: run unit tests.'
|
|
6
|
+
task :default => :test
|
|
7
|
+
|
|
8
|
+
desc 'Test the acts_as_abusable plugin.'
|
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
|
10
|
+
t.libs << 'lib'
|
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
|
12
|
+
t.verbose = true
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc 'Generate documentation for the acts_as_abusable plugin.'
|
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
18
|
+
rdoc.title = 'ActsAsAbusable'
|
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
|
20
|
+
rdoc.rdoc_files.include('README')
|
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
22
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = %q{acts_as_abusable}
|
|
3
|
+
s.version = "0.0.2"
|
|
4
|
+
|
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
6
|
+
s.authors = ["Linking Paths"]
|
|
7
|
+
s.date = %q{2008-10-04}
|
|
8
|
+
s.description = %q{Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.}
|
|
9
|
+
s.email = ["aitor@linkingpaths.com"]
|
|
10
|
+
s.files = ["MIT-LICENSE", "README.markdown", "Rakefile", "acts_as_abusable.gemspec", "generators", "generators/acts_as_abusable_migration", "generators/acts_as_abusable_migration/acts_as_abusable_migration_generator.rb", "generators/acts_as_abusable_migration/templates", "generators/acts_as_abusable_migration/templates/migration.rb", "init.rb", "lib", "lib/abuse.rb", "lib/acts_as_abusable.rb", "tasks", "tasks/acts_as_abusable_tasks.rake", "test", "test/acts_as_abusable_test.rb"]
|
|
11
|
+
s.has_rdoc = true
|
|
12
|
+
s.homepage = %q{http://github.com/linkingpaths/acts_as_abusable}
|
|
13
|
+
s.post_install_message = %q{
|
|
14
|
+
For more information on acts_as_abusable, see http://github.com/linkingpaths/acts_as_abusable
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
s.rubyforge_project = %q{acts_as_abusable}
|
|
19
|
+
s.rubygems_version = %q{1.2.0}
|
|
20
|
+
s.summary = %q{Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.}
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class ActsAsAbusableMigration < ActiveRecord::Migration
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :abuses do |t|
|
|
5
|
+
t.column :email, :string
|
|
6
|
+
t.column :title, :string
|
|
7
|
+
t.column :referer, :string
|
|
8
|
+
t.column :description, :string
|
|
9
|
+
t.column :confirmed, :boolean, :default => false
|
|
10
|
+
t.column :resource_id, :integer
|
|
11
|
+
t.column :resource_type, :string
|
|
12
|
+
t.column :created_at, :datetime
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.down
|
|
17
|
+
drop_table :abuses
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
data/init.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "acts_as_abusable"
|
data/lib/abuse.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'abuse'
|
|
2
|
+
|
|
3
|
+
module LinkingPaths
|
|
4
|
+
module Acts #:nodoc:
|
|
5
|
+
module Abusable #:nodoc:
|
|
6
|
+
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.extend ClassMethods
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module ClassMethods
|
|
12
|
+
def acts_as_abusable
|
|
13
|
+
has_many :reported_abuses, :class_name => 'Abuse', :as => :resource do
|
|
14
|
+
def confirmed
|
|
15
|
+
find(:all, :conditions => ["confirmed = ?", true])
|
|
16
|
+
end
|
|
17
|
+
def pending
|
|
18
|
+
find(:all, :conditions => ["confirmed = ?", false])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
include LinkingPaths::Acts::Abusable::InstanceMethods
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Adds instance methods.
|
|
27
|
+
module InstanceMethods
|
|
28
|
+
def is_an_abuse?
|
|
29
|
+
!self.reported_abuses.confirmed.blank?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
ActiveRecord::Base.class_eval do
|
|
38
|
+
include LinkingPaths::Acts::Abusable
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: acts_as_abusable
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Linking Paths
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-10-04 00:00:00 +02:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.
|
|
17
|
+
email:
|
|
18
|
+
- aitor@linkingpaths.com
|
|
19
|
+
executables: []
|
|
20
|
+
|
|
21
|
+
extensions: []
|
|
22
|
+
|
|
23
|
+
extra_rdoc_files: []
|
|
24
|
+
|
|
25
|
+
files:
|
|
26
|
+
- MIT-LICENSE
|
|
27
|
+
- README.markdown
|
|
28
|
+
- Rakefile
|
|
29
|
+
- acts_as_abusable.gemspec
|
|
30
|
+
- generators/acts_as_abusable_migration/acts_as_abusable_migration_generator.rb
|
|
31
|
+
- generators/acts_as_abusable_migration/templates/migration.rb
|
|
32
|
+
- init.rb
|
|
33
|
+
- lib/abuse.rb
|
|
34
|
+
- lib/acts_as_abusable.rb
|
|
35
|
+
- tasks/acts_as_abusable_tasks.rake
|
|
36
|
+
- test/acts_as_abusable_test.rb
|
|
37
|
+
has_rdoc: true
|
|
38
|
+
homepage: http://github.com/linkingpaths/acts_as_abusable
|
|
39
|
+
licenses: []
|
|
40
|
+
|
|
41
|
+
post_install_message: |+
|
|
42
|
+
|
|
43
|
+
For more information on acts_as_abusable, see http://github.com/linkingpaths/acts_as_abusable
|
|
44
|
+
|
|
45
|
+
rdoc_options: []
|
|
46
|
+
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: "0"
|
|
54
|
+
version:
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: "0"
|
|
60
|
+
version:
|
|
61
|
+
requirements: []
|
|
62
|
+
|
|
63
|
+
rubyforge_project: acts_as_abusable
|
|
64
|
+
rubygems_version: 1.3.5
|
|
65
|
+
signing_key:
|
|
66
|
+
specification_version: 3
|
|
67
|
+
summary: Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.
|
|
68
|
+
test_files: []
|
|
69
|
+
|