aam 0.0.12 → 0.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c4215273a773fbf7a74ecec759f61332979517612184e7e70565d6fdb729f7e
4
- data.tar.gz: 9c5b893e8361f5fbd8922d42b511317cee8c25f80c99723ddbd126ba324fd875
3
+ metadata.gz: 4f2e237766cc4aebb981ae843b061980f73a5a19aea5e981df784a1a4fa96f7a
4
+ data.tar.gz: db1533ca813417f4cfc3066328959a6aa7e00c594211a11854c826ede9872ca2
5
5
  SHA512:
6
- metadata.gz: 3f4f2aacd5120feab9997582e2531bf618088522ddc7cc694b6957cb3a0a59767794c9a853029983e3738cb6f835c753d1a72d0d12aa8b1f1bfed6b8a6071ccd
7
- data.tar.gz: 25d9f289573ca3daf7510901f1fac5f5d7d70673045f6cb3963ba75eed77d51710e86b599bc7e152c526b337787821fbca0ba323f7f625fee0f148d2f0bc1e6c
6
+ metadata.gz: 6bc66294cb01e90c72bc2982632770d1e7e8f25e994e57e24af8490524dcb3053958ae1cd328f04ad7fb6d1b1784e4e5eb1a4535feda16efc70d0b7d0d433bdb
7
+ data.tar.gz: 17730f79a62f99ec2eebb246a505bcc9e8210a3c186440342f33455fcbf3b052f2ce41d4f78fc7d7c2775bf13d5f498492ff98ed876c6a4a4a5c300490fd6ed0
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in aam.gemspec
1
+ source "https://rubygems.org"
4
2
  gemspec
data/aam.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "test-unit"
24
24
  spec.add_development_dependency "sqlite3"
@@ -63,7 +63,7 @@ puts Aam::Generator.new(SubArticle).generate
63
63
  # >> # |------+------+---------+-------------+------+-------|
64
64
  # >> # | id | Id | integer | NOT NULL PK | | |
65
65
  # >> # | name | Name | string | | | A! |
66
- # >> # | flag | Flag | boolean | DEFAULT(f) | | |
66
+ # >> # | flag | Flag | boolean | DEFAULT(0) | | |
67
67
  # >> # |------+------+---------+-------------+------+-------|
68
68
  # >> # == Schema Information ==
69
69
  # >> #
@@ -78,10 +78,10 @@ puts Aam::Generator.new(SubArticle).generate
78
78
  # >> # | foo_id | Foo | integer | | => (foo_type)#id | |
79
79
  # >> # |----------+----------+---------+-------------+----------------------------+-------|
80
80
  # >> #
81
- # >> #- Remarks ----------------------------------------------------------------------
81
+ # >> # - Remarks ----------------------------------------------------------------------
82
82
  # >> # User.has_many :articles
83
83
  # >> # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
84
- # >> #--------------------------------------------------------------------------------
84
+ # >> # --------------------------------------------------------------------------------
85
85
  # >> # == Schema Information ==
86
86
  # >> #
87
87
  # >> # Blog (blogs as Blog)
@@ -105,8 +105,8 @@ puts Aam::Generator.new(SubArticle).generate
105
105
  # >> # | foo_id | Foo | integer | | :blog => Blog#id と => (foo_type)#id | |
106
106
  # >> # |----------+----------+---------+-------------+--------------------------------------+-------|
107
107
  # >> #
108
- # >> #- Remarks ----------------------------------------------------------------------
108
+ # >> # - Remarks ----------------------------------------------------------------------
109
109
  # >> # Blog.has_many :sub_articles, foreign_key: :foo_id
110
110
  # >> # User.has_many :articles
111
111
  # >> # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:foo_id, :foo_type] を追加してください
112
- # >> #--------------------------------------------------------------------------------
112
+ # >> # --------------------------------------------------------------------------------
@@ -49,7 +49,7 @@ module Aam
49
49
  begin
50
50
  model = Model.new(self, klass)
51
51
  @all << model.schema_info
52
- rescue ActiveRecord::ActiveRecordError => error
52
+ rescue ActiveRecord::ActiveRecordError
53
53
  end
54
54
  end
55
55
  file = root_dir.join("db", "schema_info.txt")
@@ -122,7 +122,7 @@ module Aam
122
122
  if body.match(regexp)
123
123
  body = body.sub(regexp, schema_info)
124
124
  elsif body.include?(MAGIC_COMMENT_LINE)
125
- body = body.sub(/#{Regexp.escape(MAGIC_COMMENT_LINE)}\s*/) {MAGIC_COMMENT_LINE + schema_info}
125
+ body = body.sub(/#{Regexp.escape(MAGIC_COMMENT_LINE)}\s*/) { MAGIC_COMMENT_LINE + "\n" + schema_info }
126
126
  else
127
127
  body = body.sub(/^\s*/, schema_info)
128
128
  end
data/lib/aam/generator.rb CHANGED
@@ -34,9 +34,9 @@ module Aam
34
34
  out << rows.to_t.lines.collect { |e| "# #{e}" }.join
35
35
  if @memos.present?
36
36
  out << "#\n"
37
- out << "#- Remarks ----------------------------------------------------------------------\n"
38
- out << @memos.sort.collect{|row|"# #{row}\n"}.join
39
- out << "#--------------------------------------------------------------------------------\n"
37
+ out << "# - Remarks ----------------------------------------------------------------------\n"
38
+ out << @memos.sort.collect { |row| "# #{row}\n" }.join
39
+ out << "# --------------------------------------------------------------------------------\n"
40
40
  end
41
41
  out.join
42
42
  end
@@ -118,7 +118,7 @@ module Aam
118
118
  memo_puts "[Warning: Need to add relation] #{@klass} モデルに #{syntax} を追加してください"
119
119
  else
120
120
  # "xxx_type" は polymorphic 指定されていることを確認
121
- key, reflection = @klass.reflections.find do |key, reflection|
121
+ _key, reflection = @klass.reflections.find do |key, reflection|
122
122
  _options = reflection.options
123
123
  if true
124
124
  # >= 3.1.3
@@ -178,7 +178,7 @@ module Aam
178
178
  # 理由は belongs_to に foreign_key が指定されたら has_many 側も has_many :foos, :foreign_key => "bar_id" とならないといけないため。
179
179
  #
180
180
  def belongs_to_model_has_many_syntax(column, reflection)
181
- assoc_key, assoc_reflection = reflection.class_name.constantize.reflections.find do |assoc_key, assoc_reflection|
181
+ _assoc_key, assoc_reflection = reflection.class_name.constantize.reflections.find do |assoc_key, assoc_reflection|
182
182
  if false
183
183
  r = reflection.class_name.constantize == assoc_reflection.active_record && [:has_many, :has_one].include?(assoc_reflection.macro)
184
184
  else
@@ -252,7 +252,7 @@ module Aam
252
252
  # 関係するインデックスに絞る
253
253
  indexes2 = indexes.find_all {|e| e.columns.include?(column.name) }
254
254
  indexes2.collect {|e|
255
- mark = ""
255
+ mark = +""
256
256
  # そのインデックスは何番目にあるかを調べる
257
257
  mark << ("A".."Z").to_a.at(indexes.index(e)).to_s
258
258
  # ユニークなら「!」
data/lib/aam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aam
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.14"
3
3
  end
data/test/test_aam.rb CHANGED
@@ -59,7 +59,7 @@ class TestAam < Test::Unit::TestCase
59
59
  # |------+------+------------+-------------+------+-------|
60
60
  # | id | Id | integer | NOT NULL PK | | |
61
61
  # | name | Name | string(32) | | | A! |
62
- # | flag | Flag | boolean | DEFAULT(f) | | |
62
+ # | flag | Flag | boolean | DEFAULT(0) | | |
63
63
  # |------+------+------------+-------------+------+-------|
64
64
  EOT
65
65
  assert_equal <<-EOT.strip_heredoc, Aam::Generator.new(Article).generate
@@ -76,11 +76,11 @@ EOT
76
76
  # | xxx_id | Xxx | integer | | => (xxx_type)#id | |
77
77
  # |----------+----------+---------+-------------+----------------------------+-------|
78
78
  #
79
- #- Remarks ----------------------------------------------------------------------
79
+ # - Remarks ----------------------------------------------------------------------
80
80
  # User.has_many :articles
81
81
  # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, :user_id を追加してください
82
82
  # [Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
83
- #--------------------------------------------------------------------------------
83
+ # --------------------------------------------------------------------------------
84
84
  EOT
85
85
  Aam::Generator.new(SubArticle).generate == <<-EOT.strip_heredoc
86
86
  # == Schema Information ==
@@ -96,10 +96,10 @@ EOT
96
96
  # | xxx_id | Xxx | integer | | :blog => Blog#id と => (xxx_type)#id | |
97
97
  # |----------+----------+---------+-------------+--------------------------------------+-------|
98
98
  #
99
- #- 備考 -------------------------------------------------------------------------
99
+ # - 備考 -------------------------------------------------------------------------
100
100
  # ・[Warning: Need to add index] create_articles マイグレーションに add_index :articles, :user_id を追加してください
101
101
  # ・[Warning: Need to add index] create_articles マイグレーションに add_index :articles, [:xxx_id, :xxx_type] を追加してください
102
- #--------------------------------------------------------------------------------
102
+ # --------------------------------------------------------------------------------
103
103
  EOT
104
104
  end
105
105
 
@@ -136,12 +136,12 @@ EOT
136
136
  # | xxx_id | Xxx | integer | | | |
137
137
  # |----------+----------+---------+-------------+------+-------|
138
138
  #
139
- #- Remarks ----------------------------------------------------------------------
139
+ # - Remarks ----------------------------------------------------------------------
140
140
  # [Warning: Need to add index] create_foos マイグレーションに add_index :foos, :user_id を追加してください
141
141
  # [Warning: Need to add index] create_foos マイグレーションに add_index :foos, [:xxx_id, :xxx_type] を追加してください
142
142
  # [Warning: Need to add relation] Foo モデルに belongs_to :user を追加してください
143
143
  # [Warning: Need to add relation] Foo モデルに belongs_to :xxx, polymorphic: true を追加してください
144
- #--------------------------------------------------------------------------------
144
+ # --------------------------------------------------------------------------------
145
145
  EOT
146
146
  end
147
147
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require "test/unit"
2
2
  $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
3
  require "aam"
4
+ require "active_support/core_ext/string"
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - "~>"
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '1.3'
18
+ version: '0'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - "~>"
23
+ - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '1.3'
25
+ version: '0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rake
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +129,6 @@ extensions: []
130
129
  extra_rdoc_files: []
131
130
  files:
132
131
  - ".gitignore"
133
- - ".travis.yml"
134
132
  - Gemfile
135
133
  - LICENSE.txt
136
134
  - README.org
@@ -149,7 +147,6 @@ homepage: ''
149
147
  licenses:
150
148
  - MIT
151
149
  metadata: {}
152
- post_install_message:
153
150
  rdoc_options: []
154
151
  require_paths:
155
152
  - lib
@@ -164,9 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
161
  - !ruby/object:Gem::Version
165
162
  version: '0'
166
163
  requirements: []
167
- rubyforge_project:
168
- rubygems_version: 2.7.6
169
- signing_key:
164
+ rubygems_version: 3.6.8
170
165
  specification_version: 4
171
166
  summary: Advanced Annotate Models
172
167
  test_files:
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0