ahnnotate 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ahnnotate/column.rb +2 -2
- data/lib/ahnnotate/tables.rb +53 -46
- data/lib/ahnnotate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14bcad2d733058ad421c5e107460aed3db606df535cb805f8cc8637f475edee
|
4
|
+
data.tar.gz: e5dc4b278e7a2088d79dc21901558e81f4b028c58671c3dddff9957c1e36804c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6713b0fd862f104a971faf98e643806ed1860599caab15e26d925451a9b75f56f406a3208c382aabd995d8f9f9a12acc9d0c503b7460491bd3908ef1e1892c84
|
7
|
+
data.tar.gz: 132a919729c31aaaecd621fd981ea840ba00abf96478be13ea62402f4d2c5a539fb0bf5f07b63b2c23a9b32d4ad6c9bbd9e425d03f8e8755cc273c0b45b67c5f
|
data/Gemfile.lock
CHANGED
data/lib/ahnnotate/column.rb
CHANGED
@@ -10,8 +10,8 @@ module Ahnnotate
|
|
10
10
|
map["character"] = "char"
|
11
11
|
map["datetime"] = "timestamp"
|
12
12
|
map["double precision"] = "double"
|
13
|
-
map["time with time zone"] = "
|
14
|
-
map["time without time zone"] = "
|
13
|
+
map["time with time zone"] = "timetz"
|
14
|
+
map["time without time zone"] = "time"
|
15
15
|
map["timestamp with time zone"] = "timestamptz"
|
16
16
|
map["timestamp without time zone"] = "timestamp"
|
17
17
|
map
|
data/lib/ahnnotate/tables.rb
CHANGED
@@ -17,59 +17,66 @@ module Ahnnotate
|
|
17
17
|
end
|
18
18
|
|
19
19
|
@connection.public_send(data_sources_method_name).each do |table_name|
|
20
|
-
|
20
|
+
begin
|
21
|
+
original_stderr = $stderr
|
22
|
+
$stderr = StringIO.new
|
21
23
|
|
22
|
-
|
23
|
-
is_primary_key =
|
24
|
-
if primary_key.is_a?(Array)
|
25
|
-
primary_key.include?(c.name)
|
26
|
-
else
|
27
|
-
primary_key == c.name
|
28
|
-
end
|
24
|
+
primary_key = ActiveRecord::Base.get_primary_key(table_name)
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
26
|
+
columns = @connection.columns(table_name).map do |c|
|
27
|
+
is_primary_key =
|
28
|
+
if primary_key.is_a?(Array)
|
29
|
+
primary_key.include?(c.name)
|
30
|
+
else
|
31
|
+
primary_key == c.name
|
32
|
+
end
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
Column.new(
|
35
|
+
name: c.name,
|
36
|
+
sql_type: c.sql_type,
|
37
|
+
nullable: c.null,
|
38
|
+
primary_key: is_primary_key,
|
39
|
+
default: c.default
|
40
|
+
)
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
)
|
51
|
-
end
|
43
|
+
indexes = @connection.indexes(table_name).map do |i|
|
44
|
+
comment =
|
45
|
+
if i.respond_to?(:comment)
|
46
|
+
i.comment
|
47
|
+
end
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
to_table: fk.to_table,
|
60
|
-
to_column: fk.primary_key
|
61
|
-
)
|
62
|
-
end
|
63
|
-
else
|
64
|
-
[]
|
49
|
+
Index.new(
|
50
|
+
name: i.name,
|
51
|
+
columns: i.columns,
|
52
|
+
unique: i.unique,
|
53
|
+
comment: comment
|
54
|
+
)
|
65
55
|
end
|
66
56
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
57
|
+
foreign_keys =
|
58
|
+
if @abilities.foreign_key?
|
59
|
+
@connection.foreign_keys(table_name).map do |fk|
|
60
|
+
ForeignKey.new(
|
61
|
+
name: fk.name,
|
62
|
+
from_column: fk.column,
|
63
|
+
to_table: fk.to_table,
|
64
|
+
to_column: fk.primary_key
|
65
|
+
)
|
66
|
+
end
|
67
|
+
else
|
68
|
+
[]
|
69
|
+
end
|
70
|
+
|
71
|
+
yield Table.new(
|
72
|
+
name: table_name,
|
73
|
+
columns: columns,
|
74
|
+
indexes: indexes,
|
75
|
+
foreign_keys: foreign_keys,
|
76
|
+
)
|
77
|
+
ensure
|
78
|
+
$stderr = original_stderr
|
79
|
+
end
|
73
80
|
end
|
74
81
|
end
|
75
82
|
|
data/lib/ahnnotate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahnnotate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Ahn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|