has_moderated 1.0.rc7 → 1.0.rc8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -4
- data/lib/generators/has_moderated/install/install_generator.rb +13 -3
- data/lib/generators/has_moderated/install/templates/{migration.rb → migrations/1_create_moderations.rb} +0 -0
- data/lib/has_moderated/common.rb +0 -4
- data/lib/has_moderated/railtie.rb +14 -0
- data/lib/has_moderated/version.rb +1 -1
- data/lib/has_moderated.rb +1 -15
- data/test/dummy/log/development.log +5 -0
- data/test/dummy/log/test.log +72254 -0
- data/test/dummy/spec/spec_helper.rb +1 -66
- metadata +20 -5
- data/test/dummy/Guardfile +0 -29
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Add it to your project's Gemfile
|
7
7
|
|
8
|
-
gem "has_moderated", ">=1.0.
|
8
|
+
gem "has_moderated", ">=1.0.rc8"
|
9
9
|
|
10
10
|
and run
|
11
11
|
|
@@ -26,9 +26,9 @@ When upgrading, rerun the generator
|
|
26
26
|
|
27
27
|
rails generate has_moderated:install
|
28
28
|
|
29
|
-
If
|
29
|
+
If you are upgrading from a version lower than 1.0.x you need to remove the old create_moderations migration file.
|
30
30
|
|
31
|
-
|
31
|
+
Make sure you have reviewed and accepted/declined all current moderations before upgrading! This means the moderations table in database should be empty, otherwise the migration process might fail (on purpose).
|
32
32
|
|
33
33
|
== Why use this instead of something like Papertrail?
|
34
34
|
|
@@ -136,7 +136,7 @@ The fake object described above has a nifty feature (1.0.rc7+) that allows you t
|
|
136
136
|
preview.title = "Task 2"
|
137
137
|
preview.update_moderation
|
138
138
|
moderation.parsed_data # => {:attributes=>{"title"=>"Task 2"}}
|
139
|
-
moderation.
|
139
|
+
moderation.accept
|
140
140
|
Task.first.title # => "Task 2"
|
141
141
|
|
142
142
|
=== Get a real ActiveRecord preview
|
@@ -277,6 +277,8 @@ It is also possible you will encounter problems with some heavily customized ass
|
|
277
277
|
|
278
278
|
This is just for my personal todo list...
|
279
279
|
|
280
|
+
perhaps can use .freeze for preview?
|
281
|
+
|
280
282
|
improve functionality when rerunning has_moderated:install generator
|
281
283
|
|
282
284
|
hm maybe has_moderated_association could be just a has_moderated_create on the assoc? just check stuff like if task_id is not nil or something. could be much easier to implement then
|
@@ -2,15 +2,25 @@ module HasModerated
|
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < ::Rails::Generators::Base
|
4
4
|
desc "This generator installs files for has_moderated."
|
5
|
-
source_root File.expand_path('../templates', __FILE__)
|
6
5
|
include Rails::Generators::Migration
|
7
6
|
|
7
|
+
def self.source_root
|
8
|
+
@_has_moderated_source_root ||= File.expand_path("../templates", __FILE__)
|
9
|
+
end
|
10
|
+
|
8
11
|
def files
|
9
|
-
class_collisions 'Moderation'
|
12
|
+
# class_collisions 'Moderation'
|
10
13
|
template 'moderation.rb', File.join('app/models', 'moderation.rb')
|
11
|
-
migration_template 'migration.rb', 'db/migrate/create_moderations.rb'
|
12
14
|
end
|
13
15
|
|
16
|
+
def create_migrations
|
17
|
+
Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
|
18
|
+
name = File.basename(filepath)
|
19
|
+
migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
|
20
|
+
sleep 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
14
24
|
private
|
15
25
|
def self.next_migration_number(dirname) #:nodoc:
|
16
26
|
if ActiveRecord::Base.timestamped_migrations
|
File without changes
|
data/lib/has_moderated/common.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module HasModerated
|
2
|
+
class Railtie < Rails::Railtie
|
3
|
+
initializer "has_moderated.include_in_activerecord" do
|
4
|
+
ActiveSupport.on_load :active_record do
|
5
|
+
include HasModerated::Common::InstanceMethods
|
6
|
+
extend HasModerated::UserHooks::ClassMethods
|
7
|
+
extend HasModerated::Associations::Base::ClassMethods
|
8
|
+
extend HasModerated::ModeratedAttributes::ClassMethods
|
9
|
+
extend HasModerated::ModeratedCreate::ClassMethods
|
10
|
+
extend HasModerated::ModeratedDestroy::ClassMethods
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/has_moderated.rb
CHANGED
@@ -14,18 +14,4 @@ require 'has_moderated/moderated_create'
|
|
14
14
|
require 'has_moderated/moderated_destroy'
|
15
15
|
|
16
16
|
require 'has_moderated/carrier_wave'
|
17
|
-
|
18
|
-
module HasModerated
|
19
|
-
def self.included(base)
|
20
|
-
HasModerated::Common::included(base)
|
21
|
-
base.send :extend, HasModerated::UserHooks::ClassMethods
|
22
|
-
|
23
|
-
# TODO: only include class methods that can be called, lazy load everything else
|
24
|
-
base.send :extend, HasModerated::Associations::Base::ClassMethods
|
25
|
-
base.send :extend, HasModerated::ModeratedAttributes::ClassMethods
|
26
|
-
base.send :extend, HasModerated::ModeratedCreate::ClassMethods
|
27
|
-
base.send :extend, HasModerated::ModeratedDestroy::ClassMethods
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
ActiveRecord::Base.send :include, HasModerated
|
17
|
+
require 'has_moderated/railtie' if defined?(Rails)
|
@@ -70,3 +70,8 @@ Connecting to database specified by database.yml
|
|
70
70
|
Connecting to database specified by database.yml
|
71
71
|
Connecting to database specified by database.yml
|
72
72
|
Connecting to database specified by database.yml
|
73
|
+
Connecting to database specified by database.yml
|
74
|
+
Connecting to database specified by database.yml
|
75
|
+
Connecting to database specified by database.yml
|
76
|
+
Connecting to database specified by database.yml
|
77
|
+
Connecting to database specified by database.yml
|