swift_client 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/swift_client.rb +1 -1
- data/lib/swift_client/version.rb +1 -1
- data/swift_client.gemspec +1 -1
- data/test/swift_client_test.rb +8 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9703134ee4b5656b16c32f49305288723eb7f66d6942c2f6392ac9f663803c96
|
4
|
+
data.tar.gz: 8f97e98bc8c83e549e4359b53891e0d12b4673a8990426704658a3c78289e546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b06d3358d7d40de924ccdaff5e1de219e1d4882ea5e607f9d9fdff47b260ce57338dbdc92d19f80c5b9908257d3397ca37b6ab38e6a0353ead8f63124e983659
|
7
|
+
data.tar.gz: 1c5fa028f57c0f460d4f4a28b52534033cf4045212ba64df9bd32d58fa2291377a81d5b815249b79e51db71c526405123b23991e94c09daeed2043bb2c9ee624
|
data/README.md
CHANGED
@@ -151,6 +151,8 @@ SwiftClient offers the following requests:
|
|
151
151
|
* `bulk_delete(entries, options = {}) # => entries`
|
152
152
|
* `post_head(object_name, container_name, _headers = {}, options = {}) # => HTTParty::Response`
|
153
153
|
|
154
|
+
By default, the client instructs the Swift server to return JSON via an HTTP Accept header; to disable this pass `:json => false` in `options`. The rest of the `options` are passed directly to the internal [HTTParty](https://rubygems.org/gems/httparty) client.
|
155
|
+
|
154
156
|
### Getting large objects
|
155
157
|
The `get_object` method with out a block is suitable for small objects that easily fit in memory. For larger objects, specify a block to process chunked data as it comes in.
|
156
158
|
|
data/lib/swift_client.rb
CHANGED
@@ -195,7 +195,7 @@ class SwiftClient
|
|
195
195
|
def request(method, path, opts = {}, &block)
|
196
196
|
headers = (opts[:headers] || {}).dup
|
197
197
|
headers["X-Auth-Token"] = auth_token
|
198
|
-
headers["Accept"]
|
198
|
+
headers["Accept"] ||= "application/json" unless opts.delete(:json) == false
|
199
199
|
|
200
200
|
stream_pos = opts[:body_stream].pos if opts[:body_stream]
|
201
201
|
|
data/lib/swift_client/version.rb
CHANGED
data/swift_client.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "httparty"
|
22
|
-
spec.add_dependency "mime-types"
|
22
|
+
spec.add_dependency "mime-types"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler"
|
25
25
|
spec.add_development_dependency "rake"
|
data/test/swift_client_test.rb
CHANGED
@@ -341,6 +341,14 @@ class SwiftClientTest < MiniTest::Test
|
|
341
341
|
assert_equal objects, @swift_client.get_objects("container-1", :limit => 2, :marker => "object-2").parsed_response
|
342
342
|
end
|
343
343
|
|
344
|
+
def test_get_objects_no_json
|
345
|
+
response = "object-2\nobject-3\n"
|
346
|
+
|
347
|
+
stub_request(:get, "https://example.com/v1/AUTH_account/container-1?limit=2&marker=object-2").with(:headers => { "X-Auth-Token" => "Token" }).to_return(:status => 200, :body => response, :headers => { "Content-Type" => "text/html" })
|
348
|
+
|
349
|
+
assert_equal response, @swift_client.get_objects("container-1", { :limit => 2, :marker => "object-2" }, :json => false).body
|
350
|
+
end
|
351
|
+
|
344
352
|
def test_paginate_objects
|
345
353
|
objects = [
|
346
354
|
{ "hash" => "Hash", "last_modified" => "Last modified", "bytes" => 1, "name" => "object-1", "content_type" => "Content type" },
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swift_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Vetter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: mime-types
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|