annotaterb 4.12.0 → 4.14.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: acf04a7f1c6244fa950273cc78bb159e3f25e1e1f8f154ebb5a668152672f28d
4
- data.tar.gz: 67466b09b7efa8ad90d2b674228c60b368c475b8809a5af7f0c9c48f1bfa3938
3
+ metadata.gz: 915a9aee6e9396080e4b115bc34466f422cc866aa31f64e8563a409f4ed53753
4
+ data.tar.gz: 30e4511ae77313d4d1f7348599286815a85e56f2c100f31ca73cc7a1feaa59d4
5
5
  SHA512:
6
- metadata.gz: 76fcd6ffe70e014b15a4aab9b8e5f838432281cf7836eb83532a17f3f13c0e70381ea20bcec185efd91816df6eed64ae25d9541403c1aa0e3bb94b7970846f5b
7
- data.tar.gz: 311ccf2c9013fe16ee0b70a693f9c1c478b4ab1543b6f8fdc3baf3fb0b4c9f8840e45d98236d2b634b80e3cadc1b33bb77f92a77f118828e92319292a85d8845
6
+ metadata.gz: 8e1c00298956404ba517a54b803f0cae4235da530a1f2dfe6db35e58c3747ba4bc7304759375ecf51237870f2e4701b965192b235e1c430b08bd4d0340bf6dc1
7
+ data.tar.gz: 63f51a4bbc1ebf2455aeeb8b3a7459a87787b309f5deae0a0e91df971bc28a36f77fa71f7b80a4fbe8f32d3660936fa41576f56569e72526fc2505a77c8fc6df
data/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.13.0](https://github.com/drwl/annotaterb/tree/v4.13.0) (2024-10-21)
4
+
5
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.12.0...v4.13.0)
6
+
7
+ **Closed issues:**
8
+
9
+ - Bug: Bigint are reported as integer [\#157](https://github.com/drwl/annotaterb/issues/157)
10
+ - Bug \(apparently\): :ignore\_columns does not work \(with any syntax I've tried\) [\#154](https://github.com/drwl/annotaterb/issues/154)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Bump version to v4.13.0 [\#159](https://github.com/drwl/annotaterb/pull/159) ([drwl](https://github.com/drwl))
15
+ - Support parsing of dynamic fixture erb yml files [\#158](https://github.com/drwl/annotaterb/pull/158) ([drwl](https://github.com/drwl))
16
+ - Fix updating of indexes containing escaped characters [\#156](https://github.com/drwl/annotaterb/pull/156) ([antonivanopoulos](https://github.com/antonivanopoulos))
17
+ - Add model with association and foreign key to dummyapp [\#153](https://github.com/drwl/annotaterb/pull/153) ([drwl](https://github.com/drwl))
18
+ - Generate changelog for v4.12.0 [\#152](https://github.com/drwl/annotaterb/pull/152) ([drwl](https://github.com/drwl))
19
+
20
+ ## [v4.12.0](https://github.com/drwl/annotaterb/tree/v4.12.0) (2024-09-15)
21
+
22
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.11.0...v4.12.0)
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Bump version to v4.12.0 [\#151](https://github.com/drwl/annotaterb/pull/151) ([drwl](https://github.com/drwl))
27
+ - Support postgres NULLS NOT DISTINCT clause in unique index [\#148](https://github.com/drwl/annotaterb/pull/148) ([ENewmeration](https://github.com/ENewmeration))
28
+ - Generate changelog for v4.11.0 [\#147](https://github.com/drwl/annotaterb/pull/147) ([drwl](https://github.com/drwl))
29
+
3
30
  ## [v4.11.0](https://github.com/drwl/annotaterb/tree/v4.11.0) (2024-08-16)
4
31
 
5
32
  [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.10.2...v4.11.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.12.0
1
+ 4.14.0
@@ -20,7 +20,7 @@ module AnnotateRb
20
20
 
21
21
  new_annotation = wrapped_content(@new_annotations)
22
22
 
23
- _content = @file_content.sub(@parsed_file.annotations, new_annotation)
23
+ _content = @file_content.sub(@parsed_file.annotations) { new_annotation }
24
24
  end
25
25
 
26
26
  private
@@ -5,7 +5,13 @@ module AnnotateRb
5
5
  # Compares the current file content and new annotation block and generates the column annotation differences
6
6
  class AnnotationDiffGenerator
7
7
  HEADER_PATTERN = /(^# Table name:.*?\n(#.*\r?\n)*\r?)/
8
- COLUMN_PATTERN = /^#[\t ]+[\w*.`\[\]():]+[\t ]+.+$/
8
+ # Example matches:
9
+ # - "# id :uuid not null, primary key"
10
+ # - "# title(length 255) :string not null"
11
+ # - "# status(a/b/c) :string not null"
12
+ # - "# created_at :datetime not null"
13
+ # - "# updated_at :datetime not null"
14
+ COLUMN_PATTERN = /^#[\t ]+[\w*.`\[\]():]+(?:\(.*?\))?[\t ]+.+$/
9
15
 
10
16
  class << self
11
17
  def call(file_content, annotation_block)
@@ -78,6 +78,12 @@ module AnnotateRb
78
78
  end
79
79
  end
80
80
 
81
+ # Check if the column is a virtual column and print the function
82
+ if @options[:show_virtual_columns] && @column.virtual?
83
+ # Any whitespace in the function gets reduced to a single space
84
+ attrs << @column.default_function.gsub(/\s+/, " ").strip
85
+ end
86
+
81
87
  attrs
82
88
  end
83
89
 
@@ -85,6 +85,14 @@ module AnnotateRb
85
85
  @column.name
86
86
  end
87
87
 
88
+ def virtual?
89
+ @column.respond_to?(:virtual?) && @column.virtual?
90
+ end
91
+
92
+ def default_function
93
+ @column.default_function
94
+ end
95
+
88
96
  private
89
97
 
90
98
  # Simple quoting for the default column value
@@ -25,6 +25,8 @@ module AnnotateRb
25
25
 
26
26
  if is_decimal_type
27
27
  formatted_column_type = "decimal(#{@column.precision}, #{@column.scale})"
28
+ elsif @options[:show_virtual_columns] && @column.virtual?
29
+ formatted_column_type = "virtual(#{column_type})"
28
30
  elsif is_special_type
29
31
  # Do nothing. Kept as a code fragment in case we need to do something here.
30
32
  elsif @column.limit && !@options[:format_yard]
@@ -40,7 +40,14 @@ module AnnotateRb
40
40
  def parse_yml
41
41
  # https://docs.ruby-lang.org/en/master/Psych.html#module-Psych-label-Reading+to+Psych-3A-3ANodes-3A-3AStream+structure
42
42
  parser = Psych.parser
43
- parser.parse(@input)
43
+ begin
44
+ parser.parse(@input)
45
+ rescue Psych::SyntaxError => _e
46
+ # "Dynamic fixtures with ERB" exist in Rails, and will cause Psych.parser to error
47
+ # This is a hacky solution to get around this and still have it parse
48
+ erb_yml = ERB.new(@input).result
49
+ parser.parse(erb_yml)
50
+ end
44
51
 
45
52
  stream = parser.handler.root
46
53
 
@@ -162,21 +162,12 @@ module AnnotateRb
162
162
  # These are the columns that the globalize gem needs to work but
163
163
  # are not necessary for the models to be displayed as annotations.
164
164
  def ignored_translation_table_columns
165
- # Construct the foreign column name in the translations table
166
- # eg. Model: Car, foreign column name: car_id
167
- foreign_column_name = [
168
- @klass.translation_class.to_s
169
- .gsub("::Translation", "").gsub("::", "_")
170
- .downcase,
171
- "_id"
172
- ].join.to_sym
173
-
174
165
  [
175
166
  :id,
176
167
  :created_at,
177
168
  :updated_at,
178
169
  :locale,
179
- foreign_column_name
170
+ @klass.name.foreign_key.to_sym
180
171
  ]
181
172
  end
182
173
  end
@@ -48,6 +48,7 @@ module AnnotateRb
48
48
  show_check_constraints: false, # ModelAnnotator
49
49
  show_foreign_keys: true, # ModelAnnotator
50
50
  show_indexes: true, # ModelAnnotator
51
+ show_virtual_columns: false, # ModelAnnotator
51
52
  simple_indexes: false, # ModelAnnotator
52
53
  sort: false, # ModelAnnotator
53
54
  timestamp: false, # RouteAnnotator
@@ -78,11 +78,12 @@ module AnnotateRb
78
78
  version: Commands::PrintVersion.new
79
79
  }
80
80
 
81
+ if @commands.size > 1
82
+ warn "Only one command can be run at a time"
83
+ end
84
+
81
85
  @options[:command] = if @commands.any?
82
86
  map[@commands.first]
83
- elsif @commands.size > 1
84
- # TODO: Should raise or alert user that multiple commands were selected but only 1 command will be ran
85
- map[@commands.first]
86
87
  else # None
87
88
  map[:help]
88
89
  end
data/lib/annotaterb.rb ADDED
@@ -0,0 +1,4 @@
1
+ # Gem names that follow naming convention work seamlessly. However, this gem is "annotaterb" where in code it is
2
+ # AnnotateRb. Because of this, we need this file so that the rest of the library automatically gets required.
3
+
4
+ require "annotate_rb"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.0
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew W. Lee
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-15 00:00:00.000000000 Z
11
+ date: 2025-02-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Annotates Rails/ActiveRecord Models, routes, fixtures, and others based
14
14
  on the database schema.
@@ -104,6 +104,7 @@ files:
104
104
  - lib/annotate_rb/route_annotator/removal_processor.rb
105
105
  - lib/annotate_rb/runner.rb
106
106
  - lib/annotate_rb/tasks/annotate_models_migrate.rake
107
+ - lib/annotaterb.rb
107
108
  - lib/generators/annotate_rb/config/USAGE
108
109
  - lib/generators/annotate_rb/config/config_generator.rb
109
110
  - lib/generators/annotate_rb/hook/USAGE
@@ -121,6 +122,7 @@ metadata:
121
122
  source_code_uri: https://github.com/drwl/annotaterb
122
123
  changelog_uri: https://github.com/drwl/annotaterb/blob/master/CHANGELOG.md
123
124
  bug_tracker_uri: https://github.com/drwl/annotaterb/issues
125
+ rubygems_mfa_required: 'true'
124
126
  post_install_message:
125
127
  rdoc_options: []
126
128
  require_paths:
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
138
  - !ruby/object:Gem::Version
137
139
  version: '0'
138
140
  requirements: []
139
- rubygems_version: 3.5.11
141
+ rubygems_version: 3.5.22
140
142
  signing_key:
141
143
  specification_version: 4
142
144
  summary: A gem for generating annotations for Rails projects.