support_table_data 1.6.0 → 1.6.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9977faeef0b935eb106be5e5cf9a6ba81a0ba1ab1f9e90fa6b694ce32fe3fd40
|
|
4
|
+
data.tar.gz: 31a8019bce856f7555f7a2fbb28a913fad287dbc4c554d36cb3983f2b564e3db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cc917037da50fd3f79ffe67db151bafb4c0042729946eb62974b46a3cf5332a8e3b6ab2ff4a31df20d6d2273f111ba7aaad14509a352b1fa986eb120e7b4b68
|
|
7
|
+
data.tar.gz: 50ab7d9230f0b7f104f542121e1cf3d1b7ffb4f6082fda2af68c9829e9b2b8eb3b2e04c126ef81f82395800ea8a0802229d8fdd313c21e77d8704b1597d87ca0
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## 1.6.1
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Fixed issue with YARD and RBS documentation tasks possibly raising an error if a named value method is deprecated and wrapped to return an error. Types are now inferred directly from the data rather than calling a method.
|
|
12
|
+
|
|
7
13
|
## 1.6.0
|
|
8
14
|
|
|
9
15
|
### Added
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.6.
|
|
1
|
+
1.6.1
|
|
@@ -42,7 +42,7 @@ module SupportTableData
|
|
|
42
42
|
lines << "def self.#{name}: () -> #{klass.name}"
|
|
43
43
|
lines << "def #{name}?: () -> bool"
|
|
44
44
|
klass.support_table_attribute_helpers.each do |attribute_name|
|
|
45
|
-
return_type = TypeInference.rbs_type(TypeInference.value_type(klass,
|
|
45
|
+
return_type = TypeInference.rbs_type(TypeInference.value_type(klass, name, attribute_name))
|
|
46
46
|
lines << "def self.#{name}_#{attribute_name}: () -> #{return_type}"
|
|
47
47
|
end
|
|
48
48
|
lines
|
|
@@ -3,26 +3,28 @@
|
|
|
3
3
|
module SupportTableData
|
|
4
4
|
module Documentation
|
|
5
5
|
# Infers documentation types for the dynamically-defined attribute helpers
|
|
6
|
-
# by
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
# This module must not be used on finder helpers (e.g. `Color.red`), which
|
|
11
|
-
# call `find_by!` and would hit the database.
|
|
6
|
+
# by reading the canonical value out of the parsed data file and
|
|
7
|
+
# inspecting its class. This avoids invoking the generated method, which
|
|
8
|
+
# may have been wrapped (e.g. deprecated) to raise.
|
|
12
9
|
module TypeInference
|
|
13
10
|
module_function
|
|
14
11
|
|
|
15
|
-
# Determine the documentation type for
|
|
16
|
-
#
|
|
17
|
-
#
|
|
12
|
+
# Determine the documentation type for a named-instance attribute
|
|
13
|
+
# helper by looking up the attribute value in the model's named
|
|
14
|
+
# instance data and returning its class. Returns nil when the
|
|
15
|
+
# attribute is not defined for the named instance.
|
|
18
16
|
#
|
|
19
17
|
# @param klass [Class] The model class
|
|
20
|
-
# @param
|
|
18
|
+
# @param name [String, Symbol] The named instance name
|
|
19
|
+
# @param attribute_name [String, Symbol] The attribute name
|
|
21
20
|
# @return [Class, nil]
|
|
22
|
-
def value_type(klass,
|
|
23
|
-
return nil unless klass.respond_to?(
|
|
21
|
+
def value_type(klass, name, attribute_name)
|
|
22
|
+
return nil unless klass.respond_to?(:named_instance_data)
|
|
24
23
|
|
|
25
|
-
klass.
|
|
24
|
+
data = klass.named_instance_data(name)
|
|
25
|
+
return nil unless data.is_a?(Hash) && data.key?(attribute_name.to_s)
|
|
26
|
+
|
|
27
|
+
data[attribute_name.to_s].class
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
# Map a Ruby value class to a YARD type string.
|
|
@@ -175,7 +175,7 @@ module SupportTableData
|
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
def attribute_yard_return_type(name, attribute_name)
|
|
178
|
-
TypeInference.yard_type(TypeInference.value_type(klass,
|
|
178
|
+
TypeInference.yard_type(TypeInference.value_type(klass, name, attribute_name))
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
end
|