aam 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.org +10 -10
- data/examples/0100_example.rb +40 -40
- data/lib/aam.rb +1 -1
- data/lib/aam/annotation.rb +1 -1
- data/lib/aam/{schema_info_generator.rb → generator.rb} +20 -19
- data/lib/aam/version.rb +1 -1
- data/test/test_aam.rb +40 -40
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4215273a773fbf7a74ecec759f61332979517612184e7e70565d6fdb729f7e
|
4
|
+
data.tar.gz: 9c5b893e8361f5fbd8922d42b511317cee8c25f80c99723ddbd126ba324fd875
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f4f2aacd5120feab9997582e2531bf618088522ddc7cc694b6957cb3a0a59767794c9a853029983e3738cb6f835c753d1a72d0d12aa8b1f1bfed6b8a6071ccd
|
7
|
+
data.tar.gz: 25d9f289573ca3daf7510901f1fac5f5d7d70673045f6cb3963ba75eed77d51710e86b599bc7e152c526b337787821fbca0ba323f7f625fee0f148d2f0bc1e6c
|
data/README.org
CHANGED
@@ -37,7 +37,7 @@ ActiveRecord::Schema.define do
|
|
37
37
|
|
38
38
|
create_table :articles do |t|
|
39
39
|
t.belongs_to :user, index: true
|
40
|
-
t.belongs_to :foo, :
|
40
|
+
t.belongs_to :foo, polymorphic: true, :index => false
|
41
41
|
end
|
42
42
|
|
43
43
|
create_table :blogs do |t|
|
@@ -53,7 +53,7 @@ end
|
|
53
53
|
|
54
54
|
class Article < ActiveRecord::Base
|
55
55
|
belongs_to :user
|
56
|
-
belongs_to :foo, :
|
56
|
+
belongs_to :foo, polymorphic: true
|
57
57
|
end
|
58
58
|
|
59
59
|
class Blog < ActiveRecord::Base
|
@@ -64,7 +64,7 @@ class SubArticle < Article
|
|
64
64
|
belongs_to :blog, :class_name => "Blog", :foreign_key => :foo_id
|
65
65
|
end
|
66
66
|
|
67
|
-
puts Aam::
|
67
|
+
puts Aam::Generator.new(User).generate
|
68
68
|
# >> # == Schema Information ==
|
69
69
|
# >> #
|
70
70
|
# >> # Userテーブル (users as User)
|
@@ -77,7 +77,7 @@ puts Aam::SchemaInfoGenerator.new(User).generate
|
|
77
77
|
# >> # | flag | Flag | boolean | DEFAULT(f) | | |
|
78
78
|
# >> # +----------+------+---------+-------------+------+-------+
|
79
79
|
|
80
|
-
puts Aam::
|
80
|
+
puts Aam::Generator.new(Article).generate
|
81
81
|
# >> # == Schema Information ==
|
82
82
|
# >> #
|
83
83
|
# >> # Articleテーブル (articles as Article)
|
@@ -87,16 +87,16 @@ puts Aam::SchemaInfoGenerator.new(Article).generate
|
|
87
87
|
# >> # +----------+----------+---------+-------------+-----------------------+-------+
|
88
88
|
# >> # | id | Id | integer | NOT NULL PK | | |
|
89
89
|
# >> # | user_id | ユーザー | integer | | => User#id | A |
|
90
|
-
# >> # | foo_type | Foo type | string | |
|
90
|
+
# >> # | foo_type | Foo type | string | | SpecificModel(polymorphic) | |
|
91
91
|
# >> # | foo_id | Foo | integer | | => (foo_type)#id | |
|
92
92
|
# >> # +----------+----------+---------+-------------+-----------------------+-------+
|
93
93
|
# >> #
|
94
94
|
# >> #- 備考 -------------------------------------------------------------------------
|
95
95
|
# >> # ・Article モデルは User モデルから has_many :articles されています。
|
96
|
-
# >> #
|
96
|
+
# >> # ・[Warning: Need to add index]create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
|
97
97
|
# >> #--------------------------------------------------------------------------------
|
98
98
|
|
99
|
-
puts Aam::
|
99
|
+
puts Aam::Generator.new(Blog).generate
|
100
100
|
# >> # == Schema Information ==
|
101
101
|
# >> #
|
102
102
|
# >> # Blogテーブル (blogs as Blog)
|
@@ -108,7 +108,7 @@ puts Aam::SchemaInfoGenerator.new(Blog).generate
|
|
108
108
|
# >> # | name | Name | string | | | |
|
109
109
|
# >> # +----------+------+---------+-------------+------+-------+
|
110
110
|
|
111
|
-
puts Aam::
|
111
|
+
puts Aam::Generator.new(SubArticle).generate
|
112
112
|
# >> # == Schema Information ==
|
113
113
|
# >> #
|
114
114
|
# >> # なんとかテーブル (articles as SubArticle)
|
@@ -118,13 +118,13 @@ puts Aam::SchemaInfoGenerator.new(SubArticle).generate
|
|
118
118
|
# >> # +----------+----------+---------+-------------+--------------------------------------+-------+
|
119
119
|
# >> # | id | Id | integer | NOT NULL PK | | |
|
120
120
|
# >> # | user_id | ユーザー | integer | | => User#id | A |
|
121
|
-
# >> # | foo_type | Foo type | string | |
|
121
|
+
# >> # | foo_type | Foo type | string | | SpecificModel(polymorphic) | |
|
122
122
|
# >> # | foo_id | Foo | integer | | :blog => Blog#id と => (foo_type)#id | |
|
123
123
|
# >> # +----------+----------+---------+-------------+--------------------------------------+-------+
|
124
124
|
# >> #
|
125
125
|
# >> #- 備考 -------------------------------------------------------------------------
|
126
126
|
# >> # ・SubArticle モデルは User モデルから has_many :articles されています。
|
127
|
-
# >> #
|
127
|
+
# >> # ・[Warning: Need to add index]create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
|
128
128
|
# >> # ・SubArticle モデルは Blog モデルから has_many :sub_articles, :foreign_key => :foo_id されています。
|
129
129
|
# >> #--------------------------------------------------------------------------------
|
130
130
|
#+END_SRC
|
data/examples/0100_example.rb
CHANGED
@@ -13,7 +13,7 @@ ActiveRecord::Schema.define do
|
|
13
13
|
|
14
14
|
create_table :articles do |t|
|
15
15
|
t.belongs_to :user, index: true
|
16
|
-
t.belongs_to :foo, :
|
16
|
+
t.belongs_to :foo, polymorphic: true, :index => false # Rails5からindex:trueがデフォルトになっているため
|
17
17
|
end
|
18
18
|
|
19
19
|
create_table :blogs do |t|
|
@@ -29,7 +29,7 @@ end
|
|
29
29
|
|
30
30
|
class Article < ActiveRecord::Base
|
31
31
|
belongs_to :user
|
32
|
-
belongs_to :foo, :
|
32
|
+
belongs_to :foo, polymorphic: true
|
33
33
|
end
|
34
34
|
|
35
35
|
class Blog < ActiveRecord::Base
|
@@ -49,64 +49,64 @@ if true
|
|
49
49
|
I18n.backend.store_translations :ja, {:activerecord => {:models => {"sub_article" => "なんとか"} }, :attributes => {"user_id" => "ユーザー"}}
|
50
50
|
end
|
51
51
|
|
52
|
-
puts Aam::
|
53
|
-
puts Aam::
|
54
|
-
puts Aam::
|
55
|
-
puts Aam::
|
52
|
+
puts Aam::Generator.new(User).generate
|
53
|
+
puts Aam::Generator.new(Article).generate
|
54
|
+
puts Aam::Generator.new(Blog).generate
|
55
|
+
puts Aam::Generator.new(SubArticle).generate
|
56
56
|
|
57
57
|
# >> # == Schema Information ==
|
58
58
|
# >> #
|
59
|
-
# >> # User
|
59
|
+
# >> # User (users as User)
|
60
60
|
# >> #
|
61
|
-
# >> #
|
62
|
-
# >> # |
|
63
|
-
# >> #
|
64
|
-
# >> # | id
|
65
|
-
# >> # | name
|
66
|
-
# >> # | flag
|
67
|
-
# >> #
|
61
|
+
# >> # |------+------+---------+-------------+------+-------|
|
62
|
+
# >> # | name | desc | type | opts | refs | index |
|
63
|
+
# >> # |------+------+---------+-------------+------+-------|
|
64
|
+
# >> # | id | Id | integer | NOT NULL PK | | |
|
65
|
+
# >> # | name | Name | string | | | A! |
|
66
|
+
# >> # | flag | Flag | boolean | DEFAULT(f) | | |
|
67
|
+
# >> # |------+------+---------+-------------+------+-------|
|
68
68
|
# >> # == Schema Information ==
|
69
69
|
# >> #
|
70
|
-
# >> # Article
|
70
|
+
# >> # Article (articles as Article)
|
71
71
|
# >> #
|
72
|
-
# >> #
|
73
|
-
# >> # |
|
74
|
-
# >> #
|
75
|
-
# >> # | id | Id | integer | NOT NULL PK |
|
76
|
-
# >> # | user_id | ユーザー | integer | | => User#id
|
77
|
-
# >> # | foo_type | Foo type | string | |
|
78
|
-
# >> # | foo_id | Foo | integer | | => (foo_type)#id
|
79
|
-
# >> #
|
72
|
+
# >> # |----------+----------+---------+-------------+----------------------------+-------|
|
73
|
+
# >> # | name | desc | type | opts | refs | index |
|
74
|
+
# >> # |----------+----------+---------+-------------+----------------------------+-------|
|
75
|
+
# >> # | id | Id | integer | NOT NULL PK | | |
|
76
|
+
# >> # | user_id | ユーザー | integer | | => User#id | A |
|
77
|
+
# >> # | foo_type | Foo type | string | | SpecificModel(polymorphic) | |
|
78
|
+
# >> # | foo_id | Foo | integer | | => (foo_type)#id | |
|
79
|
+
# >> # |----------+----------+---------+-------------+----------------------------+-------|
|
80
80
|
# >> #
|
81
|
-
# >> #-
|
82
|
-
# >> #
|
83
|
-
# >> #
|
81
|
+
# >> #- Remarks ----------------------------------------------------------------------
|
82
|
+
# >> # User.has_many :articles
|
83
|
+
# >> # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
|
84
84
|
# >> #--------------------------------------------------------------------------------
|
85
85
|
# >> # == Schema Information ==
|
86
86
|
# >> #
|
87
|
-
# >> # Blog
|
87
|
+
# >> # Blog (blogs as Blog)
|
88
88
|
# >> #
|
89
|
-
# >> #
|
90
|
-
# >> # |
|
91
|
-
# >> #
|
92
|
-
# >> # | id
|
93
|
-
# >> # | name
|
94
|
-
# >> #
|
89
|
+
# >> # |------+------+---------+-------------+------+-------|
|
90
|
+
# >> # | name | desc | type | opts | refs | index |
|
91
|
+
# >> # |------+------+---------+-------------+------+-------|
|
92
|
+
# >> # | id | Id | integer | NOT NULL PK | | |
|
93
|
+
# >> # | name | Name | string | | | |
|
94
|
+
# >> # |------+------+---------+-------------+------+-------|
|
95
95
|
# >> # == Schema Information ==
|
96
96
|
# >> #
|
97
|
-
# >> #
|
97
|
+
# >> # なんとか (articles as SubArticle)
|
98
98
|
# >> #
|
99
99
|
# >> # |----------+----------+---------+-------------+--------------------------------------+-------|
|
100
|
-
# >> # |
|
100
|
+
# >> # | name | desc | type | opts | refs | index |
|
101
101
|
# >> # |----------+----------+---------+-------------+--------------------------------------+-------|
|
102
102
|
# >> # | id | Id | integer | NOT NULL PK | | |
|
103
103
|
# >> # | user_id | ユーザー | integer | | => User#id | A |
|
104
|
-
# >> # | foo_type | Foo type | string | |
|
104
|
+
# >> # | foo_type | Foo type | string | | SpecificModel(polymorphic) | |
|
105
105
|
# >> # | foo_id | Foo | integer | | :blog => Blog#id と => (foo_type)#id | |
|
106
106
|
# >> # |----------+----------+---------+-------------+--------------------------------------+-------|
|
107
107
|
# >> #
|
108
|
-
# >> #-
|
109
|
-
# >> #
|
110
|
-
# >> #
|
111
|
-
# >> #
|
108
|
+
# >> #- Remarks ----------------------------------------------------------------------
|
109
|
+
# >> # Blog.has_many :sub_articles, foreign_key: :foo_id
|
110
|
+
# >> # User.has_many :articles
|
111
|
+
# >> # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
|
112
112
|
# >> #--------------------------------------------------------------------------------
|
data/lib/aam.rb
CHANGED
data/lib/aam/annotation.rb
CHANGED
@@ -3,7 +3,7 @@ require "active_support/core_ext/string/filters"
|
|
3
3
|
require "table_format"
|
4
4
|
|
5
5
|
module Aam
|
6
|
-
class
|
6
|
+
class Generator
|
7
7
|
def initialize(klass, options = {})
|
8
8
|
@klass = klass
|
9
9
|
@options = {
|
@@ -19,23 +19,23 @@ module Aam
|
|
19
19
|
}
|
20
20
|
rows = columns.collect {|e|
|
21
21
|
{
|
22
|
-
"
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
27
|
-
"
|
22
|
+
"name" => e.name,
|
23
|
+
"desc" => column_to_human_name(e.name),
|
24
|
+
"type" => column_type_inspect_of(e),
|
25
|
+
"opts" => column_attribute_inspect_of(e),
|
26
|
+
"refs" => reflections_inspect_of(e),
|
27
|
+
"index" => index_info(e),
|
28
28
|
}
|
29
29
|
}
|
30
30
|
out = []
|
31
31
|
out << "#{SCHEMA_HEADER}\n#\n"
|
32
|
-
out << "# #{@klass.model_name.human}
|
32
|
+
out << "# #{@klass.model_name.human} (#{@klass.table_name} as #{@klass.name})\n"
|
33
33
|
out << "#\n"
|
34
34
|
out << rows.to_t.lines.collect { |e| "# #{e}" }.join
|
35
35
|
if @memos.present?
|
36
36
|
out << "#\n"
|
37
|
-
out << "#-
|
38
|
-
out << @memos.collect{|row|"#
|
37
|
+
out << "#- Remarks ----------------------------------------------------------------------\n"
|
38
|
+
out << @memos.sort.collect{|row|"# #{row}\n"}.join
|
39
39
|
out << "#--------------------------------------------------------------------------------\n"
|
40
40
|
end
|
41
41
|
out.join
|
@@ -95,7 +95,7 @@ module Aam
|
|
95
95
|
|
96
96
|
def reflections_inspect_ary_of(column)
|
97
97
|
if column.name == @klass.inheritance_column # カラムが "type" のとき
|
98
|
-
return "
|
98
|
+
return "SpecificModel(STI)"
|
99
99
|
end
|
100
100
|
|
101
101
|
index_check(column)
|
@@ -111,11 +111,11 @@ module Aam
|
|
111
111
|
if md = column.name.match(/(\w+)_id\z/)
|
112
112
|
name = md.captures.first
|
113
113
|
if @klass.column_names.include?("#{name}_type")
|
114
|
-
syntax = "belongs_to :#{name}, :
|
114
|
+
syntax = "belongs_to :#{name}, polymorphic: true"
|
115
115
|
else
|
116
116
|
syntax = "belongs_to :#{name}"
|
117
117
|
end
|
118
|
-
memo_puts "
|
118
|
+
memo_puts "[Warning: Need to add relation] #{@klass} モデルに #{syntax} を追加してください"
|
119
119
|
else
|
120
120
|
# "xxx_type" は polymorphic 指定されていることを確認
|
121
121
|
key, reflection = @klass.reflections.find do |key, reflection|
|
@@ -129,7 +129,7 @@ module Aam
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
if reflection
|
132
|
-
"
|
132
|
+
"SpecificModel(polymorphic)"
|
133
133
|
end
|
134
134
|
end
|
135
135
|
else
|
@@ -187,9 +187,10 @@ module Aam
|
|
187
187
|
if r
|
188
188
|
syntax = ["#{assoc_reflection.macro} :#{assoc_reflection.name}"]
|
189
189
|
if assoc_reflection.options[:foreign_key]
|
190
|
-
syntax << ":
|
190
|
+
syntax << "foreign_key: :#{assoc_reflection.options[:foreign_key]}"
|
191
191
|
end
|
192
|
-
memo_puts "#{@klass.name} モデルは #{assoc_reflection.active_record} モデルから #{syntax.join(', ')} されています。"
|
192
|
+
# memo_puts "#{@klass.name} モデルは #{assoc_reflection.active_record} モデルから #{syntax.join(', ')} されています。"
|
193
|
+
memo_puts "#{assoc_reflection.active_record}.#{syntax.join(', ')}"
|
193
194
|
r
|
194
195
|
end
|
195
196
|
end
|
@@ -289,14 +290,14 @@ module Aam
|
|
289
290
|
#
|
290
291
|
def index_check(column)
|
291
292
|
if column.name.match(/(\w+)_id\z/) || belongs_to_column?(column)
|
292
|
-
# belongs_to :xxx, :
|
293
|
+
# belongs_to :xxx, polymorphic: true の場合は xxx_id と xxx_type のペアでインデックスを貼る
|
293
294
|
if (md = column.name.match(/(\w+)_id\z/)) && (type_column = @klass.columns_hash["#{md.captures.first}_type"])
|
294
295
|
unless index_column?(column) && index_column?(type_column)
|
295
|
-
memo_puts "
|
296
|
+
memo_puts "[Warning: Need to add index] create_#{@klass.table_name} マイグレーションに add_index :#{@klass.table_name}, [:#{column.name}, :#{type_column.name}] を追加してください"
|
296
297
|
end
|
297
298
|
else
|
298
299
|
unless index_column?(column)
|
299
|
-
memo_puts "
|
300
|
+
memo_puts "[Warning: Need to add index] create_#{@klass.table_name} マイグレーションに add_index :#{@klass.table_name}, :#{column.name} を追加してください"
|
300
301
|
end
|
301
302
|
end
|
302
303
|
end
|
data/lib/aam/version.rb
CHANGED
data/test/test_aam.rb
CHANGED
@@ -12,14 +12,14 @@ ActiveRecord::Schema.define do
|
|
12
12
|
|
13
13
|
create_table(:articles) do |t|
|
14
14
|
t.belongs_to :user, :index => false
|
15
|
-
t.belongs_to :xxx, :
|
15
|
+
t.belongs_to :xxx, polymorphic: true, :index => false
|
16
16
|
end
|
17
17
|
create_table(:blogs) do |t|
|
18
18
|
t.string :name
|
19
19
|
end
|
20
20
|
create_table(:foos) do |t|
|
21
21
|
t.belongs_to :user, :index => false
|
22
|
-
t.belongs_to :xxx, :
|
22
|
+
t.belongs_to :xxx, polymorphic: true, :index => false
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -31,7 +31,7 @@ end
|
|
31
31
|
|
32
32
|
class Article < ActiveRecord::Base
|
33
33
|
belongs_to :user
|
34
|
-
belongs_to :xxx, :
|
34
|
+
belongs_to :xxx, polymorphic: true
|
35
35
|
end
|
36
36
|
|
37
37
|
class Blog < ActiveRecord::Base
|
@@ -49,56 +49,56 @@ Aam.logger = nil
|
|
49
49
|
|
50
50
|
class TestAam < Test::Unit::TestCase
|
51
51
|
test "test_main" do
|
52
|
-
assert_equal <<-EOT.strip_heredoc, Aam::
|
52
|
+
assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(User).generate
|
53
53
|
# == Schema Information ==
|
54
54
|
#
|
55
|
-
# User
|
55
|
+
# User (users as User)
|
56
56
|
#
|
57
|
-
#
|
58
|
-
# |
|
59
|
-
#
|
60
|
-
# | id
|
61
|
-
# | name
|
62
|
-
# | flag
|
63
|
-
#
|
57
|
+
# |------+------+------------+-------------+------+-------|
|
58
|
+
# | name | desc | type | opts | refs | index |
|
59
|
+
# |------+------+------------+-------------+------+-------|
|
60
|
+
# | id | Id | integer | NOT NULL PK | | |
|
61
|
+
# | name | Name | string(32) | | | A! |
|
62
|
+
# | flag | Flag | boolean | DEFAULT(f) | | |
|
63
|
+
# |------+------+------------+-------------+------+-------|
|
64
64
|
EOT
|
65
|
-
assert_equal <<-EOT.strip_heredoc, Aam::
|
65
|
+
assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(Article).generate
|
66
66
|
# == Schema Information ==
|
67
67
|
#
|
68
|
-
# Article
|
68
|
+
# Article (articles as Article)
|
69
69
|
#
|
70
|
-
#
|
71
|
-
# |
|
72
|
-
#
|
73
|
-
# | id | Id | integer | NOT NULL PK |
|
74
|
-
# | user_id | User | integer | | => User#id
|
75
|
-
# | xxx_type | Xxx type | string | |
|
76
|
-
# | xxx_id | Xxx | integer | | => (xxx_type)#id
|
77
|
-
#
|
70
|
+
# |----------+----------+---------+-------------+----------------------------+-------|
|
71
|
+
# | name | desc | type | opts | refs | index |
|
72
|
+
# |----------+----------+---------+-------------+----------------------------+-------|
|
73
|
+
# | id | Id | integer | NOT NULL PK | | |
|
74
|
+
# | user_id | User | integer | | => User#id | |
|
75
|
+
# | xxx_type | Xxx type | string | | SpecificModel(polymorphic) | |
|
76
|
+
# | xxx_id | Xxx | integer | | => (xxx_type)#id | |
|
77
|
+
# |----------+----------+---------+-------------+----------------------------+-------|
|
78
78
|
#
|
79
|
-
#-
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
79
|
+
#- Remarks ----------------------------------------------------------------------
|
80
|
+
# User.has_many :articles
|
81
|
+
# [Warning: Need to add index] create_articles マイグレーションに add_index :articles, :user_id を追加してください
|
82
|
+
# [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
|
83
83
|
#--------------------------------------------------------------------------------
|
84
84
|
EOT
|
85
|
-
Aam::
|
85
|
+
Aam::Generator.new(SubArticle).generate == <<-EOT.strip_heredoc
|
86
86
|
# == Schema Information ==
|
87
87
|
#
|
88
|
-
# Sub article
|
88
|
+
# Sub article (articles as SubArticle)
|
89
89
|
#
|
90
90
|
# |----------+----------+---------+-------------+--------------------------------------+-------|
|
91
|
-
# |
|
91
|
+
# | name | desc | type | opts | refs | index |
|
92
92
|
# |----------+----------+---------+-------------+--------------------------------------+-------|
|
93
93
|
# | id | Id | integer | NOT NULL PK | | |
|
94
94
|
# | user_id | User | integer | | => User#id | |
|
95
|
-
# | xxx_type | Xxx type | string | |
|
95
|
+
# | xxx_type | Xxx type | string | | SpecificModel(polymorphic) | |
|
96
96
|
# | xxx_id | Xxx | integer | | :blog => Blog#id と => (xxx_type)#id | |
|
97
97
|
# |----------+----------+---------+-------------+--------------------------------------+-------|
|
98
98
|
#
|
99
99
|
#- 備考 -------------------------------------------------------------------------
|
100
|
-
#
|
101
|
-
#
|
100
|
+
# ・[Warning: Need to add index] create_articles マイグレーションに add_index :articles, :user_id を追加してください
|
101
|
+
# ・[Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
|
102
102
|
#--------------------------------------------------------------------------------
|
103
103
|
EOT
|
104
104
|
end
|
@@ -122,13 +122,13 @@ EOT
|
|
122
122
|
end
|
123
123
|
|
124
124
|
test "test_foo" do
|
125
|
-
assert_equal <<-EOT.strip_heredoc, Aam::
|
125
|
+
assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(Foo).generate
|
126
126
|
# == Schema Information ==
|
127
127
|
#
|
128
|
-
# Foo
|
128
|
+
# Foo (foos as Foo)
|
129
129
|
#
|
130
130
|
# |----------+----------+---------+-------------+------+-------|
|
131
|
-
# |
|
131
|
+
# | name | desc | type | opts | refs | index |
|
132
132
|
# |----------+----------+---------+-------------+------+-------|
|
133
133
|
# | id | Id | integer | NOT NULL PK | | |
|
134
134
|
# | user_id | User | integer | | | |
|
@@ -136,11 +136,11 @@ EOT
|
|
136
136
|
# | xxx_id | Xxx | integer | | | |
|
137
137
|
# |----------+----------+---------+-------------+------+-------|
|
138
138
|
#
|
139
|
-
#-
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
139
|
+
#- Remarks ----------------------------------------------------------------------
|
140
|
+
# [Warning: Need to add index] create_foos マイグレーションに add_index :foos, :user_id を追加してください
|
141
|
+
# [Warning: Need to add index] create_foos マイグレーションに add_index :foos, [:xxx_id, :xxx_type] を追加してください
|
142
|
+
# [Warning: Need to add relation] Foo モデルに belongs_to :user を追加してください
|
143
|
+
# [Warning: Need to add relation] Foo モデルに belongs_to :xxx, polymorphic: true を追加してください
|
144
144
|
#--------------------------------------------------------------------------------
|
145
145
|
EOT
|
146
146
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akicho8
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -139,8 +139,8 @@ files:
|
|
139
139
|
- examples/0100_example.rb
|
140
140
|
- lib/aam.rb
|
141
141
|
- lib/aam/annotation.rb
|
142
|
+
- lib/aam/generator.rb
|
142
143
|
- lib/aam/railtie.rb
|
143
|
-
- lib/aam/schema_info_generator.rb
|
144
144
|
- lib/aam/tasks/aam.rake
|
145
145
|
- lib/aam/version.rb
|
146
146
|
- test/test_aam.rb
|