schema_comments 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 24b3283a263104ee9046e1997be8c81c8147833a
4
- data.tar.gz: cb88b5c63f9beee0dda6e4a5fa914a46a338ea8c
3
+ metadata.gz: cb906aa319149d9162686075b61ccaa340f1fd38
4
+ data.tar.gz: 91ba3034e9efc564abfe4e7b556639fc606a5c6a
5
5
  SHA512:
6
- metadata.gz: 02a04a92bf9a60b4830636e8788eb561bafb454a80ebdeec79d2960e473e96c4d302b50d80fbd739f8c3832e2d2b4ff4eed4873c95b5812f039887108749b124
7
- data.tar.gz: d344cb682fcd641ca133968b395cb9ef4bfa533af50cd9e7a70773efb66688b19b703a61d36dd86b4c15d6c55e17615a3b1eb2adeda562d00e0bb036e7983567
6
+ metadata.gz: 8b83e84536e4770de6e2231c9c6b712ce299ed3bb7610e847d0ba004050455d5d3a9e35d6d88ad809e67e8c8075757a5ad276370ab37363869c2f572a6a8b8ca
7
+ data.tar.gz: 5ac5502337703798c29e059d1bfaa7efbffdde85a2148cd88143e9ea40f579849638910107190be71f2e975952e0243f8b800c3dab2edf33f4e6e6296a8e0d01
data/README.md CHANGED
@@ -5,89 +5,67 @@
5
5
  ### With Bundler
6
6
  add this line into Gemfile
7
7
 
8
- gem "schema_comments"
8
+ ```
9
+ gem "schema_comments"
10
+ ```
9
11
 
10
12
  And do bundle install
11
13
 
12
- bundle install
13
-
14
- ## Install(old)
15
-
16
- ### as a plugin
17
-
18
- ruby script/plugin install git://github.com/akm/schema_comments.git
19
-
20
- ### as a gem
21
- insert following line to config/environment.rb
22
-
23
- config.gem 'schema_comments', :version => '0.2.0'
24
-
25
- and
26
-
27
- $ sudo rake gems:install
14
+ ```
15
+ bundle install
16
+ ```
28
17
 
29
18
  Or install gem manually
30
19
 
31
- $ sudo gem install schema_comments
32
-
33
- And make lib/tasks/schema_comments.rake
34
-
35
- require 'schema_comments/task'
36
-
37
- ## Configuration for Rails App
38
- 1. make lib/tasks/schema_comments.rake
39
- 2. edit the file like following
40
-
41
- require 'schema_comments/task'
42
- SchemaComments.yaml_path = File.expand_path("../../../db/schema_comments.yml", __FILE__)
43
-
44
-
45
- ## Configuration (old)
46
- If you install schema_comments as a gem, must create config/initializers/schema_comments.rb like this:
47
-
48
- require 'schema_comments'
49
- SchemaComments.setup
20
+ ```
21
+ $ gem install schema_comments
22
+ ```
50
23
 
51
24
 
52
25
  ## Overview
53
26
  schema_commentsプラグインを使うと、テーブルとカラムにコメントを記述することができます。
54
27
 
55
- class CreateProducts < ActiveRecord::Migration
56
- def self.up
57
- create_table "products", :comment => '商品' do |t|
58
- t.string "product_type_cd", :comment => '種別コード'
59
- t.integer "price", :comment => "価格"
60
- t.string "name", :comment => "商品名"
61
- t.datetime "created_at", :comment => "登録日時"
62
- t.datetime "updated_at", :comment => "更新日時"
63
- end
64
- end
65
-
66
- def self.down
67
- drop_table "products"
68
- end
28
+ ```
29
+ class CreateProducts < ActiveRecord::Migration
30
+ def self.up
31
+ create_table "products", :comment => '商品' do |t|
32
+ t.string "product_type_cd", :comment => '種別コード'
33
+ t.integer "price", :comment => "価格"
34
+ t.string "name", :comment => "商品名"
35
+ t.datetime "created_at", :comment => "登録日時"
36
+ t.datetime "updated_at", :comment => "更新日時"
69
37
  end
38
+ end
39
+
40
+ def self.down
41
+ drop_table "products"
42
+ end
43
+ end
44
+ ```
70
45
 
71
46
  こんな感じ。
72
47
 
73
48
  でこのようなマイグレーションを実行すると、db/schema.rb には、
74
49
  コメントが設定されているテーブル、カラムは以下のように出力されます。
75
50
 
76
- ActiveRecord::Schema.define(:version => 0) do
77
- create_table "products", :force => true, :comment => '商品' do |t|
78
- t.string "product_type_cd", :comment => '種別コード'
79
- t.integer "price", :comment => "価格"
80
- t.string "name", :comment => "商品名"
81
- t.datetime "created_at", :comment => "登録日時"
82
- t.datetime "updated_at", :comment => "更新日時"
83
- end
84
- end
85
-
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
+ ```
86
62
 
87
63
  コメントは、以下のメソッドで使用することが可能です。
88
64
 
65
+ ```
89
66
  columns, create_table, drop_table, rename_table
90
67
  remove_column, add_column, change_column
68
+ ```
91
69
 
92
70
 
93
71
  ## コメントはどこに保存されるのか
@@ -98,53 +76,66 @@ db/schema_comments.yml にYAML形式で保存されます。
98
76
 
99
77
  ## I18nへの対応
100
78
 
101
- rake i18n:schema_comments:update_config_locale
79
+ ```
80
+ rake i18n:schema_comments:update_config_locale
81
+ ```
102
82
 
103
83
  このタスクを実行すると、i18n用のYAMLを更新できます。
104
84
 
105
- rake i18n:schema_comments:update_config_locale LOCALE=ja
85
+ ```
86
+ rake i18n:schema_comments:update_config_locale LOCALE=ja
87
+ ```
106
88
 
107
89
  でデフォルトではconfig/locales/ja.ymlを更新します。
108
90
 
109
91
  毎回LOCALEを指定するのが面倒な場合は、config/initializers/locale.rb に
110
92
 
111
- I18n.default_locale = 'ja'
93
+ ```
94
+ I18n.default_locale = 'ja'
95
+ ```
112
96
 
113
97
  という記述を追加しておくと良いでしょう。
114
98
 
115
99
  また出力先のYAMLのPATHを指定したい場合、YAML_PATHで指定が可能です。
116
100
 
117
- rake i18n:schema_comments:update_config_locale LOCALE=ja YAML_PATH=/path/to/yaml
101
+ ```
102
+ rake i18n:schema_comments:update_config_locale LOCALE=ja YAML_PATH=/path/to/yaml
103
+ ```
118
104
 
119
105
  ### コメント内コメント
120
106
  コメント中の ((( から ))) は反映されませんので、モデル名/属性名に含めたくない箇所は ((( と ))) で括ってください。
121
107
  ((( ))) と同様に[[[ ]]]も使用できます。
122
108
  例えば以下のようにdb/schema.rbに出力されている場合、
123
109
 
124
- ActiveRecord::Schema.define(:version => 0) do
125
- create_table "products", :force => true, :comment => '商品' do |t|
126
- t.string "product_type_cd", :comment => '種別コード(((01:書籍, 02:靴, 03:パソコン)))'
127
- t.integer "price", :comment => "価格"
128
- t.string "name", :comment => "商品名"
129
- t.datetime "created_at", :comment => "登録日時"
130
- t.datetime "updated_at", :comment => "更新日時"
131
- end
132
- end
133
-
134
-
135
- rake i18n:schema_comments:update_config_locale LOCALE=ja
110
+ ```
111
+ ActiveRecord::Schema.define(:version => 0) do
112
+ create_table "products", :force => true, :comment => '商品' do |t|
113
+ t.string "product_type_cd", :comment => '種別コード(((01:書籍, 02:靴, 03:パソコン)))'
114
+ t.integer "price", :comment => "価格"
115
+ t.string "name", :comment => "商品名"
116
+ t.datetime "created_at", :comment => "登録日時"
117
+ t.datetime "updated_at", :comment => "更新日時"
118
+ end
119
+ end
120
+ ```
121
+
122
+ ```
123
+ $ rake i18n:schema_comments:update_config_locale LOCALE=ja
124
+ ```
136
125
 
137
126
  とすると、以下のように出力されます。
138
127
 
139
- ja:
140
- activerecord:
141
- attributes:
142
- product:
143
- product_type_cd: "種別コード"
144
- price: "価格"
145
- name: "商品名"
146
- created_at: "登録日時"
147
- updated_at: "更新日時"
128
+ ```
129
+ ja:
130
+ activerecord:
131
+ attributes:
132
+ product:
133
+ product_type_cd: "種別コード"
134
+ price: "価格"
135
+ name: "商品名"
136
+ created_at: "登録日時"
137
+ updated_at: "更新日時"
138
+ ```
148
139
 
149
140
 
150
141
 
@@ -159,22 +150,24 @@ test環境ではテーブルとして作成されてしまい、テストが正
159
150
  rake db:annotate で以下のようなコメントを、モデル、テスト、フィクスチャといったモデルに関係の強いファイルの
160
151
  先頭に追加します。
161
152
 
162
- # == Schema Info
163
- #
164
- # Schema version: 20090721185959
165
- #
166
- # Table name: books # 書籍
167
- #
168
- # id :integer not null, primary key
169
- # title :string(100) not null # タイトル
170
- # size :integer not null, default(1) # 判型
171
- # price :decimal(17, 14) not null, default(0.0) # 価格
172
- # created_at :datetime # 登録日時
173
- # updated_at :datetime # 更新日時
174
- #
175
- # =================
176
- #
177
-
153
+ ```
154
+ # == Schema Info
155
+ #
156
+ # Schema version: 20090721185959
157
+ #
158
+ # Table name: books # 書籍
159
+ #
160
+ # id :integer not null, primary key
161
+ # title :string(100) not null # タイトル
162
+ # size :integer not null, default(1) # 判型
163
+ # price :decimal(17, 14) not null, default(0.0) # 価格
164
+ # created_at :datetime # 登録日時
165
+ # updated_at :datetime # 更新日時
166
+ #
167
+ # =================
168
+ #
169
+ ```
170
+
178
171
  また、rake db:updateで、rake db:migrateとrake db:annotateを実行します。
179
172
 
180
173
  annotate_modelsは、達人プログラマーのDave Thomasさんが公開しているプラグインです。
@@ -5,6 +5,7 @@ require 'rails'
5
5
  module SchemaScomments
6
6
  class Railtie < ::Rails::Railtie
7
7
  rake_tasks do
8
+ SchemaComments.yaml_path = Rails.root.join("db/schema_comments.yml").to_s
8
9
  require 'schema_comments/task'
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module SchemaComments
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,9 +1,9 @@
1
1
  require 'active_support/core_ext/module'
2
2
 
3
+ require 'schema_comments/version'
3
4
  require 'schema_comments/railtie'
4
5
 
5
6
  module SchemaComments
6
- VERSION = File.read(File.expand_path("../../VERSION", __FILE__))
7
7
 
8
8
  autoload :Base , 'schema_comments/base'
9
9
  autoload :ConnectionAdapters, 'schema_comments/connection_adapters'
@@ -14,8 +14,6 @@ module SchemaComments
14
14
  autoload :SchemaDumper , 'schema_comments/schema_dumper'
15
15
 
16
16
  mattr_accessor :yaml_path
17
- self.yaml_path = Rails.root.join("db/schema_comments.yml").to_s if defined?(Rails) && Rails.root
18
-
19
17
  mattr_accessor :quiet
20
18
 
21
19
  class YamlError < StandardError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport