async-rest 0.6.0 → 0.7.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: b348ab4bc1a06560f1f075791ddc9859f7b9148ea9df6befebc7bb228caee779
4
- data.tar.gz: 596bad25fb27370bceb0eef0825a3af51ac34dcf27ff97a84e345aeb77d7aac0
3
+ metadata.gz: 3f371511181c4977c4b1adc61434464b6a0d919b5284dbc31c325d61dfa720fd
4
+ data.tar.gz: 93b321234513a434b44eebf522cbe0b944730f354074d6486b81140fc5a5f07d
5
5
  SHA512:
6
- metadata.gz: d6998bb2e970995d1e09033ad118097cd4dcfb5af7b0cd95bafb6c0e205649cccc4ad84eef951b797ce5b7e59a3328e0269ae660b8d9e4ce70f4cbc0abc04223
7
- data.tar.gz: ae37524edc67a1ee70c3cb884e9b4bbfc0000a0d24dc90f572965e2e3e9a22be334c71ff6ce5a2b4fc048a6d26cfc15a8c7b8a12a5bc5b5970fd442c7e1ba5a3
6
+ metadata.gz: 765a7d85ea961a51313614514f9762acd837293e528b128bcffa3f7fb8ff0308186222448690f5ca198489bcf49b356a5ec05bcfa47d9aa90cb6b3113511bf03
7
+ data.tar.gz: cd31bc226e87d07bd6ff911629a619102ee8904400f927fc102221bf29f1389afcc15a51a6506c841e3de8a821b2d0502ec74b4d81c14506c77639f7d3a20d8f
@@ -1,10 +1,7 @@
1
1
  language: ruby
2
+ dist: xenial
2
3
  cache: bundler
3
4
 
4
- before_script:
5
- - gem update --system
6
- - gem install bundler
7
-
8
5
  matrix:
9
6
  include:
10
7
  - rvm: 2.3
@@ -13,9 +10,11 @@ matrix:
13
10
  - rvm: 2.6
14
11
  - rvm: jruby-head
15
12
  env: JRUBY_OPTS="--debug -X+O"
13
+ - rvm: truffleruby
16
14
  - rvm: ruby-head
17
15
  - rvm: rbx-3
18
16
  allow_failures:
19
17
  - rvm: ruby-head
20
18
  - rvm: jruby-head
21
19
  - rvm: rbx-3
20
+ - rvm: truffleruby
data/Gemfile CHANGED
@@ -6,7 +6,3 @@ gemspec
6
6
  group :development do
7
7
  gem 'pry'
8
8
  end
9
-
10
- group :test do
11
- gem 'covered', require: 'covered/rspec' if RUBY_VERSION >= "2.6.0"
12
- end
@@ -17,10 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency "async-http", "~> 0.37.0"
20
+ spec.add_dependency "http-protocol", "~> 0.14"
20
21
 
21
22
  spec.add_development_dependency "async-rspec", "~> 1.1"
22
23
 
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "covered"
25
+ spec.add_development_dependency "bundler"
24
26
  spec.add_development_dependency "rspec", "~> 3.6"
25
27
  spec.add_development_dependency "rake"
26
28
  end
@@ -30,8 +30,8 @@ module Async
30
30
  #
31
31
  # A representation consists of data, metadata describing the data, and, on occasion, metadata to describe the metadata (usually for the purpose of verifying message integrity). Metadata is in the form of name-value pairs, where the name corresponds to a standard that defines the value's structure and semantics. Response messages may include both representation metadata and resource metadata: information about the resource that is not specific to the supplied representation.
32
32
  class Representation
33
- def self.for(*args)
34
- self.new(Resource.for(*args))
33
+ def self.for(*args, **options)
34
+ self.new(Resource.for(*args), **options)
35
35
  end
36
36
 
37
37
  # @param resource [Resource] the RESTful resource that this representation is of.
@@ -67,7 +67,9 @@ module Async
67
67
  attr :headers
68
68
 
69
69
  def self.with(parent, *args, headers: {}, parameters: nil, path: nil)
70
- self.new(*args, parent.delegate, parent.reference.dup(path, parameters), parent.headers.merge(headers))
70
+ reference = parent.reference.dup(path, parameters)
71
+
72
+ self.new(*args, parent.delegate, reference, parent.headers.merge(headers))
71
73
  end
72
74
 
73
75
  def with(*args, **options)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module REST
23
- VERSION = "0.6.0"
23
+ VERSION = "0.7.0"
24
24
  end
25
25
  end
@@ -34,6 +34,8 @@ module Async
34
34
  @content_type = content_type
35
35
  end
36
36
 
37
+ attr :content_type
38
+
37
39
  def split(*args)
38
40
  @content_type.split
39
41
  end
@@ -0,0 +1,76 @@
1
+ # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require 'json'
22
+
23
+ require 'async/http/body/wrapper'
24
+ require 'async/http/body/buffered'
25
+
26
+ module Async
27
+ module REST
28
+ module Wrapper
29
+ class URLEncoded
30
+ APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded".freeze
31
+
32
+ def initialize(content_type = APPLICATION_FORM_URLENCODED)
33
+ @content_type = content_type
34
+ end
35
+
36
+ attr :content_type
37
+
38
+ def split(*args)
39
+ @content_type.split
40
+ end
41
+
42
+ def prepare_request(payload, headers)
43
+ headers['accept'] ||= @content_type
44
+
45
+ if payload
46
+ headers['content-type'] = @content_type
47
+
48
+ HTTP::Body::Buffered.new([
49
+ ::HTTP::Protocol::URL.encode(payload)
50
+ ])
51
+ end
52
+ end
53
+
54
+ def process_response(request, response)
55
+ if content_type = response.headers['content-type']
56
+ if content_type.start_with? @content_type
57
+ if body = response.body
58
+ response.body = Parser.new(body)
59
+ end
60
+ else
61
+ warn "Unknown content type: #{content_type}!"
62
+ end
63
+ end
64
+
65
+ return response
66
+ end
67
+
68
+ class Parser < HTTP::Body::Wrapper
69
+ def join
70
+ ::HTTP::Protocol::URL.decode(super, symbolize_keys: true)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
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.6.0
4
+ version: 0.7.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-12-28 00:00:00.000000000 Z
11
+ date: 2019-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.37.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: http-protocol
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.14'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.14'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: async-rspec
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +52,34 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: covered
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: bundler
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
- - - "~>"
73
+ - - ">="
46
74
  - !ruby/object:Gem::Version
47
- version: '1.3'
75
+ version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - "~>"
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
- version: '1.3'
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rspec
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +128,7 @@ files:
100
128
  - lib/async/rest/resource.rb
101
129
  - lib/async/rest/version.rb
102
130
  - lib/async/rest/wrapper/json.rb
131
+ - lib/async/rest/wrapper/url_encoded.rb
103
132
  homepage: https://github.com/socketry/async-rest
104
133
  licenses: []
105
134
  metadata: {}
@@ -118,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
147
  - !ruby/object:Gem::Version
119
148
  version: '0'
120
149
  requirements: []
121
- rubygems_version: 3.0.1
150
+ rubygems_version: 3.0.2
122
151
  signing_key:
123
152
  specification_version: 4
124
153
  summary: A library for RESTful clients (and hopefully servers).