async-rest 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/async-rest.gemspec +1 -1
- data/lib/async/rest/resource.rb +16 -7
- data/lib/async/rest/version.rb +1 -1
- data/lib/async/rest/wrapper/json.rb +6 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99c709ef59de6ef14480af19a3126f41ebe0c632da11c31a70ecc0fd10cdbe28
|
4
|
+
data.tar.gz: 8f0ec6398542b8c1240dab2d545b876812500429c864d7d7b63195389e1bfa16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95d54f61a3b812dbe47e81321a51e6eda5d341fb503339e4700d4662fa18ef4778a45950e661a011cd5ed5f41ab7430bd40f0cb7dce3ea04ebe11a7d115df215
|
7
|
+
data.tar.gz: 0b607070cd4baaf8dc998f5abbb8b0d256be2285bfe0aa38d347e7beb6575bd03d33c1c9717abac7452dc9f80ea8d8a345ff84db58ebafcac26fd747faf6ed97
|
data/async-rest.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "async-http", "~> 0.
|
19
|
+
spec.add_dependency "async-http", "~> 0.37.0"
|
20
20
|
|
21
21
|
spec.add_development_dependency "async-rspec", "~> 1.1"
|
22
22
|
|
data/lib/async/rest/resource.rb
CHANGED
@@ -28,8 +28,12 @@ require 'async/http/url_endpoint'
|
|
28
28
|
module Async
|
29
29
|
module REST
|
30
30
|
class Resource < HTTP::Middleware
|
31
|
-
|
32
|
-
|
31
|
+
# @param delegate [Async::HTTP::Middleware] the delegate that will handle requests.
|
32
|
+
# @param reference [Async::HTTP::Reference] the base request path/parameters.
|
33
|
+
# @param headers [Async::HTTP::Headers] the default headers that will be supplied with the request.
|
34
|
+
# @param wrapper [#prepare_request, #process_response] the wrapper for encoding/decoding the request/response body.
|
35
|
+
def initialize(delegate, reference = HTTP::Reference.parse, headers = HTTP::Headers.new, wrapper = Wrapper::JSON.new)
|
36
|
+
super(delegate)
|
33
37
|
|
34
38
|
@reference = reference
|
35
39
|
@headers = headers
|
@@ -39,8 +43,9 @@ module Async
|
|
39
43
|
def self.connect(url)
|
40
44
|
endpoint = HTTP::URLEndpoint.parse(url)
|
41
45
|
|
42
|
-
reference = HTTP::Reference.parse(endpoint.
|
46
|
+
reference = HTTP::Reference.parse(endpoint.path)
|
43
47
|
|
48
|
+
# return HTTP::Client.new(endpoint), reference
|
44
49
|
return HTTP::AcceptEncoding.new(HTTP::Client.new(endpoint)), reference
|
45
50
|
end
|
46
51
|
|
@@ -58,16 +63,20 @@ module Async
|
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
|
-
attr :client
|
62
66
|
attr :reference
|
63
67
|
attr :headers
|
68
|
+
attr :wrapper
|
64
69
|
|
65
70
|
def self.nest(parent, path = nil, *args)
|
66
|
-
self.new(*args, parent.
|
71
|
+
self.new(*args, parent.delegate, parent.reference.dup(path), parent.headers, parent.wrapper)
|
67
72
|
end
|
68
73
|
|
69
|
-
def
|
70
|
-
self.class.
|
74
|
+
def nest(path, *args)
|
75
|
+
self.class.nest(self, path, *args)
|
76
|
+
end
|
77
|
+
|
78
|
+
def with(headers)
|
79
|
+
self.class.new(@delegate, @reference, @headers.merge(headers), @wrapper)
|
71
80
|
end
|
72
81
|
|
73
82
|
def prepare_request(verb, payload = nil, headers = nil, **parameters)
|
data/lib/async/rest/version.rb
CHANGED
@@ -20,13 +20,17 @@
|
|
20
20
|
|
21
21
|
require 'json'
|
22
22
|
|
23
|
+
require 'async/http/body/wrapper'
|
24
|
+
require 'async/http/body/buffered'
|
25
|
+
|
23
26
|
module Async
|
24
27
|
module REST
|
25
28
|
module Wrapper
|
26
29
|
class JSON
|
27
|
-
|
30
|
+
APPLICATION_JSON = "application/json".freeze
|
31
|
+
APPLICATION_JSON_STREAM = "application/json; boundary=NL".freeze
|
28
32
|
|
29
|
-
def initialize(content_type =
|
33
|
+
def initialize(content_type = APPLICATION_JSON)
|
30
34
|
@content_type = content_type
|
31
35
|
end
|
32
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.37.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.37.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.7.
|
120
|
+
rubygems_version: 2.7.7
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: A library for RESTful clients (and hopefully servers).
|