purple-client 0.1.9.2 → 0.1.9.3
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/purple/responses/body.rb +23 -19
- data/lib/purple/version.rb +1 -1
- 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: 381595d6be33f7e1f3c7a838182db63d5f157ba3978fa70f99b78c75391a9c06
|
4
|
+
data.tar.gz: 48aa5d67fd40fd4d8c8b1bf482e4e493d69f77dd8d9c8fe7011382a74437806f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '084bbb42e3790b1e291c5f95dc5928ec23acb1d6df597b8471e7f6effb279c08eff9f99281f046bc9e84658ec03cd39c943d8aa4a510fa79397afe0e4240550e'
|
7
|
+
data.tar.gz: cd0c4805e785f1cc92087b12a902fb23c78c90e15c540d52a4cedf78990a9c3cedd2ebfaf6d5583617e6a7c71b40db0fdfc208e8147e1b1eb0f0aad4a1b47ddc
|
@@ -82,9 +82,11 @@ class Purple::Responses::Body
|
|
82
82
|
next if value[:optional]
|
83
83
|
next if value[:allow_blank] && object[key].blank?
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
85
|
+
if object[key].is_a?(Array)
|
86
|
+
check_array!(object, key, value[:type].first, substructure[key][:type].first)
|
87
|
+
else
|
88
|
+
check_type!(object, key, value[:type])
|
89
|
+
end
|
88
90
|
else
|
89
91
|
next if object[key].nil?
|
90
92
|
|
@@ -96,22 +98,7 @@ class Purple::Responses::Body
|
|
96
98
|
"Expected a non-nil array for '#{key}' in response body.\n\nExpected response structure: #{substructure}.\n\nUse '#{key}: { type: #{value}, allow_blank: true }' if this field can be nil, blank or empty."
|
97
99
|
end
|
98
100
|
|
99
|
-
|
100
|
-
|
101
|
-
if type.is_a?(Symbol)
|
102
|
-
raise "Body structure definition error in key '#{key}' of structure #{substructure}."
|
103
|
-
end
|
104
|
-
|
105
|
-
object[key].each_with_index do |item, index|
|
106
|
-
if type.is_a?(Class)
|
107
|
-
unless item.is_a?(type)
|
108
|
-
raise BodyStructureMismatchError.new(key, type, item, object),
|
109
|
-
"Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
|
110
|
-
end
|
111
|
-
else
|
112
|
-
check_structure!(item, type)
|
113
|
-
end
|
114
|
-
end
|
101
|
+
check_array!(object, key, value.first, substructure)
|
115
102
|
else
|
116
103
|
if object.nil?
|
117
104
|
raise BodyStructureMismatchError.new(key, value, nil, object),
|
@@ -123,6 +110,23 @@ class Purple::Responses::Body
|
|
123
110
|
end
|
124
111
|
end
|
125
112
|
|
113
|
+
def check_array!(object, key, type, substructure)
|
114
|
+
if type.is_a?(Symbol)
|
115
|
+
raise "Body structure definition error in key '#{key}' of structure #{substructure}."
|
116
|
+
end
|
117
|
+
|
118
|
+
object[key].each_with_index do |item, index|
|
119
|
+
if type.is_a?(Class)
|
120
|
+
unless item.is_a?(type)
|
121
|
+
raise BodyStructureMismatchError.new(key, type, item, object),
|
122
|
+
"Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
|
123
|
+
end
|
124
|
+
else
|
125
|
+
check_structure!(item, type)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
126
130
|
def check_type!(object, key, expected_type)
|
127
131
|
return if key.in?([:optional, :allow_blank])
|
128
132
|
|
data/lib/purple/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purple-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.9.
|
4
|
+
version: 0.1.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-initializer
|