hyperion_http 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hyperion/aux/version.rb +1 -1
- data/lib/hyperion/formats.rb +1 -0
- data/lib/hyperion/headers.rb +3 -2
- data/lib/hyperion/types/multipart.rb +9 -1
- data/spec/fixtures/test +0 -0
- data/spec/lib/hyperion/formats_spec.rb +7 -0
- data/spec/lib/hyperion/headers_spec.rb +1 -0
- data/spec/lib/hyperion_test/fake_route_spec.rb +24 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff839cd9280b6f5ca5629404af5eed86a6bd44e4
|
4
|
+
data.tar.gz: 4cfd0125216b32cb9c01f59cda244314a0eb0994
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 656b2d028d48ff5d374fca0c048ef55b6e97e5aff5fede47bb2adc5bd5c840406bfca6ce587933747584003dbf71589ddda53afcce573b438742784bcf3c7bec
|
7
|
+
data.tar.gz: f1c71106ea625105e8a02fc4d8edb6c600b641e45982300c2b661132f341fd363af5f74317f3c32be8c9dfbe25bc33013a6312b4ac2109aa228e37baaf4ca2ef
|
data/lib/hyperion/aux/version.rb
CHANGED
data/lib/hyperion/formats.rb
CHANGED
data/lib/hyperion/headers.rb
CHANGED
@@ -27,7 +27,8 @@ class Hyperion
|
|
27
27
|
end
|
28
28
|
|
29
29
|
ContentTypes = [[:json, 'application/json'],
|
30
|
-
[:protobuf, 'application/x-protobuf']
|
30
|
+
[:protobuf, 'application/x-protobuf'],
|
31
|
+
[Multipart.format, Multipart.content_type]]
|
31
32
|
|
32
33
|
def content_type_for(format)
|
33
34
|
format = Hyperion::Formats.get_from(format)
|
@@ -36,7 +37,7 @@ class Hyperion
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def format_for(content_type)
|
39
|
-
ct = ContentTypes.detect{|x| x.last == content_type}
|
40
|
+
ct = ContentTypes.detect{|x| x.last == content_type.split(';')[0]}
|
40
41
|
fail "Unsupported content type: #{content_type}" unless ct
|
41
42
|
ct.first
|
42
43
|
end
|
data/spec/fixtures/test
ADDED
File without changes
|
@@ -82,6 +82,13 @@ class Hyperion
|
|
82
82
|
it 'allows protobuf format but just passes it through' do
|
83
83
|
expect(read('x', :protobuf)).to eql 'x'
|
84
84
|
end
|
85
|
+
it 'allows multipart format data format but just passes it through' do
|
86
|
+
data = '--------------------------0bf18f00cf53ec0e' +
|
87
|
+
'Content-Disposition: form-data; name="file"; filename="test"' +
|
88
|
+
'Content-Type: application/octet-stream' +
|
89
|
+
'--------------------------0bf18f00cf53ec0e--'
|
90
|
+
expect(read(data, Multipart.format)).to eql data
|
91
|
+
end
|
85
92
|
end
|
86
93
|
end
|
87
94
|
end
|
@@ -51,6 +51,7 @@ class Hyperion
|
|
51
51
|
it 'returns the format for the given content type' do
|
52
52
|
expect(format_for('application/json')).to eql :json
|
53
53
|
expect(format_for('application/x-protobuf')).to eql :protobuf
|
54
|
+
expect(format_for('multipart/form-data; boundary=------------------------2b463b63688b28fa')).to eql Multipart.format
|
54
55
|
end
|
55
56
|
it 'raises an error if the content type is unknown' do
|
56
57
|
expect{format_for('aaa/bbb')}.to raise_error
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'hyperion/requestor'
|
3
|
+
require 'hyperion_test'
|
4
|
+
|
5
|
+
describe 'fake_route' do
|
6
|
+
include Hyperion::Requestor
|
7
|
+
|
8
|
+
context 'for multipart form data as a part of the body' do
|
9
|
+
let(:uri) { File.join('http://test.com', 'convert') }
|
10
|
+
let(:response_descriptor) { ResponseDescriptor.new('converted_sample', 1, :json) }
|
11
|
+
let(:route) { RestRoute.new(:post, uri, response_descriptor) }
|
12
|
+
let(:response) { {'x' => 1} }
|
13
|
+
|
14
|
+
it 'it fakes the given response' do
|
15
|
+
fake_route(route, JSON.dump(response))
|
16
|
+
expect(make_request(route)).to eql response
|
17
|
+
end
|
18
|
+
|
19
|
+
def make_request(route)
|
20
|
+
body = Multipart.new(file: File.open(File.expand_path('spec/fixtures/test'), 'r'))
|
21
|
+
request(route, body: body)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperion_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Indigo BioAutomation, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -241,6 +241,7 @@ files:
|
|
241
241
|
- lib/hyperion_test/fake_server/types.rb
|
242
242
|
- lib/hyperion_test/spec_helper.rb
|
243
243
|
- lib/hyperion_test/test_framework_hooks.rb
|
244
|
+
- spec/fixtures/test
|
244
245
|
- spec/lib/hyperion/aux/util_spec.rb
|
245
246
|
- spec/lib/hyperion/formats_spec.rb
|
246
247
|
- spec/lib/hyperion/headers_spec.rb
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- spec/lib/hyperion/types/hyperion_result_spec.rb
|
252
253
|
- spec/lib/hyperion/types/hyperion_uri_spec.rb
|
253
254
|
- spec/lib/hyperion_spec.rb
|
255
|
+
- spec/lib/hyperion_test/fake_route_spec.rb
|
254
256
|
- spec/lib/types_spec.rb
|
255
257
|
- spec/spec_helper.rb
|
256
258
|
- spec/support/core_helpers.rb
|
@@ -279,6 +281,7 @@ signing_key:
|
|
279
281
|
specification_version: 4
|
280
282
|
summary: Ruby REST client
|
281
283
|
test_files:
|
284
|
+
- spec/fixtures/test
|
282
285
|
- spec/lib/hyperion/aux/util_spec.rb
|
283
286
|
- spec/lib/hyperion/formats_spec.rb
|
284
287
|
- spec/lib/hyperion/headers_spec.rb
|
@@ -289,6 +292,7 @@ test_files:
|
|
289
292
|
- spec/lib/hyperion/types/hyperion_result_spec.rb
|
290
293
|
- spec/lib/hyperion/types/hyperion_uri_spec.rb
|
291
294
|
- spec/lib/hyperion_spec.rb
|
295
|
+
- spec/lib/hyperion_test/fake_route_spec.rb
|
292
296
|
- spec/lib/types_spec.rb
|
293
297
|
- spec/spec_helper.rb
|
294
298
|
- spec/support/core_helpers.rb
|