annotaterb 4.4.0 → 4.4.1

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: 349c4c734ded99ebac4d6ec075372fe814dff54e7edd7834a4b7c254aa046571
4
- data.tar.gz: 715b408a71123bc45986f4aca53c1c34b0debb92b01dc770085a7ba5aac6ae45
3
+ metadata.gz: a337f543f32142efaffbfd396196692d42a98438352b3bdd406c104c25a9958a
4
+ data.tar.gz: 27d091e7fed5953ccdd26c4b4874e45a0fcff541630595fa467e010629efb9ba
5
5
  SHA512:
6
- metadata.gz: d843a40644a70550177193b9f1e559c541852384bf4e26f489a45d6ad486d8ddf6157d94abc9c98072acfad802e3144db40fe9ba1e6a3b00018d7865c92dc78a
7
- data.tar.gz: e3706615de5bca13aa90353aec34bcc9a728400c139321d051edac045d4c2f24edc032129f666eb012da7b88587bd90bab979e40f77fb25c0568b39559a8302a
6
+ metadata.gz: 44125b3f65246ad1b5a0dd0d354487462ea6584c6147165650268244fd8d3c9826cf337873f24c31e008efa1c560b37bcb71e36af7fc05c9bc381d48e2b1e4b0
7
+ data.tar.gz: 7979e2309e3c09ee11fc090a424e7006a94634c7a970fe34b61028b3a90d495b684cc2a4a6fa78221b288dfe5e6682567835fb6839ada3903dfaa599a4f8cfdc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [v4.4.0](https://github.com/drwl/annotaterb/tree/v4.4.0) (2023-06-24)
4
+
5
+ [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.3.1...v4.4.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Bump version to v4.4.0 [\#52](https://github.com/drwl/annotaterb/pull/52) ([drwl](https://github.com/drwl))
10
+ - Flatten tests in `annotation_builder_spec.rb` [\#51](https://github.com/drwl/annotaterb/pull/51) ([drwl](https://github.com/drwl))
11
+ - Add support for table comments [\#50](https://github.com/drwl/annotaterb/pull/50) ([drwl](https://github.com/drwl))
12
+ - Improve some model annotator tests [\#49](https://github.com/drwl/annotaterb/pull/49) ([drwl](https://github.com/drwl))
13
+ - Make tests that use `mock_column` more accurate [\#48](https://github.com/drwl/annotaterb/pull/48) ([drwl](https://github.com/drwl))
14
+ - Generate changelog for v4.3.1 [\#47](https://github.com/drwl/annotaterb/pull/47) ([drwl](https://github.com/drwl))
15
+
3
16
  ## [v4.3.1](https://github.com/drwl/annotaterb/tree/v4.3.1) (2023-06-15)
4
17
 
5
18
  [Full Changelog](https://github.com/drwl/annotaterb/compare/v4.3.0...v4.3.1)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.4.0
1
+ 4.4.1
data/exe/annotaterb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- unless File.exist?("./Rakefile") || File.exist?("./Gemfile")
4
+ if !File.exist?("./Rakefile") && !File.exist?("./Gemfile")
5
5
  abort "Please run annotaterb from the root of the project."
6
6
  end
7
7
 
@@ -88,17 +88,7 @@ module AnnotateRb
88
88
 
89
89
  # Simple quoting for the default column value
90
90
  def quote(value)
91
- case value
92
- when NilClass then "NULL"
93
- when TrueClass then "TRUE"
94
- when FalseClass then "FALSE"
95
- when Float, Integer then value.to_s
96
- # BigDecimals need to be output in a non-normalized form and quoted.
97
- when BigDecimal then value.to_s("F")
98
- when Array then value.map { |v| quote(v) }
99
- else
100
- value.inspect
101
- end
91
+ DefaultValueBuilder.new(value).build
102
92
  end
103
93
  end
104
94
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AnnotateRb
4
+ module ModelAnnotator
5
+ module ColumnAnnotation
6
+ class DefaultValueBuilder
7
+ def initialize(value)
8
+ @value = value
9
+ end
10
+
11
+ # @return [String]
12
+ # Returns the value to get written to file by file.puts. Strings get written to file so escaped quoted strings
13
+ # get written as quoted. For example, if `value: "\"some_string\""` then "some_string" gets written.
14
+ # Same with arrays, if `value: "[\"a\", \"b\", \"c\"]"` then `["a", "b", "c"]` gets written.
15
+ #
16
+ # @example "\"some_string\""
17
+ # @example "NULL"
18
+ # @example "1.2"
19
+ def build
20
+ if @value.is_a?(Array)
21
+ quote_array(@value)
22
+ else
23
+ quote(@value)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def quote(value)
30
+ case value
31
+ when NilClass then "NULL"
32
+ when TrueClass then "TRUE"
33
+ when FalseClass then "FALSE"
34
+ when Float, Integer then value.to_s
35
+ # BigDecimals need to be output in a non-normalized form and quoted.
36
+ when BigDecimal then value.to_s("F")
37
+ when String then value.inspect
38
+ else
39
+ value.inspect
40
+ end
41
+ end
42
+
43
+ def quote_array(value)
44
+ content = value.map { |v| quote(v) }.join(", ")
45
+ "[" + content + "]"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -7,6 +7,7 @@ module AnnotateRb
7
7
  autoload :TypeBuilder, "annotate_rb/model_annotator/column_annotation/type_builder"
8
8
  autoload :ColumnWrapper, "annotate_rb/model_annotator/column_annotation/column_wrapper"
9
9
  autoload :AnnotationBuilder, "annotate_rb/model_annotator/column_annotation/annotation_builder"
10
+ autoload :DefaultValueBuilder, "annotate_rb/model_annotator/column_annotation/default_value_builder"
10
11
  end
11
12
  end
12
13
  end
data/lib/annotate_rb.rb CHANGED
@@ -10,8 +10,6 @@ require "active_support/core_ext/string/inflections"
10
10
 
11
11
  require "rake"
12
12
 
13
- require "annotate_rb/active_record_patch"
14
-
15
13
  require_relative "annotate_rb/helper"
16
14
  require_relative "annotate_rb/core"
17
15
  require_relative "annotate_rb/commands"
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.4.0
4
+ version: 4.4.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-24 00:00:00.000000000 Z
11
+ date: 2023-09-11 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.
@@ -25,7 +25,6 @@ files:
25
25
  - VERSION
26
26
  - exe/annotaterb
27
27
  - lib/annotate_rb.rb
28
- - lib/annotate_rb/active_record_patch.rb
29
28
  - lib/annotate_rb/commands.rb
30
29
  - lib/annotate_rb/commands/annotate_models.rb
31
30
  - lib/annotate_rb/commands/annotate_routes.rb
@@ -48,6 +47,7 @@ files:
48
47
  - lib/annotate_rb/model_annotator/column_annotation/annotation_builder.rb
49
48
  - lib/annotate_rb/model_annotator/column_annotation/attributes_builder.rb
50
49
  - lib/annotate_rb/model_annotator/column_annotation/column_wrapper.rb
50
+ - lib/annotate_rb/model_annotator/column_annotation/default_value_builder.rb
51
51
  - lib/annotate_rb/model_annotator/column_annotation/type_builder.rb
52
52
  - lib/annotate_rb/model_annotator/file_builder.rb
53
53
  - lib/annotate_rb/model_annotator/file_components.rb
@@ -1,11 +0,0 @@
1
- # monkey patches
2
-
3
- # standard:disable Style/MissingRespondToMissing
4
- module ::ActiveRecord
5
- class Base
6
- def self.method_missing(_name, *_args)
7
- # ignore this, so unknown/unloaded macros won't cause parsing to fail
8
- end
9
- end
10
- end
11
- # standard:enable Style/MissingRespondToMissing