migration_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.
data/README.rdoc
CHANGED
@@ -4,9 +4,9 @@ Comments for your migrations
|
|
4
4
|
|
5
5
|
Tested on:
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
ActiveRecord 4.x:: using Ruby 1.9.3 / 2.0
|
8
|
+
ActiveRecord 3.x:: using Ruby 1.8.7 / 1.9.x / 2.0
|
9
|
+
ActiveRecord 2.3.x (deprecated):: using Ruby 1.8.6 / 1.8.7
|
10
10
|
|
11
11
|
== Why?
|
12
12
|
|
@@ -22,11 +22,11 @@ Using MigrationComments, you can simply add comments during your migrations. Or
|
|
22
22
|
have existing data structures, just add the comments afterwards in a separate migration. And of
|
23
23
|
course you can always modify and delete these comments in later migrations.
|
24
24
|
|
25
|
-
So where are these comments used? Firstly, they will be included in your schema.rb dump which
|
26
|
-
is where your IDE (e.g. RubyMine) should be learning about your model structure. This means that
|
27
|
-
they'll be available at any point in your project. Additionally, if you are using the
|
28
|
-
gem, these comments will be added to the annotations
|
29
|
-
file.
|
25
|
+
So where are these comments used? Firstly, they will be included in your <tt>schema.rb</tt> dump which
|
26
|
+
is where your IDE (e.g. RubyMine, TextMate) should be learning about your model structure. This means that
|
27
|
+
they'll be available at any point in your project. Additionally, if you are using the
|
28
|
+
'annotate'[https://github.com/ctran/annotate_models] gem, these comments will be added to the annotations
|
29
|
+
that are generated within your <tt>_model_.rb</tt> file.
|
30
30
|
|
31
31
|
== Examples
|
32
32
|
|
@@ -37,7 +37,7 @@ To add a comment to an existing structure...
|
|
37
37
|
set_column_comment :table_name, :column_name, "A column comment"
|
38
38
|
end
|
39
39
|
|
40
|
-
Or you can use the change_table macro...
|
40
|
+
Or you can use the <tt>change_table</tt> macro...
|
41
41
|
|
42
42
|
def self.up
|
43
43
|
change_table :table_name do |t|
|
@@ -37,13 +37,13 @@ module MigrationComments::ActiveRecord::ConnectionAdapters
|
|
37
37
|
result.inject({}){|m, row| m[row[0].to_sym] = (row[1].blank? ? nil : row[1]); m}
|
38
38
|
end
|
39
39
|
|
40
|
-
def create_table_with_migration_comments(table_name, options={}
|
40
|
+
def create_table_with_migration_comments(table_name, options={})
|
41
41
|
local_table_definition = nil
|
42
42
|
create_table_without_migration_comments(table_name, options) do |td|
|
43
43
|
local_table_definition = td
|
44
44
|
local_table_definition.base = self
|
45
45
|
local_table_definition.comment options[:comment] if options.has_key?(:comment)
|
46
|
-
|
46
|
+
yield td if block_given?
|
47
47
|
end
|
48
48
|
comments = local_table_definition.collect_comments(table_name)
|
49
49
|
comments.each do |comment_definition|
|
@@ -33,13 +33,13 @@ module MigrationComments::ActiveRecord::ConnectionAdapters
|
|
33
33
|
return result.inject({}){|m, row| m[row[0].to_sym] = row[1]; m}
|
34
34
|
end
|
35
35
|
|
36
|
-
def create_table_with_migration_comments(table_name, options = {}
|
36
|
+
def create_table_with_migration_comments(table_name, options = {})
|
37
37
|
local_table_definition = nil
|
38
38
|
create_table_without_migration_comments(table_name, options) do |td|
|
39
39
|
local_table_definition = td
|
40
40
|
local_table_definition.base = self
|
41
41
|
local_table_definition.comment options[:comment] if options.has_key?(:comment)
|
42
|
-
|
42
|
+
yield td if block_given?
|
43
43
|
end
|
44
44
|
comments = local_table_definition.collect_comments(table_name)
|
45
45
|
comments.each do |comment_definition|
|
data/test/add_comments_test.rb
CHANGED
@@ -26,6 +26,12 @@ class AddCommentsTest < Test::Unit::TestCase
|
|
26
26
|
assert_nil result_field2
|
27
27
|
end
|
28
28
|
|
29
|
+
def test_creating_a_table_with_table_comments_and_no_block
|
30
|
+
ActiveRecord::Schema.define do
|
31
|
+
create_table :sample3, :temporary => true, :comment => "a table comment"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
29
35
|
def test_creating_a_table_with_table_and_column_comments
|
30
36
|
table_comment = "a table comment"
|
31
37
|
column_comment = "a column comment"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
segments:
|
146
146
|
- 0
|
147
|
-
hash:
|
147
|
+
hash: -3400320072112058526
|
148
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
segments:
|
155
155
|
- 0
|
156
|
-
hash:
|
156
|
+
hash: -3400320072112058526
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project: migration_comments
|
159
159
|
rubygems_version: 1.8.25
|