kentouzu 0.0.13 → 0.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/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/generators/kentouzu/install_generator.rb +5 -2
- data/lib/kentouzu/draft.rb +0 -2
- data/lib/kentouzu/has_drafts.rb +13 -5
- data/lib/kentouzu/version.rb +1 -1
- data/spec/dummy/app/models/message.rb +0 -2
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
require 'rails/generators/migration'
|
3
|
-
require 'rails/generators/active_record
|
3
|
+
require 'rails/generators/active_record'
|
4
4
|
|
5
5
|
module Kentouzu
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
7
|
include Rails::Generators::Migration
|
8
|
-
extend ActiveRecord::Generators::Migration
|
9
8
|
|
10
9
|
source_root File.expand_path('../templates', __FILE__)
|
11
10
|
|
@@ -14,5 +13,9 @@ module Kentouzu
|
|
14
13
|
def create_migration_file
|
15
14
|
migration_template 'create_drafts.rb', 'db/migrate/create_drafts.rb'
|
16
15
|
end
|
16
|
+
|
17
|
+
def self.next_migration_number(dirname)
|
18
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/kentouzu/draft.rb
CHANGED
data/lib/kentouzu/has_drafts.rb
CHANGED
@@ -37,11 +37,19 @@ module Kentouzu
|
|
37
37
|
class_attribute :drafts_association_name
|
38
38
|
self.drafts_association_name = options[:drafts] || :drafts
|
39
39
|
|
40
|
-
has_many
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
if ActiveRecord::VERSION::STRING.to_f >= 4.0 # `has_many` syntax for specifying order uses a lambda in Rails 4
|
41
|
+
has_many self.drafts_association_name,
|
42
|
+
lambda { order("#{Kentouzu.timestamp_field} ASC, #{self.draft_class_name.constantize.primary_key} ASC") },
|
43
|
+
:class_name => draft_class_name,
|
44
|
+
:as => :item,
|
45
|
+
:dependent => :destroy
|
46
|
+
else
|
47
|
+
has_many self.drafts_association_name,
|
48
|
+
:class_name => draft_class_name,
|
49
|
+
:as => :item,
|
50
|
+
:order => "#{Kentouzu.timestamp_field} ASC, #{self.draft_class_name.constantize.primary_key} ASC",
|
51
|
+
:dependent => :destroy
|
52
|
+
end
|
45
53
|
|
46
54
|
define_singleton_method "new_#{drafts_association_name.to_s}".to_sym do
|
47
55
|
Draft.where(:item_type => self.name, :event => 'create')
|
data/lib/kentouzu/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kentouzu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -259,7 +259,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
259
259
|
version: '0'
|
260
260
|
segments:
|
261
261
|
- 0
|
262
|
-
hash:
|
262
|
+
hash: -333500455675358414
|
263
263
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
264
|
none: false
|
265
265
|
requirements:
|
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
version: '0'
|
269
269
|
segments:
|
270
270
|
- 0
|
271
|
-
hash:
|
271
|
+
hash: -333500455675358414
|
272
272
|
requirements: []
|
273
273
|
rubyforge_project: kentouzu
|
274
274
|
rubygems_version: 1.8.25
|