sequel-annotate 1.4.0 → 1.5.0

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: 00ae8faeab78d5bf3db91c08be72e190c23c5937aff9a134b0f60d8a8a28fd46
4
- data.tar.gz: 3324fec486219f6324ff300046ee1f80608c84621f3eb159e5192a0e7f42bdbf
3
+ metadata.gz: cbe18cf12eced99b6453d25c4e7194e807ac4e9aad1e21d0371c72452dd6d2f4
4
+ data.tar.gz: 442da3e19cf3a387f0a73aede9f6c16219d7984338b777a85a2d4d04053a1f28
5
5
  SHA512:
6
- metadata.gz: 898b3c06f2728c69570071f04b14b506925d87e794b63fdbe0882bc710e03fc76c6c824f0c01384f96e19b1ee59894766722fa4bb12c668068794d632c3651c7
7
- data.tar.gz: 0ac394e89f13a0d8f005b90ff7263fe882ce67aca63f9d19b7327d0561eb7666df04cb6e4031a01ad6f318c87372b7d59ae9aba39b38e0ffed870036ad1ff035
6
+ metadata.gz: 2c01cfbc83195c28c29c458517ef9ea54ee9b40e5c3ac9faa70bb97db1c458a65e82496772d43faa89289da9f0f22ede013169a7a37da24721c1de4b82b046db
7
+ data.tar.gz: 566f31d7ebdc2e86dce167327c0ec4ead26d5755ff5621334421f6fef54eba16d6b84c1e7e6e5b44fe42f9bb29c78b2482cbba0eda38c730bc28574e08e731cd
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ === 1.5.0 (2020-05-04)
2
+
3
+ * Add support for magic comments in model files when using the :position=>:before option (qortex, jeremyevans) (#15)
4
+
5
+ * Add support for PostgreSQL column comments (rgalanakis, jeremyevans) (#14)
6
+
7
+ * Respect domain types on PostgreSQL (chanks) (#13)
8
+
9
+ * Make schema comments handle table names that aren't just symbols (chanks) (#12)
10
+
1
11
  === 1.4.0 (2018-11-15)
2
12
 
3
13
  * Support adding borders to the beginning and end of comments via :border option (kreynolds) (#9)
@@ -5,7 +5,7 @@ default, it includes information on columns, indexes, and foreign key
5
5
  constraints for the current table.
6
6
 
7
7
  On PostgreSQL, this includes more advanced information, including
8
- check constraints, triggers, and foreign keys constraints for other
8
+ check constraints, triggers, comments, and foreign keys constraints for other
9
9
  tables that reference the current table.
10
10
 
11
11
  == Example
@@ -84,9 +84,10 @@ Then you can use the +:namespace+ option to set the namespace to use:
84
84
  Sequel::Annotate.annotate(Dir['models/*.rb'], namespace: 'ModelNamespace')
85
85
 
86
86
  For PostgreSQL, you can optionally leave out indexes, foreign_keys, references,
87
- triggers, and constraints by passing in false as a parameter as follows:
87
+ triggers, comments, and constraints by passing in false as a parameter as follows:
88
88
 
89
- Sequel::Annotate.annotate(Dir['models/*.rb'], foreign_keys: false, :indexes: false, constraints: false)
89
+ Sequel::Annotate.annotate(Dir['models/*.rb'], foreign_keys: false,
90
+ :indexes: false, constraints: false, comments: false)
90
91
 
91
92
  The columns section can have a border on the top and bottom for easier visual distinction by setting the :border option to true
92
93
 
@@ -40,8 +40,13 @@ module Sequel
40
40
  orig = current = File.read(path).rstrip
41
41
 
42
42
  if options[:position] == :before
43
+ if current =~ /\A((?:^\s*$|^#\s*(?:frozen_string_literal|coding|encoding|warn_indent|warn_past_scope)[^\n]*\s*)*)/m
44
+ magic_comments = $1
45
+ current.slice!(0, magic_comments.length)
46
+ end
47
+
43
48
  current = current.gsub(/\A#\sTable[^\n\r]+\r?\n(?:#[^\n\r]*\r?\n)*/m, '').lstrip
44
- current = "#{schema_comment(options)}#{$/}#{$/}#{current}"
49
+ current = "#{magic_comments}#{schema_comment(options)}#{$/}#{$/}#{current}"
45
50
  else
46
51
  if m = current.reverse.match(/#{"#{$/}# Table: ".reverse}/m)
47
52
  offset = current.length - m.end(0) + 1
@@ -80,7 +85,7 @@ module Sequel
80
85
  # :triggers :: Do not include triggers in annotation if set to +false+.
81
86
  def schema_comment(options = {})
82
87
  output = []
83
- output << "# Table: #{model.table_name}"
88
+ output << "# Table: #{model.dataset.with_quote_identifiers(false).literal(model.table_name)}"
84
89
 
85
90
  meth = :"_schema_comment_#{model.db.database_type}"
86
91
  if respond_to?(meth, true)
@@ -215,15 +220,38 @@ SQL
215
220
  end
216
221
  end
217
222
 
223
+ def _column_comments_postgres
224
+ model.db.fetch(<<SQL, :oid=>model.db.send(:regclass_oid, model.table_name)).to_hash(:attname, :description)
225
+ SELECT a.attname, d.description
226
+ FROM pg_description d
227
+ JOIN pg_attribute a ON (d.objoid = a.attrelid AND d.objsubid = a.attnum)
228
+ WHERE d.objoid = :oid AND COALESCE(d.description, '') != '';
229
+ SQL
230
+ end
231
+
218
232
  # The standard column schema information to output.
219
233
  def schema_comment_columns(output, options = {})
220
234
  if cpk = model.primary_key.is_a?(Array)
221
235
  output << "# Primary Key: (#{model.primary_key.join(', ')})"
222
236
  end
223
237
  output << "# Columns:"
238
+
239
+ meth = :"_column_comments_#{model.db.database_type}"
240
+ column_comments = if options[:comments] != false && respond_to?(meth, true)
241
+ send(meth)
242
+ else
243
+ {}
244
+ end
245
+
224
246
  rows = model.columns.map do |col|
225
247
  sch = model.db_schema[col]
226
- [col.to_s, sch[:db_type], "#{"PRIMARY KEY #{"AUTOINCREMENT " if sch[:auto_increment] && model.db.database_type != :postgres}" if sch[:primary_key] && !cpk}#{"NOT NULL " if sch[:allow_null] == false && !sch[:primary_key]}#{"DEFAULT #{sch[:default]}" if sch[:default]}#{"GENERATED BY DEFAULT AS IDENTITY" if sch[:auto_increment] && !sch[:default] && model.db.database_type == :postgres && model.db.server_version >= 100000}"]
248
+ parts = [
249
+ col.to_s,
250
+ sch[:db_domain_type] || sch[:db_type],
251
+ "#{"PRIMARY KEY #{"AUTOINCREMENT " if sch[:auto_increment] && model.db.database_type != :postgres}" if sch[:primary_key] && !cpk}#{"NOT NULL " if sch[:allow_null] == false && !sch[:primary_key]}#{"DEFAULT #{sch[:default]}" if sch[:default]}#{"GENERATED BY DEFAULT AS IDENTITY" if sch[:auto_increment] && !sch[:default] && model.db.database_type == :postgres && model.db.server_version >= 100000}",
252
+ ]
253
+ parts << (column_comments[col.to_s] || '') unless column_comments.empty?
254
+ parts
227
255
  end
228
256
  output.concat(align(rows))
229
257
  end
@@ -0,0 +1,20 @@
1
+ # coding: xyz
2
+
3
+ class SItemWithCoding < Sequel::Model(SDB[:items])
4
+ end
5
+
6
+ # Table: items
7
+ # Columns:
8
+ # id | integer | PRIMARY KEY AUTOINCREMENT
9
+ # category_id | integer | NOT NULL
10
+ # manufacturer_name | varchar(50) |
11
+ # manufacturer_location | varchar(255) |
12
+ # in_stock | boolean | DEFAULT 0
13
+ # name | varchar(255) | DEFAULT 'John'
14
+ # price | double precision | DEFAULT 0
15
+ # Indexes:
16
+ # manufacturer_name | (manufacturer_name)
17
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
18
+ # Foreign key constraints:
19
+ # (category_id) REFERENCES categories
20
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ class SItemWithEncoding < Sequel::Model(SDB[:items])
4
+ end
5
+
6
+ # Table: items
7
+ # Columns:
8
+ # id | integer | PRIMARY KEY AUTOINCREMENT
9
+ # category_id | integer | NOT NULL
10
+ # manufacturer_name | varchar(50) |
11
+ # manufacturer_location | varchar(255) |
12
+ # in_stock | boolean | DEFAULT 0
13
+ # name | varchar(255) | DEFAULT 'John'
14
+ # price | double precision | DEFAULT 0
15
+ # Indexes:
16
+ # manufacturer_name | (manufacturer_name)
17
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
18
+ # Foreign key constraints:
19
+ # (category_id) REFERENCES categories
20
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SItemWithFrozenLiteral < Sequel::Model(SDB[:items])
4
+ end
5
+
6
+ # Table: items
7
+ # Columns:
8
+ # id | integer | PRIMARY KEY AUTOINCREMENT
9
+ # category_id | integer | NOT NULL
10
+ # manufacturer_name | varchar(50) |
11
+ # manufacturer_location | varchar(255) |
12
+ # in_stock | boolean | DEFAULT 0
13
+ # name | varchar(255) | DEFAULT 'John'
14
+ # price | double precision | DEFAULT 0
15
+ # Indexes:
16
+ # manufacturer_name | (manufacturer_name)
17
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
18
+ # Foreign key constraints:
19
+ # (category_id) REFERENCES categories
20
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
@@ -0,0 +1,20 @@
1
+ # warn_indent: true
2
+
3
+ class SItemWithWarnIndent < Sequel::Model(SDB[:items])
4
+ end
5
+
6
+ # Table: items
7
+ # Columns:
8
+ # id | integer | PRIMARY KEY AUTOINCREMENT
9
+ # category_id | integer | NOT NULL
10
+ # manufacturer_name | varchar(50) |
11
+ # manufacturer_location | varchar(255) |
12
+ # in_stock | boolean | DEFAULT 0
13
+ # name | varchar(255) | DEFAULT 'John'
14
+ # price | double precision | DEFAULT 0
15
+ # Indexes:
16
+ # manufacturer_name | (manufacturer_name)
17
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
18
+ # Foreign key constraints:
19
+ # (category_id) REFERENCES categories
20
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
@@ -0,0 +1,21 @@
1
+ # warn_past_scope: true
2
+ # warn_indent: false
3
+ # Additional comment that should stay
4
+ class SItemWithWarnPastScope < Sequel::Model(SDB[:items])
5
+ end
6
+
7
+ # Table: items
8
+ # Columns:
9
+ # id | integer | PRIMARY KEY AUTOINCREMENT
10
+ # category_id | integer | NOT NULL
11
+ # manufacturer_name | varchar(50) |
12
+ # manufacturer_location | varchar(255) |
13
+ # in_stock | boolean | DEFAULT 0
14
+ # name | varchar(255) | DEFAULT 'John'
15
+ # price | double precision | DEFAULT 0
16
+ # Indexes:
17
+ # manufacturer_name | (manufacturer_name)
18
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
19
+ # Foreign key constraints:
20
+ # (category_id) REFERENCES categories
21
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
@@ -0,0 +1,20 @@
1
+ # coding: xyz
2
+
3
+ # Table: items
4
+ # Columns:
5
+ # id | integer | PRIMARY KEY AUTOINCREMENT
6
+ # category_id | integer | NOT NULL
7
+ # manufacturer_name | varchar(50) |
8
+ # manufacturer_location | varchar(255) |
9
+ # in_stock | boolean | DEFAULT 0
10
+ # name | varchar(255) | DEFAULT 'John'
11
+ # price | double precision | DEFAULT 0
12
+ # Indexes:
13
+ # manufacturer_name | (manufacturer_name)
14
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
15
+ # Foreign key constraints:
16
+ # (category_id) REFERENCES categories
17
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
18
+
19
+ class SItemWithCoding < Sequel::Model(SDB[:items])
20
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ # Table: items
4
+ # Columns:
5
+ # id | integer | PRIMARY KEY AUTOINCREMENT
6
+ # category_id | integer | NOT NULL
7
+ # manufacturer_name | varchar(50) |
8
+ # manufacturer_location | varchar(255) |
9
+ # in_stock | boolean | DEFAULT 0
10
+ # name | varchar(255) | DEFAULT 'John'
11
+ # price | double precision | DEFAULT 0
12
+ # Indexes:
13
+ # manufacturer_name | (manufacturer_name)
14
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
15
+ # Foreign key constraints:
16
+ # (category_id) REFERENCES categories
17
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
18
+
19
+ class SItemWithEncoding < Sequel::Model(SDB[:items])
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Table: items
4
+ # Columns:
5
+ # id | integer | PRIMARY KEY AUTOINCREMENT
6
+ # category_id | integer | NOT NULL
7
+ # manufacturer_name | varchar(50) |
8
+ # manufacturer_location | varchar(255) |
9
+ # in_stock | boolean | DEFAULT 0
10
+ # name | varchar(255) | DEFAULT 'John'
11
+ # price | double precision | DEFAULT 0
12
+ # Indexes:
13
+ # manufacturer_name | (manufacturer_name)
14
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
15
+ # Foreign key constraints:
16
+ # (category_id) REFERENCES categories
17
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
18
+
19
+ class SItemWithFrozenLiteral < Sequel::Model(SDB[:items])
20
+ end
@@ -0,0 +1,20 @@
1
+ # warn_indent: true
2
+
3
+ # Table: items
4
+ # Columns:
5
+ # id | integer | PRIMARY KEY AUTOINCREMENT
6
+ # category_id | integer | NOT NULL
7
+ # manufacturer_name | varchar(50) |
8
+ # manufacturer_location | varchar(255) |
9
+ # in_stock | boolean | DEFAULT 0
10
+ # name | varchar(255) | DEFAULT 'John'
11
+ # price | double precision | DEFAULT 0
12
+ # Indexes:
13
+ # manufacturer_name | (manufacturer_name)
14
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
15
+ # Foreign key constraints:
16
+ # (category_id) REFERENCES categories
17
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
18
+
19
+ class SItemWithWarnIndent < Sequel::Model(SDB[:items])
20
+ end
@@ -0,0 +1,21 @@
1
+ # warn_past_scope: true
2
+ # warn_indent: false
3
+ # Table: items
4
+ # Columns:
5
+ # id | integer | PRIMARY KEY AUTOINCREMENT
6
+ # category_id | integer | NOT NULL
7
+ # manufacturer_name | varchar(50) |
8
+ # manufacturer_location | varchar(255) |
9
+ # in_stock | boolean | DEFAULT 0
10
+ # name | varchar(255) | DEFAULT 'John'
11
+ # price | double precision | DEFAULT 0
12
+ # Indexes:
13
+ # manufacturer_name | (manufacturer_name)
14
+ # name | UNIQUE (manufacturer_name, manufacturer_location)
15
+ # Foreign key constraints:
16
+ # (category_id) REFERENCES categories
17
+ # (manufacturer_name, manufacturer_location) REFERENCES manufacturers
18
+
19
+ # Additional comment that should stay
20
+ class SItemWithWarnPastScope < Sequel::Model(SDB[:items])
21
+ end
@@ -4,7 +4,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), '../lib/sequel/annot
4
4
 
5
5
  ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
6
6
  gem 'minitest'
7
- require 'minitest/autorun'
7
+ require 'minitest/global_expectations/autorun'
8
8
 
9
9
  DB = Sequel.connect(ENV['SEQUEL_ANNOTATE_SPEC_POSTGRES_URL'] || 'postgres:///sequel_annotate_test?user=sequel_annotate&password=sequel_annotate')
10
10
  raise "test database name doesn't end with test" unless DB.get{current_database.function} =~ /test\z/
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  DB.drop_function(:valid_price) rescue nil
18
18
  [DB, SDB].each do |db|
19
- db.drop_table?(:newline_tests, :items, :manufacturers, :categories)
19
+ db.drop_table?(:newline_tests, :items, :manufacturers, :categories, :comment_tests)
20
20
 
21
21
  db.create_table :categories do
22
22
  primary_key :id
@@ -32,7 +32,7 @@ DB.drop_function(:valid_price) rescue nil
32
32
  db.create_table :items do
33
33
  primary_key :id
34
34
  foreign_key :category_id, :categories, :null => false
35
- foreign_key [:manufacturer_name, :manufacturer_location], :manufacturers
35
+ foreign_key [:manufacturer_name, :manufacturer_location], :manufacturers, :name=>:items_manufacturer_name_fkey
36
36
 
37
37
  String :manufacturer_name, :size => 50
38
38
  String :manufacturer_location
@@ -70,18 +70,41 @@ CREATE TRIGGER valid_price BEFORE INSERT OR UPDATE ON items
70
70
  FOR EACH ROW EXECUTE PROCEDURE valid_price();
71
71
  SQL
72
72
 
73
+ DB.run "CREATE DOMAIN test_domain AS text"
74
+
75
+ DB.create_table :domain_tests do
76
+ primary_key :id
77
+ test_domain :test_column
78
+ end
79
+
80
+ DB.create_table :comment_tests do
81
+ primary_key :id
82
+ String :name
83
+ end
84
+
85
+ DB.run "COMMENT ON COLUMN comment_tests.name IS 'name column comment'"
86
+
73
87
  Minitest.after_run do
74
- DB.drop_table(:items, :manufacturers, :categories)
88
+ DB.drop_table(:items, :manufacturers, :categories, :domain_tests, :comment_tests)
89
+ DB.run "DROP DOMAIN test_domain"
75
90
  DB.drop_function(:valid_price)
76
91
  end
77
92
 
78
93
  class ::Item < Sequel::Model; end
79
94
  class ::Category < Sequel::Model; end
80
95
  class ::Manufacturer < Sequel::Model; end
96
+ class ::DomainTest < Sequel::Model; end
97
+ class ::CommentTest < Sequel::Model; end
81
98
  class ::SItem < Sequel::Model(SDB[:items]); end
99
+ class ::SItemWithFrozenLiteral < Sequel::Model(SDB[:items]); end
100
+ class ::SItemWithCoding < Sequel::Model(SDB[:items]); end
101
+ class ::SItemWithEncoding < Sequel::Model(SDB[:items]); end
102
+ class ::SItemWithWarnIndent < Sequel::Model(SDB[:items]); end
103
+ class ::SItemWithWarnPastScope < Sequel::Model(SDB[:items]); end
82
104
  class ::SCategory < Sequel::Model(SDB[:categories]); end
83
105
  class ::SManufacturer < Sequel::Model(SDB[:manufacturers]); end
84
106
  class ::NewlineTest < Sequel::Model; end
107
+ class ::QualifiedTableNameTest < Sequel::Model(Sequel.qualify(:public, :categories)); end
85
108
 
86
109
  # Abstract Base Class
87
110
  ABC = Class.new(Sequel::Model)
@@ -97,6 +120,9 @@ describe Sequel::Annotate do
97
120
  if DB.server_version >= 100002 && (Sequel::MAJOR > 5 || (Sequel::MAJOR == 5 && Sequel::MINOR >= 7))
98
121
  comment = comment.sub(/DEFAULT nextval\('[a-z]+_id_seq'::regclass\)/, 'GENERATED BY DEFAULT AS IDENTITY')
99
122
  end
123
+ if DB.server_version >= 120000
124
+ comment = comment.gsub(/FOR EACH ROW EXECUTE PROCEDURE/, 'FOR EACH ROW EXECUTE FUNCTION')
125
+ end
100
126
  comment
101
127
  end
102
128
 
@@ -241,6 +267,36 @@ OUTPUT
241
267
  # Columns:
242
268
  # name | varchar(255) |
243
269
  # location | varchar(255) |
270
+ OUTPUT
271
+
272
+ Sequel::Annotate.new(QualifiedTableNameTest).schema_comment.must_equal(fix_pg_comment((<<OUTPUT).chomp))
273
+ # Table: public.categories
274
+ # Columns:
275
+ # id | integer | PRIMARY KEY DEFAULT nextval('categories_id_seq'::regclass)
276
+ # name | text | NOT NULL
277
+ # Indexes:
278
+ # categories_pkey | PRIMARY KEY btree (id)
279
+ # categories_name_key | UNIQUE btree (name)
280
+ # Referenced By:
281
+ # items | items_category_id_fkey | (category_id) REFERENCES categories(id)
282
+ OUTPUT
283
+
284
+ Sequel::Annotate.new(DomainTest).schema_comment.must_equal(fix_pg_comment((<<OUTPUT).chomp))
285
+ # Table: domain_tests
286
+ # Columns:
287
+ # id | integer | PRIMARY KEY DEFAULT nextval('categories_id_seq'::regclass)
288
+ # test_column | test_domain |
289
+ # Indexes:
290
+ # domain_tests_pkey | PRIMARY KEY btree (id)
291
+ OUTPUT
292
+
293
+ Sequel::Annotate.new(CommentTest).schema_comment.must_equal(fix_pg_comment((<<OUTPUT).chomp))
294
+ # Table: comment_tests
295
+ # Columns:
296
+ # id | integer | PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY |
297
+ # name | text | | name column comment
298
+ # Indexes:
299
+ # comment_tests_pkey | PRIMARY KEY btree (id)
244
300
  OUTPUT
245
301
  end
246
302
 
@@ -248,7 +304,7 @@ OUTPUT
248
304
  it "#annotate #{desc} should annotate the file comment" do
249
305
  FileUtils.cp(Dir['spec/unannotated/*.rb'], 'spec/tmp')
250
306
 
251
- [Item, Category, Manufacturer, SItem, SCategory, SManufacturer].each do |model|
307
+ [Item, Category, Manufacturer, SItem, SCategory, SManufacturer, SItemWithFrozenLiteral, SItemWithCoding, SItemWithEncoding, SItemWithWarnIndent, SItemWithWarnPastScope].each do |model|
252
308
  filename = model.name.downcase
253
309
  2.times do
254
310
  Sequel::Annotate.new(model).annotate("spec/tmp/#{filename}.rb", *args)
@@ -264,7 +320,7 @@ OUTPUT
264
320
 
265
321
  2.times do
266
322
  Sequel::Annotate.annotate(Dir["spec/tmp/*.rb"], *args)
267
- [Item, Category, Manufacturer, SItem, SCategory, SManufacturer].each do |model|
323
+ [Item, Category, Manufacturer, SItem, SCategory, SManufacturer, SItemWithFrozenLiteral, SItemWithCoding, SItemWithEncoding, SItemWithWarnIndent, SItemWithWarnPastScope].each do |model|
268
324
  filename = model.name.downcase
269
325
  expected = File.read("spec/annotated_#{pos}/#{filename}.rb")
270
326
  expected = fix_pg_comment(expected) if model.db == DB
@@ -0,0 +1,4 @@
1
+ # coding: xyz
2
+
3
+ class SItemWithCoding < Sequel::Model(SDB[:items])
4
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ class SItemWithEncoding < Sequel::Model(SDB[:items])
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SItemWithFrozenLiteral < Sequel::Model(SDB[:items])
4
+ end
@@ -0,0 +1,4 @@
1
+ # warn_indent: true
2
+
3
+ class SItemWithWarnIndent < Sequel::Model(SDB[:items])
4
+ end
@@ -0,0 +1,5 @@
1
+ # warn_past_scope: true
2
+ # warn_indent: false
3
+ # Additional comment that should stay
4
+ class SItemWithWarnPastScope < Sequel::Model(SDB[:items])
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-annotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-15 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest-global_expectations
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: pg
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,7 +86,7 @@ description: |
72
86
  constraints for the current table.
73
87
 
74
88
  On PostgreSQL, this includes more advanced information, including
75
- check constraints, triggers, and foreign keys constraints for other
89
+ check constraints, triggers, comments, and foreign keys constraints for other
76
90
  tables that reference the current table.
77
91
  email: code@jeremyevans.net
78
92
  executables: []
@@ -92,12 +106,22 @@ files:
92
106
  - spec/annotated_after/manufacturer.rb
93
107
  - spec/annotated_after/scategory.rb
94
108
  - spec/annotated_after/sitem.rb
109
+ - spec/annotated_after/sitemwithcoding.rb
110
+ - spec/annotated_after/sitemwithencoding.rb
111
+ - spec/annotated_after/sitemwithfrozenliteral.rb
112
+ - spec/annotated_after/sitemwithwarnindent.rb
113
+ - spec/annotated_after/sitemwithwarnpastscope.rb
95
114
  - spec/annotated_after/smanufacturer.rb
96
115
  - spec/annotated_before/category.rb
97
116
  - spec/annotated_before/item.rb
98
117
  - spec/annotated_before/manufacturer.rb
99
118
  - spec/annotated_before/scategory.rb
100
119
  - spec/annotated_before/sitem.rb
120
+ - spec/annotated_before/sitemwithcoding.rb
121
+ - spec/annotated_before/sitemwithencoding.rb
122
+ - spec/annotated_before/sitemwithfrozenliteral.rb
123
+ - spec/annotated_before/sitemwithwarnindent.rb
124
+ - spec/annotated_before/sitemwithwarnpastscope.rb
101
125
  - spec/annotated_before/smanufacturer.rb
102
126
  - spec/namespaced/itm_annotated.rb
103
127
  - spec/namespaced/itm_unannotated.rb
@@ -107,11 +131,19 @@ files:
107
131
  - spec/unannotated/manufacturer.rb
108
132
  - spec/unannotated/scategory.rb
109
133
  - spec/unannotated/sitem.rb
134
+ - spec/unannotated/sitemwithcoding.rb
135
+ - spec/unannotated/sitemwithencoding.rb
136
+ - spec/unannotated/sitemwithfrozenliteral.rb
137
+ - spec/unannotated/sitemwithwarnindent.rb
138
+ - spec/unannotated/sitemwithwarnpastscope.rb
110
139
  - spec/unannotated/smanufacturer.rb
111
140
  homepage: http://github.com/jeremyevans/sequel-annotate
112
141
  licenses:
113
142
  - MIT
114
- metadata: {}
143
+ metadata:
144
+ bug_tracker_uri: https://github.com/jeremyevans/sequel-annotate/issues
145
+ changelog_uri: https://github.com/jeremyevans/sequel-annotate/blob/master/CHANGELOG
146
+ source_code_uri: https://github.com/jeremyevans/sequel-annotate
115
147
  post_install_message:
116
148
  rdoc_options:
117
149
  - "--quiet"
@@ -134,8 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
166
  - !ruby/object:Gem::Version
135
167
  version: '0'
136
168
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.7.6
169
+ rubygems_version: 3.1.2
139
170
  signing_key:
140
171
  specification_version: 4
141
172
  summary: Annotate Sequel models with schema information