annotaterb 4.13.0 → 4.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7adb0604dd67e60d6658add880eeee01a0367c86f9f0088f557fcb6ab42605c6
4
- data.tar.gz: faa6374c64ffb979d1690c896cc564c526a6641b2fd79adc8bc922fad2fb25c0
3
+ metadata.gz: 915a9aee6e9396080e4b115bc34466f422cc866aa31f64e8563a409f4ed53753
4
+ data.tar.gz: 30e4511ae77313d4d1f7348599286815a85e56f2c100f31ca73cc7a1feaa59d4
5
5
  SHA512:
6
- metadata.gz: 6250eab94f83dd0c3a40d670ad6a151532199d0183f6d13893775094e5581f6bf2513205b04f29034f0c35c8a1e0c34911a964efcb2c3104cfde0c2d6af0c1d0
7
- data.tar.gz: 39210bfcf75338adf0a0bc88b31720427ed28b2679abed39ee4aa7b2500b88a170665a330a4f709a6c08f1e9d8e628c553502a4143bf4ea5be5eb96e464ebb61
6
+ metadata.gz: 8e1c00298956404ba517a54b803f0cae4235da530a1f2dfe6db35e58c3747ba4bc7304759375ecf51237870f2e4701b965192b235e1c430b08bd4d0340bf6dc1
7
+ data.tar.gz: 63f51a4bbc1ebf2455aeeb8b3a7459a87787b309f5deae0a0e91df971bc28a36f77fa71f7b80a4fbe8f32d3660936fa41576f56569e72526fc2505a77c8fc6df
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
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
+
3
20
  ## [v4.12.0](https://github.com/drwl/annotaterb/tree/v4.12.0) (2024-09-15)
4
21
 
5
22
  [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.11.0...v4.12.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.13.0
1
+ 4.14.0
@@ -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]
@@ -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.13.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-10-21 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.