volcano-sdk 0.32.3 → 0.32.4
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/volcano/storage_object_response.rb +26 -4
- data/lib/volcano/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ef8f141d5ef4704ebc727b5836e416fb382af153ad9eb7748ef9d77181c947f
|
|
4
|
+
data.tar.gz: 271d7a8647274d6229de1f89fae7521486bc8617c9f4caa9b37d69b859fc9e7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51b1d9f99ed3b506ae5716c89c29e558d5a7b3cd8b1d324a00c7adc05dc9d4c23753797c0d1d317d0f059a91574e461af32c15b9a37eefe4f43d9820db594b21
|
|
7
|
+
data.tar.gz: 60a608b1b29a3599abdcbc815c37a6f49073921eabdec82926f7f6c51024a1b3ca2f803d72b7c4256722955d5db9e7cc2d3dcba22b6005581bc7581019f54201
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
3
5
|
module Volcano
|
|
4
6
|
# Validates object metadata and paginated storage responses.
|
|
5
7
|
module StorageObjectResponse
|
|
@@ -69,20 +71,40 @@ module Volcano
|
|
|
69
71
|
def storage_json_hash(value)
|
|
70
72
|
raise Error::TransportError, 'invalid storage JSON object' unless value.is_a?(Hash)
|
|
71
73
|
|
|
74
|
+
# @type var active: Hash[Integer, bool]
|
|
75
|
+
active = {}
|
|
76
|
+
copy = storage_json_container(value, active) { storage_json_entries(value, active) }
|
|
77
|
+
JSON.generate(copy)
|
|
78
|
+
copy
|
|
79
|
+
rescue JSON::GeneratorError
|
|
80
|
+
raise Error::TransportError, 'invalid storage JSON value', cause: nil
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def storage_json_entries(value, active)
|
|
72
84
|
value.to_h do |key, item|
|
|
73
85
|
raise Error::TransportError, 'invalid storage JSON key' unless key.is_a?(String)
|
|
74
86
|
|
|
75
|
-
[key, storage_json_value(item)]
|
|
87
|
+
[key, storage_json_value(item, active)]
|
|
76
88
|
end
|
|
77
89
|
end
|
|
78
90
|
|
|
79
|
-
def storage_json_value(value)
|
|
91
|
+
def storage_json_value(value, active)
|
|
80
92
|
case value
|
|
81
93
|
when NilClass, TrueClass, FalseClass, Integer, Float, String then value
|
|
82
|
-
when Array then value.map { |item| storage_json_value(item) }
|
|
83
|
-
when Hash then
|
|
94
|
+
when Array then storage_json_container(value, active) { value.map { |item| storage_json_value(item, active) } }
|
|
95
|
+
when Hash then storage_json_container(value, active) { storage_json_entries(value, active) }
|
|
84
96
|
else raise Error::TransportError, 'invalid storage JSON value'
|
|
85
97
|
end
|
|
86
98
|
end
|
|
99
|
+
|
|
100
|
+
def storage_json_container(value, active)
|
|
101
|
+
id = value.object_id
|
|
102
|
+
raise Error::TransportError, 'invalid storage JSON value' if active.key?(id) || active.size >= 100
|
|
103
|
+
|
|
104
|
+
active[id] = true
|
|
105
|
+
copy = yield
|
|
106
|
+
active.delete(id)
|
|
107
|
+
copy
|
|
108
|
+
end
|
|
87
109
|
end
|
|
88
110
|
end
|
data/lib/volcano/version.rb
CHANGED