annotaterb 4.21.0 → 4.22.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: d35263cf60a69ceabf708e6da1acb1aa7dbb9994028b36726d813a00ef0ec7f0
4
- data.tar.gz: f7286ebed8b6b2c2d2c5edb78dbeaa89dc6052619c8631a7d5b299e76c13bd0e
3
+ metadata.gz: 2be17a236402d5406e2f4d1f68a567bf51de51f924f66591adf9460bfacabe18
4
+ data.tar.gz: 48743c136f9a195bb1dbaa564bd8047c16411394a991b4c86b57a70844d0e121
5
5
  SHA512:
6
- metadata.gz: fcd554627a6f477ae5120a98afde43b89f08aa6411ea64e2feba73f752b34499172a8bee267b7cf68f1fcd729a921e90738a6047c7f939239063cc2b935f95f3
7
- data.tar.gz: 17ac0370bef28e3275368c7a0f93a74e0863042676656878ea94b69416d2a84ec39214f6368f70ff9c2ad2b45f1714488cb57235a8950fdfef3aa5c2ce9f315f
6
+ metadata.gz: a203a269dbcf4c42a082a2088c6c38d8c4b97c3bbf9ab760762e3149294fb38dc31799aea2f3ece425504782cd2027187bd161ccf4a9c006aaa7a9a791094311
7
+ data.tar.gz: 8cc55f09f193f5f428db97afc1270386a06eb8185773cfd339830e1ee8e49631a1f203cced676fdb2f4d7d5c0b690f5aadc9108f63d3de588c019d7585c0011b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.21.0](https://github.com/drwl/annotaterb/tree/v4.21.0) (2026-01-30)
4
+
5
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.20.0...v4.21.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Displaying database name for multi-database rails projects [\#254](https://github.com/drwl/annotaterb/issues/254)
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Yard format broken? [\#212](https://github.com/drwl/annotaterb/issues/212)
14
+
15
+ **Closed issues:**
16
+
17
+ - \[dotenv\] Loaded comment gets added to routes annotations [\#288](https://github.com/drwl/annotaterb/issues/288)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - Bump version to v4.21.0 [\#306](https://github.com/drwl/annotaterb/pull/306) ([drwl](https://github.com/drwl))
22
+ - Add integration test for ignore\_multi\_database\_name config option [\#305](https://github.com/drwl/annotaterb/pull/305) ([OdenTakashi](https://github.com/OdenTakashi))
23
+ - Include ignore\_multi\_database\_name in generated config [\#304](https://github.com/drwl/annotaterb/pull/304) ([OdenTakashi](https://github.com/OdenTakashi))
24
+ - Add to\_yard and to\_rdoc methods to Annotation classes [\#302](https://github.com/drwl/annotaterb/pull/302) ([k-duho](https://github.com/k-duho))
25
+ - Support customising config path [\#301](https://github.com/drwl/annotaterb/pull/301) ([rience](https://github.com/rience))
26
+ - Bump actions/checkout from 5 to 6 [\#299](https://github.com/drwl/annotaterb/pull/299) ([dependabot[bot]](https://github.com/apps/dependabot))
27
+ - Update Rails generator command in README [\#296](https://github.com/drwl/annotaterb/pull/296) ([EstebanDalelR](https://github.com/EstebanDalelR))
28
+ - chore: remove concurrent-ruby version lock from dummy app [\#284](https://github.com/drwl/annotaterb/pull/284) ([OdenTakashi](https://github.com/OdenTakashi))
29
+ - feat: Add "ignore\_multi\_database\_name" option [\#283](https://github.com/drwl/annotaterb/pull/283) ([t27duck](https://github.com/t27duck))
30
+ - refactor: use existing `database_name` method for cache key [\#282](https://github.com/drwl/annotaterb/pull/282) ([OdenTakashi](https://github.com/OdenTakashi))
31
+ - Support .config directory convention [\#281](https://github.com/drwl/annotaterb/pull/281) ([ngan](https://github.com/ngan))
32
+ - chore: add missing newlines [\#280](https://github.com/drwl/annotaterb/pull/280) ([OdenTakashi](https://github.com/OdenTakashi))
33
+ - Generate changelog for v4.20.0 [\#279](https://github.com/drwl/annotaterb/pull/279) ([drwl](https://github.com/drwl))
34
+
3
35
  ## [v4.20.0](https://github.com/drwl/annotaterb/tree/v4.20.0) (2025-10-20)
4
36
 
5
37
  [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.19.0...v4.20.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.21.0
1
+ 4.22.0
@@ -66,7 +66,7 @@ module AnnotateRb
66
66
  # Handle empty files where no classes/modules are found
67
67
  return [nil, 0] if parsed.starts.empty?
68
68
 
69
- return parsed.starts.first unless @options[:nested_position]
69
+ return parsed.starts.first unless @options[:nested_position] && parsed.respond_to?(:type_map)
70
70
 
71
71
  class_entries = parsed.starts.select { |name, _line| parsed.type_map[name] == :class }
72
72
  class_entries.last || parsed.starts.first
@@ -31,13 +31,13 @@ module AnnotateRb
31
31
  new_annotations = @annotation_block.match(HEADER_PATTERN).to_s
32
32
 
33
33
  current_annotation_columns = if current_annotations.present?
34
- current_annotations.scan(COLUMN_PATTERN).sort
34
+ current_annotations.scan(COLUMN_PATTERN)
35
35
  else
36
36
  []
37
37
  end
38
38
 
39
39
  new_annotation_columns = if new_annotations.present?
40
- new_annotations.scan(COLUMN_PATTERN).sort
40
+ new_annotations.scan(COLUMN_PATTERN)
41
41
  else
42
42
  []
43
43
  end
@@ -35,7 +35,11 @@ module AnnotateRb
35
35
  end
36
36
 
37
37
  def connection
38
- @klass.connection
38
+ if @klass.respond_to?(:lease_connection)
39
+ @klass.lease_connection
40
+ else
41
+ @klass.connection
42
+ end
39
43
  end
40
44
 
41
45
  def database_name
@@ -56,12 +60,12 @@ module AnnotateRb
56
60
  end
57
61
 
58
62
  def table_comments
59
- @klass.connection.table_comment(@klass.table_name)
63
+ connection.table_comment(@klass.table_name)
60
64
  end
61
65
 
62
66
  def has_table_comments?
63
- @klass.connection.respond_to?(:table_comment) &&
64
- @klass.connection.table_comment(@klass.table_name).present?
67
+ connection.respond_to?(:table_comment) &&
68
+ connection.table_comment(@klass.table_name).present?
65
69
  end
66
70
 
67
71
  def column_defaults
@@ -113,21 +117,10 @@ module AnnotateRb
113
117
  end
114
118
  end
115
119
 
116
- # TODO: Simplify this conditional
117
120
  def is_column_primary_key?(column_name)
118
- if primary_key
119
- if primary_key.is_a?(Array)
120
- # If the model has multiple primary keys, check if this column is one of them
121
- if primary_key.collect(&:to_sym).include?(column_name.to_sym)
122
- return true
123
- end
124
- elsif column_name.to_sym == primary_key.to_sym
125
- # If model has 1 primary key, check if this column is it
126
- return true
127
- end
128
- end
121
+ return false unless primary_key
129
122
 
130
- false
123
+ Array(primary_key).map(&:to_sym).include?(column_name.to_sym)
131
124
  end
132
125
 
133
126
  def built_attributes
@@ -150,13 +143,13 @@ module AnnotateRb
150
143
  table_name = @klass.table_name
151
144
  return [] unless table_name
152
145
 
153
- indexes = @klass.connection.indexes(table_name)
146
+ indexes = connection.indexes(table_name)
154
147
  return indexes if indexes.any? || !@klass.table_name_prefix
155
148
 
156
149
  # Try to search the table without prefix
157
150
  table_name_without_prefix = table_name.to_s.sub(@klass.table_name_prefix.to_s, "")
158
151
  begin
159
- @klass.connection.indexes(table_name_without_prefix)
152
+ connection.indexes(table_name_without_prefix)
160
153
  rescue ActiveRecord::StatementInvalid => _e
161
154
  # Mysql2 adapter behaves differently than Sqlite3 and Postgres adapter.
162
155
  # If `table_name_without_prefix` does not exist, Mysql2 will raise,
@@ -22,8 +22,11 @@ if defined?(Rails::Application) && Rails.version.split(".").first.to_i >= 6
22
22
  end
23
23
  end
24
24
 
25
+ config = ::AnnotateRb::ConfigLoader.load_config
26
+
25
27
  migration_tasks.each do |task|
26
28
  next unless Rake::Task.task_defined?(task)
29
+ next if config[:skip_on_db_migrate]
27
30
 
28
31
  Rake::Task[task].enhance do # This block is ran after `task` completes
29
32
  task_name = Rake.application.top_level_tasks.last # The name of the task that was run, e.g. "db:migrate"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotaterb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.21.0
4
+ version: 4.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew W. Lee
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-01-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -151,7 +150,6 @@ metadata:
151
150
  changelog_uri: https://github.com/drwl/annotaterb/blob/main/CHANGELOG.md
152
151
  bug_tracker_uri: https://github.com/drwl/annotaterb/issues
153
152
  rubygems_mfa_required: 'true'
154
- post_install_message:
155
153
  rdoc_options: []
156
154
  require_paths:
157
155
  - lib
@@ -166,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
164
  - !ruby/object:Gem::Version
167
165
  version: '0'
168
166
  requirements: []
169
- rubygems_version: 3.5.22
170
- signing_key:
167
+ rubygems_version: 4.0.4
171
168
  specification_version: 4
172
169
  summary: A gem for generating annotations for Rails projects.
173
170
  test_files: []