purple-client 0.1.9.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 449c3507b473362c91ae54c9ba05261ee47f8954ee6029bbadea455665bdfc6d
4
- data.tar.gz: 1f05c3273df179762325965927e7a4168d92178e71ab90d33a2ec322e43841ea
3
+ metadata.gz: 381595d6be33f7e1f3c7a838182db63d5f157ba3978fa70f99b78c75391a9c06
4
+ data.tar.gz: 48aa5d67fd40fd4d8c8b1bf482e4e493d69f77dd8d9c8fe7011382a74437806f
5
5
  SHA512:
6
- metadata.gz: 25448d731921229e6cc6843a16da6701ef28d6c2f5ae251a8ac78df5c363af6b6824b247b2b75f55d6fffe72cc87ac9fa3f3157bb2444ebbcda0a6d8d26d3bf3
7
- data.tar.gz: 64bcf742dc5d6d7694cb0eb58c65891943bbfe3a1d69d2070cbcfccaf52cb8dcb6d169df81ed618311e07b61c006d1430fcc5719876bef35d0700416186d5a85
6
+ metadata.gz: '084bbb42e3790b1e291c5f95dc5928ec23acb1d6df597b8471e7f6effb279c08eff9f99281f046bc9e84658ec03cd39c943d8aa4a510fa79397afe0e4240550e'
7
+ data.tar.gz: cd0c4805e785f1cc92087b12a902fb23c78c90e15c540d52a4cedf78990a9c3cedd2ebfaf6d5583617e6a7c71b40db0fdfc208e8147e1b1eb0f0aad4a1b47ddc
@@ -82,7 +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
- check_type!(object, key, value[:type])
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
86
90
  else
87
91
  next if object[key].nil?
88
92
 
@@ -94,22 +98,7 @@ class Purple::Responses::Body
94
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."
95
99
  end
96
100
 
97
- type = value.first
98
-
99
- if type.is_a?(Symbol)
100
- raise "Body structure definition error in key '#{key}' of structure #{substructure}."
101
- end
102
-
103
- object[key].each_with_index do |item, index|
104
- if type.is_a?(Class)
105
- unless item.is_a?(type)
106
- raise BodyStructureMismatchError.new(key, type, item, object),
107
- "Expected item at #{index} index of '#{key}' to be of type '#{value[index]}', but got '#{item.class}' with value '#{item}'."
108
- end
109
- else
110
- check_structure!(item, type)
111
- end
112
- end
101
+ check_array!(object, key, value.first, substructure)
113
102
  else
114
103
  if object.nil?
115
104
  raise BodyStructureMismatchError.new(key, value, nil, object),
@@ -121,6 +110,23 @@ class Purple::Responses::Body
121
110
  end
122
111
  end
123
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
+
124
130
  def check_type!(object, key, expected_type)
125
131
  return if key.in?([:optional, :allow_blank])
126
132
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Purple
4
- VERSION = "0.1.9.1"
4
+ VERSION = "0.1.9.3"
5
5
  end
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.1
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-16 00:00:00.000000000 Z
11
+ date: 2025-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer