async-rest 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/rest/representation.rb +21 -10
- data/lib/async/rest/resource.rb +6 -6
- data/lib/async/rest/version.rb +2 -2
- data/lib/async/rest/wrapper/form.rb +6 -6
- data/lib/async/rest/wrapper/generic.rb +1 -1
- data/lib/async/rest/wrapper/json.rb +8 -8
- data/lib/async/rest/wrapper/url_encoded.rb +8 -8
- data/lib/async/rest.rb +3 -3
- data/readme.md +3 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a25bf93c109edc39f017bd8897b6f40cd588f9d09cd49ab0c121019a1aeb581
|
4
|
+
data.tar.gz: 29ada9fd6af46ba978cf89a24b7741ce94bcb779c0f1beaf87c174b33a98cd63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9667632e07ff0d8a72c26eb1cdf68f9f765b390cddbf604402b67f79e70cb493860d172dd25eab00dd3c2934f5f69ddfbdb6fe14e5585845420bff0cd84bf02
|
7
|
+
data.tar.gz: 01c2a95426350e1b53dbc477176f9c6e75f0d244974c8308c6244678524cf5f3a67f797f2acf3ab3b835806caeeea9f9b1c0026e2996e551df773990b7aa072e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
# Copyright, 2021, by Terry Kerr.
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
7
|
+
require_relative "error"
|
8
|
+
require_relative "resource"
|
9
|
+
require_relative "wrapper/json"
|
10
10
|
|
11
11
|
module Async
|
12
12
|
module REST
|
@@ -31,21 +31,32 @@ module Async
|
|
31
31
|
end
|
32
32
|
|
33
33
|
class << self
|
34
|
-
::Protocol::HTTP::Methods.each do |name,
|
35
|
-
define_method(
|
36
|
-
self::WRAPPER.call(resource,
|
34
|
+
::Protocol::HTTP::Methods.each do |name, method|
|
35
|
+
define_method(method.downcase) do |resource, payload = nil, &block|
|
36
|
+
self::WRAPPER.call(resource, method, payload) do |response|
|
37
37
|
return self.for(resource, response, &block)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# Instantiate a new representation from a resource and response.
|
44
|
+
#
|
45
|
+
# If a block is given, it is called with the resource and response, and the return value is used as the representation.
|
46
|
+
#
|
47
|
+
# @returns [Representation] the representation of the resource.
|
43
48
|
def self.for(resource, response, &block)
|
44
49
|
if block_given?
|
45
|
-
block.
|
50
|
+
if block.arity == 1
|
51
|
+
# Original behaviour:
|
52
|
+
yield(response)
|
53
|
+
else
|
54
|
+
# New behaviour:
|
55
|
+
return yield(resource, response)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
return self.new(resource, value: response.read, metadata: response.headers)
|
46
59
|
end
|
47
|
-
|
48
|
-
return self.new(resource, value: response.read, metadata: response.headers)
|
49
60
|
end
|
50
61
|
|
51
62
|
# @param resource [Resource] the RESTful resource that this representation is of.
|
data/lib/async/rest/resource.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require "async"
|
7
|
+
require "async/http/client"
|
8
|
+
require "async/http/endpoint"
|
9
9
|
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "protocol/http/accept_encoding"
|
11
|
+
require "protocol/http/reference"
|
12
12
|
|
13
13
|
module Async
|
14
14
|
module REST
|
data/lib/async/rest/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "json"
|
7
|
+
require_relative "url_encoded"
|
8
8
|
|
9
9
|
module Async
|
10
10
|
module REST
|
@@ -21,11 +21,11 @@ module Async
|
|
21
21
|
|
22
22
|
def prepare_request(request, payload)
|
23
23
|
@content_types.each_key do |key|
|
24
|
-
request.headers.add(
|
24
|
+
request.headers.add("accept", key)
|
25
25
|
end
|
26
26
|
|
27
27
|
if payload
|
28
|
-
request.headers[
|
28
|
+
request.headers["content-type"] = URLEncoded::APPLICATION_FORM_URLENCODED
|
29
29
|
|
30
30
|
request.body = ::Protocol::HTTP::Body::Buffered.new([
|
31
31
|
::Protocol::HTTP::URL.encode(payload)
|
@@ -34,7 +34,7 @@ module Async
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def parser_for(response)
|
37
|
-
if content_type = response.headers[
|
37
|
+
if content_type = response.headers["content-type"]
|
38
38
|
if parser = @content_types[content_type]
|
39
39
|
return parser
|
40
40
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "json"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "protocol/http/body/wrapper"
|
9
|
+
require "protocol/http/body/buffered"
|
10
10
|
|
11
|
-
require_relative
|
11
|
+
require_relative "generic"
|
12
12
|
|
13
13
|
module Async
|
14
14
|
module REST
|
@@ -28,10 +28,10 @@ module Async
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def prepare_request(request, payload)
|
31
|
-
request.headers[
|
31
|
+
request.headers["accept"] ||= @content_type
|
32
32
|
|
33
33
|
if payload
|
34
|
-
request.headers[
|
34
|
+
request.headers["content-type"] = @content_type
|
35
35
|
|
36
36
|
request.body = ::Protocol::HTTP::Body::Buffered.new([
|
37
37
|
::JSON.dump(payload)
|
@@ -46,7 +46,7 @@ module Async
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def parser_for(response)
|
49
|
-
if content_type = response.headers[
|
49
|
+
if content_type = response.headers["content-type"]
|
50
50
|
if content_type.start_with? @content_type
|
51
51
|
return Parser
|
52
52
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require
|
6
|
+
require "json"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "protocol/http/body/wrapper"
|
9
|
+
require "protocol/http/body/buffered"
|
10
10
|
|
11
|
-
require_relative
|
11
|
+
require_relative "generic"
|
12
12
|
|
13
13
|
module Async
|
14
14
|
module REST
|
@@ -27,10 +27,10 @@ module Async
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def prepare_request(request, payload)
|
30
|
-
request.headers[
|
30
|
+
request.headers["accept"] ||= @content_type
|
31
31
|
|
32
32
|
if payload
|
33
|
-
request.headers[
|
33
|
+
request.headers["content-type"] = @content_type
|
34
34
|
|
35
35
|
request.body = ::Protocol::HTTP::Body::Buffered.new([
|
36
36
|
::Protocol::HTTP::URL.encode(payload)
|
@@ -45,7 +45,7 @@ module Async
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def parser_for(response)
|
48
|
-
if content_type = response.headers[
|
48
|
+
if content_type = response.headers["content-type"]
|
49
49
|
if content_type.start_with? @content_type
|
50
50
|
return Parser
|
51
51
|
end
|
data/lib/async/rest.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-
|
4
|
+
# Copyright, 2018-2024, by Samuel Williams.
|
5
5
|
|
6
|
-
require_relative
|
7
|
-
require_relative
|
6
|
+
require_relative "rest/version"
|
7
|
+
require_relative "rest/representation"
|
data/readme.md
CHANGED
@@ -27,8 +27,8 @@ We welcome contributions to this project.
|
|
27
27
|
|
28
28
|
### Developer Certificate of Origin
|
29
29
|
|
30
|
-
|
30
|
+
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
|
31
31
|
|
32
|
-
###
|
32
|
+
### Community Guidelines
|
33
33
|
|
34
|
-
This project is
|
34
|
+
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -40,7 +40,7 @@ cert_chain:
|
|
40
40
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
41
41
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
42
42
|
-----END CERTIFICATE-----
|
43
|
-
date: 2024-09-
|
43
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: async-http
|
metadata.gz.sig
CHANGED
Binary file
|