optify-config 1.2.2-arm64-darwin → 1.3.1-arm64-darwin
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.bundle +0 -0
 - data/lib/optify_ruby/3.4/optify_ruby.bundle +0 -0
 - data/lib/optify_ruby/base_config.rb +36 -20
 - 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: 047de527f317e146c8c1a1e0a55fb064fdfbb1deba7244ff1918f7711bc37f58
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e311875d61d5f4eba2b6e94aff241dae276846d981974d872da9d3b60bf4f1fa
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2c02a632370d7412f22b2167d9ed854abd39cfee9ece700fa40e425b14869dcd5abcf4e23bfc5e623d3e1586bc56c0387ad452d23c8f12b2b7bbf02957188788
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6c94214d6397e1003f4ebb800a72ceecae16c9e3da5d0422413d734c08853fe23102bb6c55be889a783eafb969c19ad56bd58f789703cde394df921f5956450f
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         @@ -23,19 +23,26 @@ 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 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  return value.to_sym if type.is_a?(T::Types::Simple) && type.raw_type == Symbol
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       39 
46 
     | 
    
         
             
                  case value
         
     | 
| 
       40 
47 
     | 
    
         
             
                  when Array
         
     | 
| 
       41 
48 
     | 
    
         
             
                    # Handle `T.nilable(T::Array[...])`
         
     | 
| 
         @@ -43,39 +50,48 @@ module Optify 
     | 
|
| 
       43 
50 
     | 
    
         
             
                    inner_type = type.type
         
     | 
| 
       44 
51 
     | 
    
         
             
                    return value.map { |v| _convert_value(v, inner_type) }.freeze
         
     | 
| 
       45 
52 
     | 
    
         
             
                  when Hash
         
     | 
| 
       46 
     | 
    
         
            -
                    # Handle `T.nilable(T::Hash[...])`
         
     | 
| 
       47 
     | 
    
         
            -
                    type = type.unwrap_nilable if type.respond_to?(:unwrap_nilable)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    # Handle `T.nilable(T::Hash[...])` and `T.any(...)`.
         
     | 
| 
      
 54 
     | 
    
         
            +
                    # 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(...)`
         
     | 
| 
      
 55 
     | 
    
         
            +
                    # because using `.types` works for both cases.
         
     | 
| 
      
 56 
     | 
    
         
            +
                    if type.respond_to?(:types)
         
     | 
| 
      
 57 
     | 
    
         
            +
                      # Find a type that works for the hash.
         
     | 
| 
      
 58 
     | 
    
         
            +
                      type.types.each do |t|
         
     | 
| 
      
 59 
     | 
    
         
            +
                        return _convert_hash(value, t).freeze
         
     | 
| 
      
 60 
     | 
    
         
            +
                      rescue StandardError
         
     | 
| 
      
 61 
     | 
    
         
            +
                        # Ignore and try the next type.
         
     | 
| 
      
 62 
     | 
    
         
            +
                      end
         
     | 
| 
      
 63 
     | 
    
         
            +
                      raise TypeError, "Could not convert hash: #{value} to #{type}."
         
     | 
| 
      
 64 
     | 
    
         
            +
                    end
         
     | 
| 
       48 
65 
     | 
    
         
             
                    return _convert_hash(value, type).freeze
         
     | 
| 
       49 
66 
     | 
    
         
             
                  end
         
     | 
| 
       50 
67 
     | 
    
         | 
| 
      
 68 
     | 
    
         
            +
                  # It would be nice to validate that the value is of the correct type here.
         
     | 
| 
      
 69 
     | 
    
         
            +
                  # For example that a string is a string and an Integer is an Integer.
         
     | 
| 
       51 
70 
     | 
    
         
             
                  value
         
     | 
| 
       52 
71 
     | 
    
         
             
                end
         
     | 
| 
       53 
72 
     | 
    
         | 
| 
       54 
73 
     | 
    
         
             
                #: (Hash[untyped, untyped] hash, untyped type) -> untyped
         
     | 
| 
       55 
     | 
    
         
            -
                def self._convert_hash(hash, type) 
     | 
| 
      
 74 
     | 
    
         
            +
                def self._convert_hash(hash, type)
         
     | 
| 
       56 
75 
     | 
    
         
             
                  if type.respond_to?(:raw_type)
         
     | 
| 
       57 
76 
     | 
    
         
             
                    # There is an object for the hash.
         
     | 
| 
      
 77 
     | 
    
         
            +
                    # It could be a custom class, a String, or maybe something else.
         
     | 
| 
       58 
78 
     | 
    
         
             
                    type_for_hash = type.raw_type
         
     | 
| 
       59 
79 
     | 
    
         
             
                    return type_for_hash.from_hash(hash) if type_for_hash.respond_to?(:from_hash)
         
     | 
| 
       60 
     | 
    
         
            -
                  elsif type. 
     | 
| 
      
 80 
     | 
    
         
            +
                  elsif type.is_a?(T::Types::TypedHash)
         
     | 
| 
       61 
81 
     | 
    
         
             
                    # The hash should be a hash, but the values might be objects to convert.
         
     | 
| 
       62 
     | 
    
         
            -
                     
     | 
| 
      
 82 
     | 
    
         
            +
                    type_for_keys = type.keys
         
     | 
| 
       63 
83 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
                    if  
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                      end
         
     | 
| 
       70 
     | 
    
         
            -
                    end
         
     | 
| 
      
 84 
     | 
    
         
            +
                    convert_key = if type_for_keys.is_a?(T::Types::Simple) && type_for_keys.raw_type == Symbol
         
     | 
| 
      
 85 
     | 
    
         
            +
                                    lambda(&:to_sym)
         
     | 
| 
      
 86 
     | 
    
         
            +
                                  else
         
     | 
| 
      
 87 
     | 
    
         
            +
                                    lambda(&:itself)
         
     | 
| 
      
 88 
     | 
    
         
            +
                                  end
         
     | 
| 
       71 
89 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                     
     | 
| 
       73 
     | 
    
         
            -
                    return hash. 
     | 
| 
      
 90 
     | 
    
         
            +
                    type_for_values = type.values
         
     | 
| 
      
 91 
     | 
    
         
            +
                    return hash.map { |k, v| [convert_key.call(k), _convert_value(v, type_for_values)] }.to_h
         
     | 
| 
       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.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: arm64-darwin
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Justin D. Harris
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2025-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-05-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: sorbet-runtime
         
     |