pg_comment 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/README.markdown +100 -0
- data/lib/pg_comment/version.rb +1 -1
- data/pg_comment.gemspec +1 -1
- data/test/postgre_sql_adapter_test.rb +5 -4
- data/test/schema_dumper_test.rb +1 -6
- data/test/test_helper.rb +16 -0
- metadata +21 -10
- data/README.rdoc +0 -83
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.markdown
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# PgComment
|
2
|
+
|
3
|
+
https://github.com/albertosaurus/pg_comment
|
4
|
+
|
5
|
+
In any PostgreSQL database where the Rails app is not the only consumer, it is very helpful to have comments
|
6
|
+
on the various elements of the schema. PgComment extends the migrations DSL with methods to set and remove
|
7
|
+
comments on columns and tables. It also dumps those comments into your schema.rb.
|
8
|
+
|
9
|
+
Obviously, only the PostgreSQL adapter is supported. All bug reports are welcome.
|
10
|
+
|
11
|
+
## NOTE:
|
12
|
+
|
13
|
+
I'm deprecating this in favor of PgPower: https://github.com/TMXCredit/pg_power It uses this db comment code,
|
14
|
+
plus gives all sorts of other goodies like schemas and partial indexes. Since it uses this very code to
|
15
|
+
support database comments, the comment syntax is 100% compatible.
|
16
|
+
|
17
|
+
## Requirements
|
18
|
+
|
19
|
+
* Ruby 1.8.7, Ruby 1.9.2, Ruby 1.9.3, JRuby 1.6+
|
20
|
+
* ActiveRecord 3.0, 3.1, 3.2
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add the following to the Gemfile of your Rails app:
|
25
|
+
|
26
|
+
gem 'pg_comment'
|
27
|
+
|
28
|
+
then run
|
29
|
+
|
30
|
+
bundle install
|
31
|
+
|
32
|
+
Alternatively you can manually install from RubyGems:
|
33
|
+
|
34
|
+
gem install pg_comment
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
PgComment adds five methods to the migrations DSL:
|
39
|
+
|
40
|
+
* `set_table_comment(table_name, comment)`
|
41
|
+
* `remove_table_comment(table_name)`
|
42
|
+
* `set_column_comment(table_name, column_name, comment)`
|
43
|
+
* `remove_column_comment(table_name, column_name, comment)`
|
44
|
+
* `set_column_comments(table_name, comments)`
|
45
|
+
* `remove_column_comments(table_name, *comments)`
|
46
|
+
|
47
|
+
## Examples
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# Set a comment on the given table.
|
51
|
+
set_table_comment :phone_numbers, 'This table stores phone numbers that conform to the North American Numbering Plan.'
|
52
|
+
|
53
|
+
# Sets a comment on a given column of a given table.
|
54
|
+
set_column_comment :phone_numbers, :npa, 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.'
|
55
|
+
|
56
|
+
# Removes any comment from the given table.
|
57
|
+
remove_table_comment :phone_numbers
|
58
|
+
|
59
|
+
# Removes any comment from the given column of a given table.
|
60
|
+
remove_column_comment :phone_numbers, :npa
|
61
|
+
|
62
|
+
# Set comments on multiple columns in the table.
|
63
|
+
set_column_comments :phone_numbers,
|
64
|
+
:npa => 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.',
|
65
|
+
:nxx => 'Central Office Number'
|
66
|
+
|
67
|
+
# Remove comments from multiple columns in the table.
|
68
|
+
remove_column_comments :phone_numbers, :npa, :nxx
|
69
|
+
```
|
70
|
+
|
71
|
+
PgComment also adds extra methods to change_table.
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
# Set comments:
|
75
|
+
change_table :phone_numbers do |t|
|
76
|
+
t.set_table_comment 'This table stores phone numbers that conform to the North American Numbering Plan.'
|
77
|
+
t.set_column_comment :npa, 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.'
|
78
|
+
end
|
79
|
+
|
80
|
+
change_table :phone_numbers do |t|
|
81
|
+
t.set_column_comments :npa => 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.',
|
82
|
+
:nxx => 'Central Office Number'
|
83
|
+
end
|
84
|
+
|
85
|
+
# Remove comments:
|
86
|
+
change_table :phone_numbers do |t|
|
87
|
+
t.remove_table_comment
|
88
|
+
t.remove_column_comment :npa
|
89
|
+
end
|
90
|
+
|
91
|
+
change_table :phone_numbers do |t|
|
92
|
+
t.remove_column_comments :npa, :nxx
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
Copyright (c) 2011-2013 Arthur Shagall, Mindflight, Inc.
|
99
|
+
|
100
|
+
Released under the MIT License. See LICENSE for details.
|
data/lib/pg_comment/version.rb
CHANGED
data/pg_comment.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency('activerecord', '
|
21
|
+
s.add_dependency('activerecord', '~> 3.0')
|
22
22
|
s.add_development_dependency("test-unit")
|
23
23
|
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
gem 'test-unit'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'pg_comment/connection_adapters/postgresql_adapter'
|
1
|
+
require 'test_helper'
|
5
2
|
|
6
3
|
class PostgreSQLAdapterTest < Test::Unit::TestCase
|
7
4
|
class Adapter
|
@@ -87,4 +84,8 @@ class PostgreSQLAdapterTest < Test::Unit::TestCase
|
|
87
84
|
end
|
88
85
|
end
|
89
86
|
|
87
|
+
def test_supports_comments
|
88
|
+
assert_true @adapter.supports_comments?
|
89
|
+
end
|
90
|
+
|
90
91
|
end
|
data/test/schema_dumper_test.rb
CHANGED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#require 'rubygems'
|
2
|
+
gem 'test-unit'
|
3
|
+
|
4
|
+
if require 'simplecov'
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter 'test/'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'active_record'
|
12
|
+
|
13
|
+
|
14
|
+
require 'pg_comment/connection_adapters/postgresql_adapter'
|
15
|
+
require 'fake_connection'
|
16
|
+
require 'pg_comment/schema_dumper'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_comment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.0
|
21
|
+
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: test-unit
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: Extends Rails migrations to support setting column and table comments. Pulls
|
37
47
|
out comments into schema.rb
|
38
48
|
email:
|
@@ -44,7 +54,7 @@ files:
|
|
44
54
|
- .gitignore
|
45
55
|
- Gemfile
|
46
56
|
- LICENSE
|
47
|
-
- README.
|
57
|
+
- README.markdown
|
48
58
|
- Rakefile
|
49
59
|
- lib/pg_comment.rb
|
50
60
|
- lib/pg_comment/connection_adapters/abstract/schema_definitions.rb
|
@@ -58,6 +68,7 @@ files:
|
|
58
68
|
- test/fake_connection.rb
|
59
69
|
- test/postgre_sql_adapter_test.rb
|
60
70
|
- test/schema_dumper_test.rb
|
71
|
+
- test/test_helper.rb
|
61
72
|
homepage: https://github.com/albertosaurus/pg_comment
|
62
73
|
licenses: []
|
63
74
|
post_install_message:
|
@@ -78,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
89
|
version: '0'
|
79
90
|
requirements: []
|
80
91
|
rubyforge_project: pg_comment
|
81
|
-
rubygems_version: 1.8.
|
92
|
+
rubygems_version: 1.8.25
|
82
93
|
signing_key:
|
83
94
|
specification_version: 3
|
84
95
|
summary: Postgres Comments for Rails
|
data/README.rdoc
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
= PgComment
|
2
|
-
|
3
|
-
In any PostgreSQL database where the Rails app is not the only consumer, it is very helpful to have comments on the various database entities. PgComment adds methods to migrations to set and remove comments on columns and tables.
|
4
|
-
|
5
|
-
Obviously, only the PostgreSQL adapter is supported.
|
6
|
-
|
7
|
-
== Warning
|
8
|
-
|
9
|
-
This is still somewhat experimental. It has to date been tested with:
|
10
|
-
|
11
|
-
* Ruby
|
12
|
-
- 1.8.7 REE
|
13
|
-
- 1.9.2 YARV
|
14
|
-
- JRuby 1.6.4
|
15
|
-
* Rails
|
16
|
-
- 3.0.10
|
17
|
-
- 3.1
|
18
|
-
|
19
|
-
All bug reports are welcome.
|
20
|
-
|
21
|
-
== Installation
|
22
|
-
|
23
|
-
Assuming you're using RubyGems:
|
24
|
-
|
25
|
-
gem install pg_comment
|
26
|
-
|
27
|
-
== Usage
|
28
|
-
|
29
|
-
PgComment adds five methods to migrations:
|
30
|
-
|
31
|
-
* set_table_comment(table_name, comment)
|
32
|
-
* remove_table_comment(table_name)
|
33
|
-
* set_column_comment(table_name, column_name, comment)
|
34
|
-
* remove_column_comment(table_name, column_name, comment)
|
35
|
-
* set_column_comments(table_name, comments)
|
36
|
-
|
37
|
-
Set a comment on the given table.
|
38
|
-
|
39
|
-
set_table_comment :phone_numbers, 'This table stores phone numbers that conform to the North American Numbering Plan.'
|
40
|
-
|
41
|
-
Sets a comment on a given column of a given table.
|
42
|
-
|
43
|
-
set_column_comment :phone_numbers, :npa, 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.'
|
44
|
-
|
45
|
-
Removes any comment from the given table.
|
46
|
-
|
47
|
-
remove_table_comment :phone_numbers
|
48
|
-
|
49
|
-
Removes any comment from the given column of a given table.
|
50
|
-
|
51
|
-
remove_column_comment :phone_numbers, :npa
|
52
|
-
|
53
|
-
Set comments on multiple columns in the table.
|
54
|
-
|
55
|
-
set_column_comments :phone_numbers, :npa => 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.',
|
56
|
-
:nxx => 'Central Office Number'
|
57
|
-
|
58
|
-
PgComment also adds extra methods to change_table.
|
59
|
-
|
60
|
-
Set comments:
|
61
|
-
|
62
|
-
change_table :phone_numbers do |t|
|
63
|
-
t.set_table_comment 'This table stores phone numbers that conform to the North American Numbering Plan.'
|
64
|
-
t.set_column_comment :npa, 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.'
|
65
|
-
end
|
66
|
-
|
67
|
-
change_table :phone_numbers do |t|
|
68
|
-
t.set_column_comments :npa => 'Numbering Plan Area Code - Allowed ranges: [2-9] for first digit, [0-9] for second and third digit.',
|
69
|
-
:nxx => 'Central Office Number'
|
70
|
-
end
|
71
|
-
|
72
|
-
Remove comments:
|
73
|
-
|
74
|
-
change_table :phone_numbers do |t|
|
75
|
-
t.remove_table_comment
|
76
|
-
t.remove_column_comment :npa
|
77
|
-
end
|
78
|
-
|
79
|
-
== License
|
80
|
-
|
81
|
-
Copyright (c) 2011 Arthur Shagall
|
82
|
-
|
83
|
-
Released under the MIT License. See LICENSE for details.
|