cloudflare 4.2.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dcc42587b1325b8ec2935b4b2bc93024dbf217928050c0ff84ce7623f805722
4
- data.tar.gz: e2c287268b345cd3f2e9edbd116180117b5ea7ea7d7156e7b53ac4f6c5f95e09
3
+ metadata.gz: 7df158b1fb45428a5bd2f3a2147700e691ed6a4bdadbc26f7a6cf0229d77ff98
4
+ data.tar.gz: 909cd8848e8368d670592c2108ffe1231147226d56d98e23e499807f48d80e8c
5
5
  SHA512:
6
- metadata.gz: 9a82ec080141604eafce382d2bf3f7986974e4c80ba108c0aa900ffafbb79b90b32e604ae497baa842e667878e3bbcfbf452848f24d448ff1935eecdfccb59bc
7
- data.tar.gz: e6137b9c6dbaf3dd81265a2e5b07c7e40b392a08abf49318ae4f3822c8edb14c71e1e7fa7650e24cd9b91009b27e9ded0fe53f4be235d26e4a57e5c64415cc84
6
+ metadata.gz: df08439266659d4232501e8cd22dc1013b5d7d764c9c0d09c3a2768704cb460031ef69139c72de03b5c84b3e8618e1714c1b00624652e3dd557e9206a0fedd3b
7
+ data.tar.gz: 7c006538e659c65ff3059f6bbbac4feaeed6ac36763f683498be20b2cc8b0ff7d42e0bc43faeda1a8786967a829b152d7575f52c8904502302c7a2a0aa818b95
@@ -5,6 +5,7 @@
5
5
 
6
6
  require_relative '../paginate'
7
7
  require_relative '../representation'
8
+ require_relative 'rest_wrapper'
8
9
 
9
10
  module Cloudflare
10
11
  module KV
@@ -55,7 +56,8 @@ module Cloudflare
55
56
  private
56
57
 
57
58
  def value_representation(name)
58
- self.with(Representation, path: "values/#{name}")
59
+ @representation_class ||= Representation[RESTWrapper]
60
+ self.with(@representation_class, path: "values/#{name}")
59
61
  end
60
62
  end
61
63
 
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module Cloudflare
6
+ module KV
7
+ class RESTWrapper < Async::REST::Wrapper::Generic
8
+ APPLICATION_OCTET_STREAM = 'application/octet-stream'
9
+ APPLICATION_JSON = 'application/json'
10
+ ACCEPT_HEADER = "#{APPLICATION_JSON}, #{APPLICATION_OCTET_STREAM}"
11
+
12
+ def prepare_request(payload, headers)
13
+ headers['accept'] ||= ACCEPT_HEADER
14
+
15
+ if payload
16
+ headers['content-type'] = APPLICATION_OCTET_STREAM
17
+ ::Protocol::HTTP::Body::Buffered.new([payload.to_s])
18
+ end
19
+ end
20
+
21
+ def parser_for(response)
22
+ if response.headers['content-type'].start_with?(APPLICATION_OCTET_STREAM)
23
+ OctetParser
24
+ elsif response.headers['content-type'].start_with?(APPLICATION_JSON)
25
+ JsonParser
26
+ else
27
+ Async::REST::Wrapper::Generic::Unsupported
28
+ end
29
+ end
30
+
31
+ class OctetParser < ::Protocol::HTTP::Body::Wrapper
32
+ def join
33
+ super
34
+ end
35
+ end
36
+
37
+ class JsonParser < ::Protocol::HTTP::Body::Wrapper
38
+ def join
39
+ JSON.parse(super, symbolize_names: true)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -22,5 +22,5 @@
22
22
  # THE SOFTWARE.
23
23
 
24
24
  module Cloudflare
25
- VERSION = '4.2.1'
25
+ VERSION = '4.3.0'
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Prokop
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-07-19 00:00:00.000000000 Z
12
+ date: 2021-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: async-rest
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.10.0
20
+ version: 0.12.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.10.0
27
+ version: 0.12.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: async-rspec
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +96,7 @@ files:
96
96
  - lib/cloudflare/dns.rb
97
97
  - lib/cloudflare/firewall.rb
98
98
  - lib/cloudflare/kv/namespaces.rb
99
+ - lib/cloudflare/kv/rest_wrapper.rb
99
100
  - lib/cloudflare/logs.rb
100
101
  - lib/cloudflare/paginate.rb
101
102
  - lib/cloudflare/representation.rb
@@ -122,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
123
  - !ruby/object:Gem::Version
123
124
  version: '0'
124
125
  requirements: []
125
- rubygems_version: 3.1.2
126
+ rubygems_version: 3.1.6
126
127
  signing_key:
127
128
  specification_version: 4
128
129
  summary: A Ruby wrapper for the Cloudflare API.