optify-config 1.2.1-aarch64-linux → 1.3.0-aarch64-linux
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 +4 -4
- data/lib/optify_ruby/3.2/optify_ruby.so +0 -0
- data/lib/optify_ruby/3.4/optify_ruby.so +0 -0
- data/lib/optify_ruby/base_config.rb +28 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 034ea3406d9abddf721a9bf996e316c237bffb8d1a3a4c60dd6cfcf11d810256
|
4
|
+
data.tar.gz: 8d295a6002b969dac15b2621c3ee5b092450067fd3710c80e910b09b143991f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ec9a5b790be0fb4153bfc49d7d9afb17182bf240eac27e8378e88f8b16e10c05f1f87b311460e2464a7cc72ee53f7f84a93063a1b85c6f0c204880938d316f5
|
7
|
+
data.tar.gz: 175d1586630d1766ed03b3399447734a0778c77da584ac9e19488b6e64e38f7662f50ceef319a9d44594b060d8a41ddf129110e9924b356088e57e5efb1a192f
|
Binary file
|
Binary file
|
@@ -23,19 +23,24 @@ module Optify
|
|
23
23
|
# @return The new instance.
|
24
24
|
#: (Hash[untyped, untyped] hash) -> instance
|
25
25
|
def self.from_hash(hash)
|
26
|
-
|
26
|
+
instance = new
|
27
27
|
|
28
28
|
hash.each do |key, value|
|
29
29
|
sig_return_type = T::Utils.signature_for_method(instance_method(key)).return_type
|
30
30
|
value = _convert_value(value, sig_return_type)
|
31
|
-
|
31
|
+
instance.instance_variable_set("@#{key}", value)
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
instance.freeze
|
35
35
|
end
|
36
36
|
|
37
37
|
#: (untyped value, untyped type) -> untyped
|
38
38
|
def self._convert_value(value, type)
|
39
|
+
if type.is_a?(T::Types::Untyped)
|
40
|
+
# No preferred type is given, so return the value as is.
|
41
|
+
return value
|
42
|
+
end
|
43
|
+
|
39
44
|
case value
|
40
45
|
when Array
|
41
46
|
# Handle `T.nilable(T::Array[...])`
|
@@ -43,39 +48,50 @@ module Optify
|
|
43
48
|
inner_type = type.type
|
44
49
|
return value.map { |v| _convert_value(v, inner_type) }.freeze
|
45
50
|
when Hash
|
46
|
-
# Handle `T.nilable(T::Hash[...])`
|
47
|
-
type = type.unwrap_nilable if type.respond_to?(:unwrap_nilable)
|
51
|
+
# Handle `T.nilable(T::Hash[...])` and `T.any(...)`.
|
52
|
+
# We used to use `type = type.unwrap_nilable if type.respond_to?(:unwrap_nilable)`, but it's not needed now that we handle `T.any(...)`
|
53
|
+
# because using `.types` works for both cases.
|
54
|
+
if type.respond_to?(:types)
|
55
|
+
# Find a type that works for the hash.
|
56
|
+
type.types.each do |t|
|
57
|
+
return _convert_hash(value, t).freeze
|
58
|
+
rescue StandardError
|
59
|
+
# Ignore and try the next type.
|
60
|
+
end
|
61
|
+
raise TypeError, "Could not convert hash: #{value} to #{type}."
|
62
|
+
end
|
48
63
|
return _convert_hash(value, type).freeze
|
49
64
|
end
|
50
65
|
|
66
|
+
# It would be nice to validate that the value is of the correct type here.
|
67
|
+
# For example that a string is a string and an Integer is an Integer.
|
51
68
|
value
|
52
69
|
end
|
53
70
|
|
54
71
|
#: (Hash[untyped, untyped] hash, untyped type) -> untyped
|
55
|
-
def self._convert_hash(hash, type)
|
72
|
+
def self._convert_hash(hash, type)
|
56
73
|
if type.respond_to?(:raw_type)
|
57
74
|
# There is an object for the hash.
|
75
|
+
# It could be a custom class, a String, or maybe something else.
|
58
76
|
type_for_hash = type.raw_type
|
59
77
|
return type_for_hash.from_hash(hash) if type_for_hash.respond_to?(:from_hash)
|
60
|
-
elsif type.
|
78
|
+
elsif type.is_a?(T::Types::TypedHash)
|
61
79
|
# The hash should be a hash, but the values might be objects to convert.
|
62
80
|
type_for_values = type.values
|
63
81
|
|
64
82
|
if type_for_values.respond_to?(:raw_type)
|
65
|
-
raw_type_for_values = type_for_values.raw_type
|
83
|
+
raw_type_for_values = T.unsafe(type_for_values).raw_type
|
66
84
|
if raw_type_for_values.respond_to?(:from_hash)
|
67
85
|
# Use proper types.
|
68
86
|
return hash.transform_values { |v| raw_type_for_values.from_hash(v) }
|
69
87
|
end
|
70
88
|
end
|
71
89
|
|
72
|
-
# The values are not recognized objects.
|
90
|
+
# The values are not specific recognized objects.
|
73
91
|
return hash.transform_values { |v| _convert_value(v, type_for_values) }
|
74
92
|
end
|
75
93
|
|
76
|
-
#
|
77
|
-
# This can happen if there are is no type information for a key in the hash.
|
78
|
-
hash
|
94
|
+
raise TypeError, "Could not convert hash #{hash} to `#{type}`."
|
79
95
|
end
|
80
96
|
|
81
97
|
private_class_method :_convert_hash, :_convert_value
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optify-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: aarch64-linux
|
6
6
|
authors:
|
7
7
|
- Justin D. Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|