purple-client 0.1.8 → 0.1.9.1

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: 904a3aae97dec86b01cba57ebe806b9745cbce75803e986e63ae953209642455
4
- data.tar.gz: 92397c8c6a2862fd4366d58dd67bc255933252d91becad2af58241ed1a0e3234
3
+ metadata.gz: 449c3507b473362c91ae54c9ba05261ee47f8954ee6029bbadea455665bdfc6d
4
+ data.tar.gz: 1f05c3273df179762325965927e7a4168d92178e71ab90d33a2ec322e43841ea
5
5
  SHA512:
6
- metadata.gz: 7072c78039ce88e59465cd91950eca347c11e876639490235f354ff5e8fad4cef31a84128c4b90ab28b6efd107bea3b91620f27f03c1ad19f06744803268510f
7
- data.tar.gz: 6fa661c3de144a83de31fc3cdcdbd199ea6fd3d38643d2b60bbb4e243893074adaa19b6bc5daf7118b1a5339bb754d9fc3d1c809e09af7006281cb465177b7ae
6
+ metadata.gz: 25448d731921229e6cc6843a16da6701ef28d6c2f5ae251a8ac78df5c363af6b6824b247b2b75f55d6fffe72cc87ac9fa3f3157bb2444ebbcda0a6d8d26d3bf3
7
+ data.tar.gz: 64bcf742dc5d6d7694cb0eb58c65891943bbfe3a1d69d2070cbcfccaf52cb8dcb6d169df81ed618311e07b61c006d1430fcc5719876bef35d0700416186d5a85
data/lib/purple/client.rb CHANGED
@@ -37,6 +37,14 @@ module Purple
37
37
  end
38
38
  end
39
39
 
40
+ def timeout(value = nil)
41
+ if value.nil?
42
+ @timeout
43
+ else
44
+ @timeout = value
45
+ end
46
+ end
47
+
40
48
  def callback(&block)
41
49
  if block_given?
42
50
  @callback = block
data/lib/purple/path.rb CHANGED
@@ -5,6 +5,7 @@ require 'faraday'
5
5
  require 'active_support/core_ext/hash/deep_merge'
6
6
  require 'active_support/core_ext/object/inclusion'
7
7
  require 'active_support/core_ext/object/blank'
8
+ require 'cgi'
8
9
 
9
10
  module Purple
10
11
  class Path
@@ -20,7 +21,12 @@ module Purple
20
21
  option :responses, optional: true, default: -> { [] }
21
22
 
22
23
  def full_path
23
- current_path = is_param ? @param_value : name
24
+ current_path = if is_param
25
+ CGI.escape(@param_value.to_s)
26
+ else
27
+ name
28
+ end
29
+
24
30
  parent.nil? ? current_path : "#{parent.full_path}/#{current_path}"
25
31
  end
26
32
 
@@ -64,6 +70,7 @@ module Purple
64
70
  end
65
71
 
66
72
  connection = Faraday.new(url: client.domain) do |conn|
73
+ conn.options.timeout = client.timeout if client.timeout.present?
67
74
  conn.headers = headers
68
75
  end
69
76
 
@@ -89,9 +89,9 @@ class Purple::Responses::Body
89
89
  check_structure!(object[key], substructure[key])
90
90
  end
91
91
  elsif value.is_a?(Array)
92
- if object[key].nil?
92
+ if object[key].blank?
93
93
  raise BodyStructureMismatchError.new(key, value, nil, object),
94
- "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."
94
+ "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
95
  end
96
96
 
97
97
  type = value.first
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Purple
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9.1"
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.8
4
+ version: 0.1.9.1
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-07 00:00:00.000000000 Z
11
+ date: 2025-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer