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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 839be8ad4eee0471cff7053c05692ae11178f8ab934c2485c61c09b67cca6cf0
4
- data.tar.gz: af6e5721af9c1585fcd03c3e95d886ad639b71b789972ac630ed62c4c7c9c264
3
+ metadata.gz: 99c709ef59de6ef14480af19a3126f41ebe0c632da11c31a70ecc0fd10cdbe28
4
+ data.tar.gz: 8f0ec6398542b8c1240dab2d545b876812500429c864d7d7b63195389e1bfa16
5
5
  SHA512:
6
- metadata.gz: 32ff875407f491ddf920a8ebe437ca91d7fc2d6bdaa343c61b40aa292a0ca380c7414c146ec16ce3d4125627eb8f21cf21f920ab110d9c23a32fc7c4a9d5e4bf
7
- data.tar.gz: 29a11597c7af0851afeb8eef0d053abe854451e4e0c9d3dc41c10f8ea1b36d20a22bcf7261d676d3a1d3a9ef24476133e46e153d8f826a3b7ef134896e0d5b80
6
+ metadata.gz: 95d54f61a3b812dbe47e81321a51e6eda5d341fb503339e4700d4662fa18ef4778a45950e661a011cd5ed5f41ab7430bd40f0cb7dce3ea04ebe11a7d115df215
7
+ data.tar.gz: 0b607070cd4baaf8dc998f5abbb8b0d256be2285bfe0aa38d347e7beb6575bd03d33c1c9717abac7452dc9f80ea8d8a345ff84db58ebafcac26fd747faf6ed97
@@ -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.27.12"
19
+ spec.add_dependency "async-http", "~> 0.37.0"
20
20
 
21
21
  spec.add_development_dependency "async-rspec", "~> 1.1"
22
22
 
@@ -28,8 +28,12 @@ require 'async/http/url_endpoint'
28
28
  module Async
29
29
  module REST
30
30
  class Resource < HTTP::Middleware
31
- def initialize(client, reference = HTTP::Reference.parse, headers = HTTP::Headers.new, wrapper = Wrapper::JSON.new)
32
- super(client)
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.url.request_uri)
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.client, parent.reference.dup(path), parent.headers, parent.wrapper)
71
+ self.new(*args, parent.delegate, parent.reference.dup(path), parent.headers, parent.wrapper)
67
72
  end
68
73
 
69
- def with(**headers)
70
- self.class.new(@client, @reference, @headers.merge(headers), @wrapper)
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)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module REST
23
- VERSION = "0.3.0"
23
+ VERSION = "0.4.0"
24
24
  end
25
25
  end
@@ -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
- CONTENT_TYPE = "application/json".freeze
30
+ APPLICATION_JSON = "application/json".freeze
31
+ APPLICATION_JSON_STREAM = "application/json; boundary=NL".freeze
28
32
 
29
- def initialize(content_type = 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.3.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-07-15 00:00:00.000000000 Z
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.27.12
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.27.12
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.6
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).