annotato 0.2.2 → 0.2.4

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
  SHA256:
3
- metadata.gz: 3f4f23141ac1d1c1d74db46f6e08a7897f013145cecedf862bf0daf1d5cf0e7c
4
- data.tar.gz: 1b6c975c452b3673e346aed16aef4574bd7ccabd6cd1b1a4a01140e6b18e3a69
3
+ metadata.gz: 7495fe2d16ba0203b006d5cdae3e4106d0cb3f11b28b76086f9ce01b8b5d32a3
4
+ data.tar.gz: d5099b1821edd37536742c8eab1d30df30ac445e949ae5620a13907338e095c9
5
5
  SHA512:
6
- metadata.gz: 9f3e75090cc665121ecb20fd2ae0c626f10fd3572f7f25a35559130769e6a8093226f94e6c9b43eec88b51dd148c00401fd74687f36b7d8bc62e39532ac672ce
7
- data.tar.gz: 6faa3c85c724fb087868ab7768699bdf6f5f07aa943362367110680899b7eb69842e7ebab396cfc3f6e17b3d70cc0bff1e7c3d83335601b0475452d1a3ca4e71
6
+ metadata.gz: 958ef330cd3a75c32518e90648e1e50771552d9edc24ddbf862497c09ca0d05ac6d1a1f1c59d97252e52fb7760a97bebd9a423f73b41789eb49035a1f8f189ca
7
+ data.tar.gz: c303fd131c8dee8c2e78dcb71dae2c640338acad8e3ea5f7efe846f0d081a4fa35c5da02caae39de42c2cc9e95d04c0363753fc608e1dcc18148b56567ba7873
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- annotato (0.2.2)
4
+ annotato (0.2.4)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
@@ -26,11 +26,12 @@ module Annotato
26
26
  type = col.sql_type
27
27
 
28
28
  # Build the left-hand side and calculate indent.
29
- left = "# %-#{name_width}s :%-#{type_width}s" % [name, type]
30
- # " default(" is 9 chars; +2 gives the extra gap.
29
+ # Strip trailing padding spaces immediately — output must never have trailing whitespace.
30
+ left = ("# %-#{name_width}s :%-#{type_width}s" % [name, type]).rstrip
31
+ # indent_size aligns multiline default content under the opening "default(" token.
31
32
  indent_size = left.length + 1
32
33
  indent_str = " " * indent_size
33
- closing_indent_str = " " * (indent_size - 2)
34
+ closing_indent_str = " " * (indent_size - 2)
34
35
 
35
36
  # Gather all options, pulling out default_lines if multiline.
36
37
  opts = []
@@ -64,10 +65,9 @@ module Annotato
64
65
  opts_str = opts.join(", ")
65
66
  line = opts_str.empty? ? left : "#{left} #{opts_str}"
66
67
  if line.length > WrapHelper::MAX_LINE && !opts_str.empty?
67
- cont_indent = " " * (left.length + 1)
68
- [left, "# #{cont_indent}#{opts_str}"]
68
+ [left, "# #{opts_str}"]
69
69
  else
70
- [line.rstrip]
70
+ [line]
71
71
  end
72
72
  end
73
73
  end
@@ -8,19 +8,18 @@ module Annotato
8
8
  class EnumFormatter
9
9
  def self.format(conn, columns)
10
10
  # Collect columns backed by a native PG enum type.
11
- # A native enum type is one that exists in pg_type with typtype = 'e'.
12
11
  enum_columns = columns.select { |col| pg_enum_type?(conn, col.sql_type) }
13
12
  return [] if enum_columns.empty?
14
13
 
15
- enum_columns.map do |col|
14
+ enum_columns.flat_map do |col|
16
15
  labels = pg_enum_labels(conn, col.sql_type)
17
16
  lines = ["# #{col.name} (#{col.sql_type}): ["]
18
- lines += labels.map.with_index { |label, i|
17
+ labels.each_with_index do |label, i|
19
18
  comma = i == labels.size - 1 ? "" : ","
20
- "# #{label}#{comma}"
21
- }
19
+ lines << "# #{label}#{comma}"
20
+ end
22
21
  lines << "# ]"
23
- lines.join("\n")
22
+ lines
24
23
  end
25
24
  end
26
25
 
@@ -40,7 +39,7 @@ module Annotato
40
39
  conn.exec_query(
41
40
  "SELECT e.enumlabel FROM pg_enum e " \
42
41
  "JOIN pg_type t ON e.enumtypid = t.oid " \
43
- "WHERE t.typname = $1 " \
42
+ "WHERE t.typname = $1 AND t.typtype = 'e' " \
44
43
  "ORDER BY e.enumsortorder",
45
44
  "SQL",
46
45
  [type_name]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Annotato
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii Bodnaruk