schema_comments 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +13 -0
- data/Gemfile +11 -8
- data/README.md +187 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/gemfiles/.gitignore +1 -0
- data/gemfiles/Gemfile.rails-4.0 +15 -0
- data/gemfiles/Gemfile.rails-4.1 +12 -0
- data/gemfiles/Gemfile.rails-4.2 +12 -0
- data/lib/annotate_models.rb +12 -4
- data/lib/schema_comments/connection_adapters.rb +2 -1
- data/lib/schema_comments/railtie.rb +11 -0
- data/lib/schema_comments/schema_comment.rb +1 -1
- data/lib/schema_comments/schema_dumper/mysql.rb +2 -2
- data/lib/schema_comments/version.rb +3 -0
- data/lib/schema_comments.rb +2 -0
- data/schema_comments.gemspec +28 -0
- metadata +52 -194
- data/Gemfile.lock +0 -106
- data/README.rdoc +0 -150
- data/spec/annotate_models_spec.rb +0 -63
- data/spec/database.yml +0 -15
- data/spec/fake_app.rb +0 -38
- data/spec/hash_key_orderable_spec.rb +0 -50
- data/spec/human_readable_schema_comments.yml +0 -14
- data/spec/i18n_export_spec.rb +0 -44
- data/spec/migration_spec.rb +0 -108
- data/spec/migrations/valid/001_create_products.rb +0 -17
- data/spec/migrations/valid/002_rename_products.rb +0 -10
- data/spec/migrations/valid/003_rename_products_again.rb +0 -10
- data/spec/migrations/valid/004_remove_price.rb +0 -10
- data/spec/migrations/valid/005_change_products_name.rb +0 -10
- data/spec/migrations/valid/006_change_products_name_with_comment.rb +0 -10
- data/spec/migrations/valid/007_change_comments.rb +0 -12
- data/spec/migrations/valid/008_create_users_without_comment.rb +0 -19
- data/spec/resources/models/product.rb +0 -2
- data/spec/resources/models/product_name.rb +0 -2
- data/spec/schema.rb +0 -2
- data/spec/schema_comments/connection_adapters_spec.rb +0 -54
- data/spec/schema_comments/schema_comment_spec.rb +0 -76
- data/spec/schema_comments/schema_comments.yml +0 -10
- data/spec/schema_comments/schema_comments_broken_column_comments.yml +0 -7
- data/spec/schema_comments/schema_comments_broken_column_hash.yml +0 -10
- data/spec/schema_comments/schema_comments_broken_table_comments.yml +0 -13
- data/spec/schema_comments/schema_comments_users_without_column_hash.yml +0 -10
- data/spec/schema_comments/schema_dumper_spec.rb +0 -92
- data/spec/schema_comments.yml +0 -9
- data/spec/spec_helper.rb +0 -53
- data/spec/yaml_export_spec.rb +0 -52
metadata
CHANGED
@@ -1,290 +1,148 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- akm
|
9
8
|
autorequire:
|
10
|
-
bindir:
|
9
|
+
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 4.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
26
|
+
version: 4.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activerecord
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 4.0.0
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: 4.0.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: bundler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '1.9'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '1.9'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
61
|
+
version: '10.0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
68
|
+
version: '10.0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ~>
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 2.10.0
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ~>
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 2.10.0
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rspec-rails
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 2.10.1
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ~>
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 2.10.1
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: yard
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
72
|
requirements:
|
115
|
-
- -
|
73
|
+
- - ">="
|
116
74
|
- !ruby/object:Gem::Version
|
117
75
|
version: '0'
|
118
76
|
type: :development
|
119
77
|
prerelease: false
|
120
78
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
79
|
requirements:
|
123
|
-
- -
|
80
|
+
- - ">="
|
124
81
|
- !ruby/object:Gem::Version
|
125
82
|
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: simplecov
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: autotest
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: ZenTest
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - '='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 4.8.3
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - '='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 4.8.3
|
174
83
|
description: schema_comments generates extra methods dynamically for attribute which
|
175
|
-
has options
|
176
|
-
email:
|
84
|
+
has options.
|
85
|
+
email:
|
86
|
+
- akm2000@gmail.com
|
177
87
|
executables: []
|
178
88
|
extensions: []
|
179
|
-
extra_rdoc_files:
|
180
|
-
- LICENSE.txt
|
181
|
-
- README.rdoc
|
89
|
+
extra_rdoc_files: []
|
182
90
|
files:
|
183
|
-
- .
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
184
94
|
- Gemfile
|
185
|
-
- Gemfile.lock
|
186
95
|
- LICENSE.txt
|
187
|
-
- README.
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
188
98
|
- VERSION
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- gemfiles/.gitignore
|
102
|
+
- gemfiles/Gemfile.rails-4.0
|
103
|
+
- gemfiles/Gemfile.rails-4.1
|
104
|
+
- gemfiles/Gemfile.rails-4.2
|
189
105
|
- init.rb
|
190
106
|
- lib/annotate_models.rb
|
191
107
|
- lib/hash_key_orderable.rb
|
108
|
+
- lib/schema_comments.rb
|
192
109
|
- lib/schema_comments/base.rb
|
193
110
|
- lib/schema_comments/connection_adapters.rb
|
194
111
|
- lib/schema_comments/migration.rb
|
195
112
|
- lib/schema_comments/migrator.rb
|
113
|
+
- lib/schema_comments/railtie.rb
|
196
114
|
- lib/schema_comments/schema.rb
|
197
115
|
- lib/schema_comments/schema_comment.rb
|
198
|
-
- lib/schema_comments/schema_dumper/mysql.rb
|
199
116
|
- lib/schema_comments/schema_dumper.rb
|
117
|
+
- lib/schema_comments/schema_dumper/mysql.rb
|
200
118
|
- lib/schema_comments/task.rb
|
201
|
-
- lib/schema_comments.rb
|
119
|
+
- lib/schema_comments/version.rb
|
120
|
+
- schema_comments.gemspec
|
202
121
|
- tasks/annotate_models_tasks.rake
|
203
122
|
- tasks/schema_comments.rake
|
204
|
-
- spec/annotate_models_spec.rb
|
205
|
-
- spec/fake_app.rb
|
206
|
-
- spec/hash_key_orderable_spec.rb
|
207
|
-
- spec/i18n_export_spec.rb
|
208
|
-
- spec/migration_spec.rb
|
209
|
-
- spec/migrations/valid/001_create_products.rb
|
210
|
-
- spec/migrations/valid/002_rename_products.rb
|
211
|
-
- spec/migrations/valid/003_rename_products_again.rb
|
212
|
-
- spec/migrations/valid/004_remove_price.rb
|
213
|
-
- spec/migrations/valid/005_change_products_name.rb
|
214
|
-
- spec/migrations/valid/006_change_products_name_with_comment.rb
|
215
|
-
- spec/migrations/valid/007_change_comments.rb
|
216
|
-
- spec/migrations/valid/008_create_users_without_comment.rb
|
217
|
-
- spec/resources/models/product.rb
|
218
|
-
- spec/resources/models/product_name.rb
|
219
|
-
- spec/schema.rb
|
220
|
-
- spec/schema_comments/connection_adapters_spec.rb
|
221
|
-
- spec/schema_comments/schema_comment_spec.rb
|
222
|
-
- spec/schema_comments/schema_dumper_spec.rb
|
223
|
-
- spec/spec_helper.rb
|
224
|
-
- spec/yaml_export_spec.rb
|
225
|
-
- spec/database.yml
|
226
|
-
- spec/human_readable_schema_comments.yml
|
227
|
-
- spec/schema_comments/schema_comments.yml
|
228
|
-
- spec/schema_comments/schema_comments_broken_column_comments.yml
|
229
|
-
- spec/schema_comments/schema_comments_broken_column_hash.yml
|
230
|
-
- spec/schema_comments/schema_comments_broken_table_comments.yml
|
231
|
-
- spec/schema_comments/schema_comments_users_without_column_hash.yml
|
232
|
-
- spec/schema_comments.yml
|
233
123
|
homepage: http://github.com/akm/schema_comments
|
234
124
|
licenses:
|
235
|
-
-
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
236
127
|
post_install_message:
|
237
128
|
rdoc_options: []
|
238
129
|
require_paths:
|
239
130
|
- lib
|
240
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
241
|
-
none: false
|
242
132
|
requirements:
|
243
|
-
- -
|
133
|
+
- - ">="
|
244
134
|
- !ruby/object:Gem::Version
|
245
135
|
version: '0'
|
246
|
-
segments:
|
247
|
-
- 0
|
248
|
-
hash: -2176134516294785649
|
249
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
|
-
none: false
|
251
137
|
requirements:
|
252
|
-
- -
|
138
|
+
- - ">="
|
253
139
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
140
|
+
version: '0'
|
255
141
|
requirements: []
|
256
142
|
rubyforge_project:
|
257
|
-
rubygems_version:
|
143
|
+
rubygems_version: 2.4.5
|
258
144
|
signing_key:
|
259
|
-
specification_version:
|
260
|
-
summary: schema_comments generates extra methods dynamically
|
261
|
-
|
262
|
-
|
263
|
-
- spec/fake_app.rb
|
264
|
-
- spec/hash_key_orderable_spec.rb
|
265
|
-
- spec/i18n_export_spec.rb
|
266
|
-
- spec/migration_spec.rb
|
267
|
-
- spec/migrations/valid/001_create_products.rb
|
268
|
-
- spec/migrations/valid/002_rename_products.rb
|
269
|
-
- spec/migrations/valid/003_rename_products_again.rb
|
270
|
-
- spec/migrations/valid/004_remove_price.rb
|
271
|
-
- spec/migrations/valid/005_change_products_name.rb
|
272
|
-
- spec/migrations/valid/006_change_products_name_with_comment.rb
|
273
|
-
- spec/migrations/valid/007_change_comments.rb
|
274
|
-
- spec/migrations/valid/008_create_users_without_comment.rb
|
275
|
-
- spec/resources/models/product.rb
|
276
|
-
- spec/resources/models/product_name.rb
|
277
|
-
- spec/schema.rb
|
278
|
-
- spec/schema_comments/connection_adapters_spec.rb
|
279
|
-
- spec/schema_comments/schema_comment_spec.rb
|
280
|
-
- spec/schema_comments/schema_dumper_spec.rb
|
281
|
-
- spec/spec_helper.rb
|
282
|
-
- spec/yaml_export_spec.rb
|
283
|
-
- spec/database.yml
|
284
|
-
- spec/human_readable_schema_comments.yml
|
285
|
-
- spec/schema_comments/schema_comments.yml
|
286
|
-
- spec/schema_comments/schema_comments_broken_column_comments.yml
|
287
|
-
- spec/schema_comments/schema_comments_broken_column_hash.yml
|
288
|
-
- spec/schema_comments/schema_comments_broken_table_comments.yml
|
289
|
-
- spec/schema_comments/schema_comments_users_without_column_hash.yml
|
290
|
-
- spec/schema_comments.yml
|
145
|
+
specification_version: 4
|
146
|
+
summary: schema_comments generates extra methods dynamically for attribute which has
|
147
|
+
options.
|
148
|
+
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
schema_comments (0.2.0)
|
5
|
-
activerecord (>= 3.0.0)
|
6
|
-
activesupport (>= 3.0.0)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: http://rubygems.org/
|
10
|
-
specs:
|
11
|
-
ZenTest (4.8.3)
|
12
|
-
actionpack (3.2.11)
|
13
|
-
activemodel (= 3.2.11)
|
14
|
-
activesupport (= 3.2.11)
|
15
|
-
builder (~> 3.0.0)
|
16
|
-
erubis (~> 2.7.0)
|
17
|
-
journey (~> 1.0.4)
|
18
|
-
rack (~> 1.4.0)
|
19
|
-
rack-cache (~> 1.2)
|
20
|
-
rack-test (~> 0.6.1)
|
21
|
-
sprockets (~> 2.2.1)
|
22
|
-
activemodel (3.2.11)
|
23
|
-
activesupport (= 3.2.11)
|
24
|
-
builder (~> 3.0.0)
|
25
|
-
activerecord (3.2.11)
|
26
|
-
activemodel (= 3.2.11)
|
27
|
-
activesupport (= 3.2.11)
|
28
|
-
arel (~> 3.0.2)
|
29
|
-
tzinfo (~> 0.3.29)
|
30
|
-
activesupport (3.2.11)
|
31
|
-
i18n (~> 0.6)
|
32
|
-
multi_json (~> 1.0)
|
33
|
-
arel (3.0.2)
|
34
|
-
autotest (4.4.6)
|
35
|
-
ZenTest (>= 4.4.1)
|
36
|
-
builder (3.0.4)
|
37
|
-
diff-lcs (1.1.3)
|
38
|
-
erubis (2.7.0)
|
39
|
-
hike (1.2.1)
|
40
|
-
i18n (0.6.1)
|
41
|
-
journey (1.0.4)
|
42
|
-
json (1.7.6)
|
43
|
-
multi_json (1.5.0)
|
44
|
-
mysql (2.9.0)
|
45
|
-
mysql2 (0.3.11)
|
46
|
-
rack (1.4.4)
|
47
|
-
rack-cache (1.2)
|
48
|
-
rack (>= 0.4)
|
49
|
-
rack-ssl (1.3.2)
|
50
|
-
rack
|
51
|
-
rack-test (0.6.2)
|
52
|
-
rack (>= 1.0)
|
53
|
-
railties (3.2.11)
|
54
|
-
actionpack (= 3.2.11)
|
55
|
-
activesupport (= 3.2.11)
|
56
|
-
rack-ssl (~> 1.3.2)
|
57
|
-
rake (>= 0.8.7)
|
58
|
-
rdoc (~> 3.4)
|
59
|
-
thor (>= 0.14.6, < 2.0)
|
60
|
-
rake (10.0.3)
|
61
|
-
rdoc (3.12)
|
62
|
-
json (~> 1.4)
|
63
|
-
rspec (2.10.0)
|
64
|
-
rspec-core (~> 2.10.0)
|
65
|
-
rspec-expectations (~> 2.10.0)
|
66
|
-
rspec-mocks (~> 2.10.0)
|
67
|
-
rspec-core (2.10.1)
|
68
|
-
rspec-expectations (2.10.0)
|
69
|
-
diff-lcs (~> 1.1.3)
|
70
|
-
rspec-mocks (2.10.1)
|
71
|
-
rspec-rails (2.10.1)
|
72
|
-
actionpack (>= 3.0)
|
73
|
-
activesupport (>= 3.0)
|
74
|
-
railties (>= 3.0)
|
75
|
-
rspec (~> 2.10.0)
|
76
|
-
simplecov (0.7.1)
|
77
|
-
multi_json (~> 1.0)
|
78
|
-
simplecov-html (~> 0.7.1)
|
79
|
-
simplecov-html (0.7.1)
|
80
|
-
sprockets (2.2.2)
|
81
|
-
hike (~> 1.2)
|
82
|
-
multi_json (~> 1.0)
|
83
|
-
rack (~> 1.0)
|
84
|
-
tilt (~> 1.1, != 1.3.0)
|
85
|
-
sqlite3 (1.3.7)
|
86
|
-
thor (0.17.0)
|
87
|
-
tilt (1.3.3)
|
88
|
-
tzinfo (0.3.35)
|
89
|
-
yard (0.8.3)
|
90
|
-
|
91
|
-
PLATFORMS
|
92
|
-
ruby
|
93
|
-
|
94
|
-
DEPENDENCIES
|
95
|
-
ZenTest (= 4.8.3)
|
96
|
-
autotest
|
97
|
-
bundler
|
98
|
-
mysql
|
99
|
-
mysql2
|
100
|
-
rake
|
101
|
-
rspec (~> 2.10.0)
|
102
|
-
rspec-rails (~> 2.10.1)
|
103
|
-
schema_comments!
|
104
|
-
simplecov
|
105
|
-
sqlite3
|
106
|
-
yard
|
data/README.rdoc
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
= SchemaComments {<img src="https://secure.travis-ci.org/akm/schema_comments.png" />}[http://travis-ci.org/akm/schema_comments]
|
2
|
-
|
3
|
-
== Install
|
4
|
-
|
5
|
-
=== as a plugin
|
6
|
-
ruby script/plugin install git://github.com/akm/schema_comments.git
|
7
|
-
|
8
|
-
=== as a gem
|
9
|
-
insert following line to config/environment.rb
|
10
|
-
config.gem 'schema_comments', :version => '0.1.4'
|
11
|
-
and
|
12
|
-
$ sudo rake gems:install
|
13
|
-
|
14
|
-
Or install gem manually
|
15
|
-
|
16
|
-
$ sudo gem install schema_comments
|
17
|
-
|
18
|
-
And make lib/tasks/schema_comments.rake
|
19
|
-
require 'schema_comments/task'
|
20
|
-
|
21
|
-
|
22
|
-
== Configuration
|
23
|
-
If you install schema_comments as a gem, must create config/initializers/schema_comments.rb like this:
|
24
|
-
require 'schema_comments'
|
25
|
-
SchemaComments.setup
|
26
|
-
|
27
|
-
|
28
|
-
== overview
|
29
|
-
schema_commentsプラグインを使うと、テーブルとカラムにコメントを記述することができます。
|
30
|
-
|
31
|
-
class CreateProducts < ActiveRecord::Migration
|
32
|
-
def self.up
|
33
|
-
create_table "products", :comment => '商品' do |t|
|
34
|
-
t.string "product_type_cd", :comment => '種別コード'
|
35
|
-
t.integer "price", :comment => "価格"
|
36
|
-
t.string "name", :comment => "商品名"
|
37
|
-
t.datetime "created_at", :comment => "登録日時"
|
38
|
-
t.datetime "updated_at", :comment => "更新日時"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.down
|
43
|
-
drop_table "products"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
こんな感じ。
|
48
|
-
|
49
|
-
でこのようなマイグレーションを実行すると、db/schema.rb には、
|
50
|
-
コメントが設定されているテーブル、カラムは以下のように出力されます。
|
51
|
-
|
52
|
-
ActiveRecord::Schema.define(:version => 0) do
|
53
|
-
create_table "products", :force => true, :comment => '商品' do |t|
|
54
|
-
t.string "product_type_cd", :comment => '種別コード'
|
55
|
-
t.integer "price", :comment => "価格"
|
56
|
-
t.string "name", :comment => "商品名"
|
57
|
-
t.datetime "created_at", :comment => "登録日時"
|
58
|
-
t.datetime "updated_at", :comment => "更新日時"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
コメントは、以下のメソッドで使用することが可能です。
|
64
|
-
|
65
|
-
columns, create_table, drop_table, rename_table
|
66
|
-
remove_column, add_column, change_column
|
67
|
-
|
68
|
-
|
69
|
-
== コメントはどこに保存されるのか
|
70
|
-
db/schema_comments.yml にYAML形式で保存されます。
|
71
|
-
あまり推奨しませんが、もしマイグレーションにコメントを記述するのを忘れてしまった場合、db/schema_comments.yml
|
72
|
-
を直接編集した後、rake db:schema:dumpやマイグレーションを実行すると、db/schema.rbのコメントに反映されます。
|
73
|
-
|
74
|
-
|
75
|
-
== I18nへの対応
|
76
|
-
rake i18n:schema_comments:update_config_localeタスクを実行すると、i18n用のYAMLを更新できます。
|
77
|
-
|
78
|
-
rake i18n:schema_comments:update_config_locale LOCALE=ja でデフォルトではconfig/locales/ja.ymlを更新します。
|
79
|
-
|
80
|
-
毎回LOCALEを指定するのが面倒な場合は、config/initializers/locale.rb に
|
81
|
-
I18n.default_locale = 'ja'
|
82
|
-
という記述を追加しておくと良いでしょう。
|
83
|
-
|
84
|
-
また出力先のYAMLのPATHを指定したい場合、YAML_PATHで指定が可能です。
|
85
|
-
rake i18n:schema_comments:update_config_locale LOCALE=ja YAML_PATH=/path/to/yaml
|
86
|
-
|
87
|
-
=== コメント内コメント
|
88
|
-
コメント中の ((( から ))) は反映されませんので、モデル名/属性名に含めたくない箇所は ((( と ))) で括ってください。
|
89
|
-
((( ))) と同様に[[[ ]]]も使用できます。
|
90
|
-
例えば以下のようにdb/schema.rbに出力されている場合、
|
91
|
-
ActiveRecord::Schema.define(:version => 0) do
|
92
|
-
create_table "products", :force => true, :comment => '商品' do |t|
|
93
|
-
t.string "product_type_cd", :comment => '種別コード(((01:書籍, 02:靴, 03:パソコン)))'
|
94
|
-
t.integer "price", :comment => "価格"
|
95
|
-
t.string "name", :comment => "商品名"
|
96
|
-
t.datetime "created_at", :comment => "登録日時"
|
97
|
-
t.datetime "updated_at", :comment => "更新日時"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
rake i18n:schema_comments:update_config_locale LOCALE=ja
|
102
|
-
とすると、以下のように出力されます。
|
103
|
-
ja:
|
104
|
-
activerecord:
|
105
|
-
attributes:
|
106
|
-
product:
|
107
|
-
product_type_cd: "種別コード"
|
108
|
-
price: "価格"
|
109
|
-
name: "商品名"
|
110
|
-
created_at: "登録日時"
|
111
|
-
updated_at: "更新日時"
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
== MySQLのビュー
|
116
|
-
MySQLのビューを使用した場合、元々MySQLではSHOW TABLES でビューも表示してしまうため、
|
117
|
-
ビューはテーブルとしてSchemaDumperに認識され、development環境ではMySQLのビューとして作成されているのに、
|
118
|
-
test環境ではテーブルとして作成されてしまい、テストが正しく動かないことがあります。
|
119
|
-
これを避けるため、schema_commentsでは、db/schema.rbを出力する際、テーブルに関する記述の後に、CREATE VIEWを行う記述を追加します。
|
120
|
-
|
121
|
-
|
122
|
-
== annotate_models
|
123
|
-
rake db:annotate で以下のようなコメントを、モデル、テスト、フィクスチャといったモデルに関係の強いファイルの
|
124
|
-
先頭に追加します。
|
125
|
-
# == Schema Info
|
126
|
-
#
|
127
|
-
# Schema version: 20090721185959
|
128
|
-
#
|
129
|
-
# Table name: books # 書籍
|
130
|
-
#
|
131
|
-
# id :integer not null, primary key
|
132
|
-
# title :string(100) not null # タイトル
|
133
|
-
# size :integer not null, default(1) # 判型
|
134
|
-
# price :decimal(17, 14) not null, default(0.0) # 価格
|
135
|
-
# created_at :datetime # 登録日時
|
136
|
-
# updated_at :datetime # 更新日時
|
137
|
-
#
|
138
|
-
# =================
|
139
|
-
#
|
140
|
-
|
141
|
-
また、rake db:updateで、rake db:migrateとrake db:annotateを実行します。
|
142
|
-
|
143
|
-
annotate_modelsは、達人プログラマーのDave Thomasさんが公開しているプラグインです。
|
144
|
-
http://repo.pragprog.com/svn/Public/plugins/annotate_models/
|
145
|
-
|
146
|
-
本プラグインでは、それを更に拡張したDave Boltonさんのプラグイン(
|
147
|
-
http://github.com/rotuka/annotate_models )をベースに拡張を加えています。
|
148
|
-
|
149
|
-
|
150
|
-
Copyright (c) 2008 Takeshi AKIMA, released under the Ruby License
|