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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 508d3359dd94e19c340650130796f869f8a0c3b2532b3657164b17a18c6e6803
4
- data.tar.gz: 90f9e13e00d2dbf9ad0d760387c76814b3a00187768b15b1a6d3a9da6665a999
3
+ metadata.gz: 0c4215273a773fbf7a74ecec759f61332979517612184e7e70565d6fdb729f7e
4
+ data.tar.gz: 9c5b893e8361f5fbd8922d42b511317cee8c25f80c99723ddbd126ba324fd875
5
5
  SHA512:
6
- metadata.gz: 7cbc5aaf65ddfdb0a74945d4b410c46260d2dcd366d38c65c27d7fd67eb945884ee5e0794b64a52f97b014d128ff7d7cd8498d231df2b50a8131a0248948e7b8
7
- data.tar.gz: 33d6429eea8ce40b2680e1e4d0da9ed155ed20dda7d5aba0880f32b7d9a7f7dc9ee631e8adf087b76945a66a4376d40ac10757ac8c735538fbcceee30ac13406
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, :polymorphic => true, :index => false
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, :polymorphic => true
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::SchemaInfoGenerator.new(User).generate
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::SchemaInfoGenerator.new(Article).generate
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 | | モデル名(polymorphic) | |
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
- # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
96
+ # >> # ・[Warning: Need to add index]create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
97
97
  # >> #--------------------------------------------------------------------------------
98
98
 
99
- puts Aam::SchemaInfoGenerator.new(Blog).generate
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::SchemaInfoGenerator.new(SubArticle).generate
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 | | モデル名(polymorphic) | |
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
- # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
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
@@ -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, :polymorphic => true, :index => false # Rails5からindex:trueがデフォルトになっているため
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, :polymorphic => true
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::SchemaInfoGenerator.new(User).generate
53
- puts Aam::SchemaInfoGenerator.new(Article).generate
54
- puts Aam::SchemaInfoGenerator.new(Blog).generate
55
- puts Aam::SchemaInfoGenerator.new(SubArticle).generate
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テーブル (users as User)
59
+ # >> # User (users as User)
60
60
  # >> #
61
- # >> # |----------+------+---------+-------------+------+-------|
62
- # >> # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
63
- # >> # |----------+------+---------+-------------+------+-------|
64
- # >> # | id | Id | integer | NOT NULL PK | | |
65
- # >> # | name | Name | string | | | A! |
66
- # >> # | flag | Flag | boolean | DEFAULT(f) | | |
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テーブル (articles as Article)
70
+ # >> # Article (articles as Article)
71
71
  # >> #
72
- # >> # |----------+----------+---------+-------------+-----------------------+-------|
73
- # >> # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
74
- # >> # |----------+----------+---------+-------------+-----------------------+-------|
75
- # >> # | id | Id | integer | NOT NULL PK | | |
76
- # >> # | user_id | ユーザー | integer | | => User#id | A |
77
- # >> # | foo_type | Foo type | string | | モデル名(polymorphic) | |
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
- # >> # ・Article モデルは User モデルから has_many :articles されています。
83
- # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
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テーブル (blogs as Blog)
87
+ # >> # Blog (blogs as Blog)
88
88
  # >> #
89
- # >> # |----------+------+---------+-------------+------+-------|
90
- # >> # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
91
- # >> # |----------+------+---------+-------------+------+-------|
92
- # >> # | id | Id | integer | NOT NULL PK | | |
93
- # >> # | name | Name | string | | | |
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
- # >> # なんとかテーブル (articles as SubArticle)
97
+ # >> # なんとか (articles as SubArticle)
98
98
  # >> #
99
99
  # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
100
- # >> # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
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 | | モデル名(polymorphic) | |
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
- # >> # ・SubArticle モデルは User モデルから has_many :articles されています。
110
- # >> # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
111
- # >> # ・SubArticle モデルは Blog モデルから has_many :sub_articles, :foreign_key => :foo_id されています。
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
@@ -10,6 +10,6 @@ module Aam
10
10
  end
11
11
 
12
12
  require "aam/version"
13
- require "aam/schema_info_generator"
13
+ require "aam/generator"
14
14
  require "aam/annotation"
15
15
  require "aam/railtie" if defined? Rails::Railtie
@@ -71,7 +71,7 @@ module Aam
71
71
  end
72
72
 
73
73
  def schema_info
74
- @schema_info ||= SchemaInfoGenerator.new(@klass, @base.options).generate + "\n"
74
+ @schema_info ||= Generator.new(@klass, @base.options).generate + "\n"
75
75
  end
76
76
 
77
77
  def write_to_relation_files
@@ -3,7 +3,7 @@ require "active_support/core_ext/string/filters"
3
3
  require "table_format"
4
4
 
5
5
  module Aam
6
- class SchemaInfoGenerator
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
- "カラム名" => e.name,
23
- "意味" => column_to_human_name(e.name),
24
- "タイプ" => column_type_inspect_of(e),
25
- "属性" => column_attribute_inspect_of(e),
26
- "参照" => reflections_inspect_of(e),
27
- "INDEX" => index_info(e),
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}テーブル (#{@klass.table_name} as #{@klass.name})\n"
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 << "#- 備考 -------------------------------------------------------------------------\n"
38
- out << @memos.collect{|row|"# ・#{row}\n"}.join
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 "モデル名(STI)"
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}, :polymorphic => true"
114
+ syntax = "belongs_to :#{name}, polymorphic: true"
115
115
  else
116
116
  syntax = "belongs_to :#{name}"
117
117
  end
118
- memo_puts "【警告】#{@klass} モデルに #{syntax} を追加してください"
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
- "モデル名(polymorphic)"
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 << ":foreign_key => :#{assoc_reflection.options[:foreign_key]}"
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, :polymorphic => true の場合は xxx_id と xxx_type のペアでインデックスを貼る
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 "【警告:インデックス欠如】create_#{@klass.table_name} マイグレーションに add_index :#{@klass.table_name}, [:#{column.name}, :#{type_column.name}] を追加してください"
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 "【警告:インデックス欠如】create_#{@klass.table_name} マイグレーションに add_index :#{@klass.table_name}, :#{column.name} を追加してください"
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
@@ -1,3 +1,3 @@
1
1
  module Aam
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -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, :polymorphic => true, :index => false
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, :polymorphic => true, :index => false
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, :polymorphic => true
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::SchemaInfoGenerator.new(User).generate
52
+ assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(User).generate
53
53
  # == Schema Information ==
54
54
  #
55
- # Userテーブル (users as User)
55
+ # User (users as User)
56
56
  #
57
- # |----------+------+------------+-------------+------+-------|
58
- # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
59
- # |----------+------+------------+-------------+------+-------|
60
- # | id | Id | integer | NOT NULL PK | | |
61
- # | name | Name | string(32) | | | A! |
62
- # | flag | Flag | boolean | DEFAULT(f) | | |
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::SchemaInfoGenerator.new(Article).generate
65
+ assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(Article).generate
66
66
  # == Schema Information ==
67
67
  #
68
- # Articleテーブル (articles as Article)
68
+ # Article (articles as Article)
69
69
  #
70
- # |----------+----------+---------+-------------+-----------------------+-------|
71
- # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
72
- # |----------+----------+---------+-------------+-----------------------+-------|
73
- # | id | Id | integer | NOT NULL PK | | |
74
- # | user_id | User | integer | | => User#id | |
75
- # | xxx_type | Xxx type | string | | モデル名(polymorphic) | |
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
- # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, :user_id を追加してください
81
- # ・Article モデルは User モデルから has_many :articles されています。
82
- # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
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::SchemaInfoGenerator.new(SubArticle).generate == <<-EOT.strip_heredoc
85
+ Aam::Generator.new(SubArticle).generate == <<-EOT.strip_heredoc
86
86
  # == Schema Information ==
87
87
  #
88
- # Sub articleテーブル (articles as SubArticle)
88
+ # Sub article (articles as SubArticle)
89
89
  #
90
90
  # |----------+----------+---------+-------------+--------------------------------------+-------|
91
- # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
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 | | モデル名(polymorphic) | |
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
- # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, :user_id を追加してください
101
- # ・【警告:インデックス欠如】create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
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::SchemaInfoGenerator.new(Foo).generate
125
+ assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(Foo).generate
126
126
  # == Schema Information ==
127
127
  #
128
- # Fooテーブル (foos as Foo)
128
+ # Foo (foos as Foo)
129
129
  #
130
130
  # |----------+----------+---------+-------------+------+-------|
131
- # | カラム名 | 意味 | タイプ | 属性 | 参照 | INDEX |
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
- # ・【警告:インデックス欠如】create_foos マイグレーションに add_index :foos, :user_id を追加してください
141
- # ・【警告】Foo モデルに belongs_to :user を追加してください
142
- # ・【警告:インデックス欠如】create_foos マイグレーションに add_index :foos, [:xxx_id, :xxx_type] を追加してください
143
- # ・【警告】Foo モデルに belongs_to :xxx, :polymorphic => true を追加してください
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.11
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-06-28 00:00:00.000000000 Z
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