linkingpaths-acts_as_abusable 0.0.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/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"
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 reported abuses
47
+ penthouse_sweetie_photo.reported_abuses
48
+
49
+ # Positive abuses
50
+ penthouse_sweetie_photo.reported_abuses.confirmed
51
+
52
+ # Still not evaluated abuses
53
+ penthouse_sweetie_photo.reported_abuses.pending
54
+
55
+ # Confirmed. This is inter....erhm... and 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
66
+ abuse.referer
67
+
68
+ # Resource that supposely is an abuse
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.1"
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", "install.rb", "lib", "lib/abuse.rb", "lib/acts_as_abusable.rb", "rails", "rails/init.rb", "tasks", "tasks/acts_as_abusable_tasks.rake", "test", "test/acts_as_abusable_test.rb", "uninstall.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,11 @@
1
+ class ActsAsAbusableMigrationGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.migration_template 'migration.rb', 'db/migrate'
5
+ end
6
+ end
7
+
8
+ def file_name
9
+ "acts_as_abusable_migration"
10
+ end
11
+ 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 File.dirname(__FILE__) + "/rails/init"
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/lib/abuse.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Abuse < ActiveRecord::Base
2
+ belongs_to :resource, :polymorphic => true
3
+
4
+ def confirm!
5
+ self.confirmed = true
6
+ self.save unless self.new_record?
7
+ end
8
+
9
+ end
@@ -0,0 +1,33 @@
1
+ module LinkingPaths
2
+ module Acts #:nodoc:
3
+ module Abusable #:nodoc:
4
+
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def acts_as_abusable
11
+ has_many :reported_abuses, :class_name => 'Abuse', :as => :resource do
12
+ def confirmed
13
+ find(:all, :conditions => ["confirmed = ?", true])
14
+ end
15
+ def pending
16
+ find(:all, :conditions => ["confirmed = ?", false])
17
+ end
18
+ end
19
+
20
+ include LinkingPaths::Acts::Abusable::InstanceMethods
21
+ end
22
+ end
23
+
24
+ # Adds instance methods.
25
+ module InstanceMethods
26
+ def is_an_abuse?
27
+ !self.reported_abuses.confirmed.blank?
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'acts_as_abusable'
2
+
3
+ ActiveRecord::Base.class_eval do
4
+ include LinkingPaths::Acts::Abusable
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :acts_as_abusable do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+
3
+ class ActsAsAbusableTest < Test::Unit::TestCase
4
+ # Replace this with your real tests.
5
+ def test_this_plugin
6
+ flunk
7
+ end
8
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linkingpaths-acts_as_abusable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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 -07: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
31
+ - generators/acts_as_abusable_migration
32
+ - generators/acts_as_abusable_migration/acts_as_abusable_migration_generator.rb
33
+ - generators/acts_as_abusable_migration/templates
34
+ - generators/acts_as_abusable_migration/templates/migration.rb
35
+ - init.rb
36
+ - install.rb
37
+ - lib
38
+ - lib/abuse.rb
39
+ - lib/acts_as_abusable.rb
40
+ - rails
41
+ - rails/init.rb
42
+ - tasks
43
+ - tasks/acts_as_abusable_tasks.rake
44
+ - test
45
+ - test/acts_as_abusable_test.rb
46
+ - uninstall.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/linkingpaths/acts_as_abusable
49
+ post_install_message: |+
50
+
51
+ For more information on acts_as_abusable, see http://github.com/linkingpaths/acts_as_abusable
52
+
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ requirements: []
70
+
71
+ rubyforge_project: acts_as_abusable
72
+ rubygems_version: 1.2.0
73
+ signing_key:
74
+ specification_version: 2
75
+ summary: Tiny plugin to mark any rails model instance as an abuse or site's community guideline violation.
76
+ test_files: []
77
+