annotaterb 4.3.0 → 4.3.1

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: 6600bd03fb521f6d86e1f9dc7e86e2c2020b54cd666ccf21bb23dd7fcc18bdc5
4
- data.tar.gz: bf68866b5ed4cbc5c52464464cc239bb8d9f22f642492400aaf88ca3296aee29
3
+ metadata.gz: 638be873328bb99a7c5b8196ee15749e0c40e36fc3660204ceec28af42678f09
4
+ data.tar.gz: 0e88670fc1257d20e6282aaf4f510d8b2be29829983dce6c63bcfc4078deb996
5
5
  SHA512:
6
- metadata.gz: a1e0c299850467b29e7fb2a7fecb83464e4eb0a5d1325b688591d0ca03dc98ffcc691d4d1262861bc03aa2648249b54401020a6dbbf11600d7991b54d149be90
7
- data.tar.gz: a85ea32f4acb1cbd189d501c41d8fffa18ba8ce930e871fb804686803e94474273aa7617f33229ff397840f7055e0f06222b8e2095e1617e9b1e660a54865d4b
6
+ metadata.gz: 2142be1d47c96ac81a3ab97cfbb6d852ea952be8a179785b5cf48eadf9eec3e9ceff3588353a2d3efa6efeed071589664776948b96eda8e1df5cd4dd7335d0c6
7
+ data.tar.gz: e6cc12cc6d7110283ba23243cc27f355f594d71fc2f5ce5ee50f535f84bfb2e8e6a440546e86a4e2ffa1f300afd819321bb81968e7a235486605bd219c5284bb
data/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased](https://github.com/drwl/annotaterb/tree/HEAD)
3
+ ## [v4.3.0](https://github.com/drwl/annotaterb/tree/v4.3.0) (2023-06-10)
4
4
 
5
- [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.1.1...HEAD)
5
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.2.0...v4.3.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Bump version to v4.3.0 [\#41](https://github.com/drwl/annotaterb/pull/41) ([drwl](https://github.com/drwl))
10
+ - Add `ANNOTATERB_SKIP_ON_DB_TASKS` ENV var to skip auto annotations [\#40](https://github.com/drwl/annotaterb/pull/40) ([drwl](https://github.com/drwl))
11
+
12
+ ## [v4.2.0](https://github.com/drwl/annotaterb/tree/v4.2.0) (2023-06-02)
13
+
14
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.1.1...v4.2.0)
6
15
 
7
16
  **Merged pull requests:**
8
17
 
9
18
  - Specify `standard` gem version [\#39](https://github.com/drwl/annotaterb/pull/39) ([drwl](https://github.com/drwl))
19
+ - Generate changelog for 4.2 again [\#38](https://github.com/drwl/annotaterb/pull/38) ([drwl](https://github.com/drwl))
10
20
  - Bump version to v4.2.0 [\#37](https://github.com/drwl/annotaterb/pull/37) ([drwl](https://github.com/drwl))
11
21
  - Generate changelog for 4.2 [\#36](https://github.com/drwl/annotaterb/pull/36) ([drwl](https://github.com/drwl))
12
22
  - Improve tests for `ColumnAnnotation::*` [\#35](https://github.com/drwl/annotaterb/pull/35) ([drwl](https://github.com/drwl))
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.3.0
1
+ 4.3.1
@@ -21,9 +21,10 @@ module AnnotateRb
21
21
 
22
22
  table_indices = @model.retrieve_indexes_from_table
23
23
  column_indices = table_indices.select { |ind| ind.columns.include?(@column.name) }
24
+ column_defaults = @model.column_defaults
24
25
 
25
- column_attributes = AttributesBuilder.new(@column, @options, is_primary_key, column_indices).build
26
- formatted_column_type = TypeBuilder.new(@column, @options).build
26
+ column_attributes = AttributesBuilder.new(@column, @options, is_primary_key, column_indices, column_defaults).build
27
+ formatted_column_type = TypeBuilder.new(@column, @options, column_defaults).build
27
28
 
28
29
  col_name = if @model.with_comments? && @column.comment
29
30
  "#{@column.name}(#{@column.comment.gsub(/\n/, '\\n')})"
@@ -7,8 +7,8 @@ module AnnotateRb
7
7
  # Don't show default value for these column types
8
8
  NO_DEFAULT_COL_TYPES = %w[json jsonb hstore].freeze
9
9
 
10
- def initialize(column, options, is_primary_key, column_indices)
11
- @column = ColumnWrapper.new(column)
10
+ def initialize(column, options, is_primary_key, column_indices, column_defaults)
11
+ @column = ColumnWrapper.new(column, column_defaults)
12
12
  @options = options
13
13
  @is_primary_key = is_primary_key
14
14
  @column_indices = column_indices
@@ -20,7 +20,7 @@ module AnnotateRb
20
20
  column_type = @column.column_type_string
21
21
  attrs = []
22
22
 
23
- unless @column.default.nil? || hide_default?
23
+ if !@column.raw_default.nil? && !hide_default?
24
24
  schema_default = "default(#{@column.default_string})"
25
25
 
26
26
  attrs << schema_default
@@ -4,18 +4,21 @@ module AnnotateRb
4
4
  module ModelAnnotator
5
5
  module ColumnAnnotation
6
6
  class ColumnWrapper
7
- def initialize(column)
7
+ def initialize(column, column_defaults)
8
8
  @column = column
9
+ @column_defaults = column_defaults
9
10
  end
10
11
 
11
- def default
12
- # Note: Used to be klass.column_defaults[name], where name is the column name.
13
- # Looks to be identical, but keeping note here in case there are differences.
14
- _column_default = @column.default
12
+ def raw_default
13
+ @column.default
14
+ end
15
+
16
+ def default_value
17
+ @column_defaults[@column.name]
15
18
  end
16
19
 
17
20
  def default_string
18
- quote(@column.default)
21
+ quote(default_value)
19
22
  end
20
23
 
21
24
  def type
@@ -8,8 +8,9 @@ module AnnotateRb
8
8
  # Example: show "integer" instead of "integer(4)"
9
9
  NO_LIMIT_COL_TYPES = %w[integer bigint boolean].freeze
10
10
 
11
- def initialize(column, options)
12
- @column = ColumnWrapper.new(column)
11
+ def initialize(column, options, column_defaults)
12
+ # Passing `column_defaults` for posterity, don't actually need it here since it's not used
13
+ @column = ColumnWrapper.new(column, column_defaults)
13
14
  @options = options
14
15
  end
15
16
 
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.3.0
4
+ version: 4.3.1
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: 2023-06-10 00:00:00.000000000 Z
11
+ date: 2023-06-15 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.