ruby-manta 2.0.1 → 2.1.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
  SHA1:
3
- metadata.gz: 4b636e55491d14ec82b6c9d2bb7db81b3a27e8e2
4
- data.tar.gz: 13359dea81e874109311d507442f20999d6e6311
3
+ metadata.gz: de7bfde003051167ceb812eeeee748fe405107ef
4
+ data.tar.gz: fa140f03d2becadedd4e1837a4cde82be2d5f937
5
5
  SHA512:
6
- metadata.gz: 932ad21b320335849abdade93cc2d51fdc18a3ae3672d4ce42886c61a11a8c9b246ead95fecff4cef713f18ccfd014bfb7e30e0a8ade652ba68caf1bebcbd1ba
7
- data.tar.gz: c66a383843d985524cacfa07a9660674de8dfd36cba20f0df13ef44b97b1bc0b7fb2ca069b6ab94a9c5d1ec41e32baa76310aeec38ec071cdecd4643126dfc91
6
+ metadata.gz: 997933f4865d0b6241fde0506319a08945cd15db8c4407e57b6609969f90d60e833d304873c37101e35f7852d58a578a0045cbc79eb16297ba72f3bb748a556b
7
+ data.tar.gz: 7aafc92abb2b0e3ac969bfe05242f2cca4ed99f6e8c8de50ecf7165ed451af068a357cb3b1a87bec5dbe8b422377cea150e87b6c62f6157d045e139535493bfc
data/README.md CHANGED
@@ -169,9 +169,9 @@ supports it either.
169
169
 
170
170
  Changes in 2.0.0
171
171
  ----------------
172
- * MantaClient was moved into the namespace RubyManta::MantaClient. Compatibility
173
- with the namespaceless 1.0.0 MantaClient was maintained, but it may not be
174
- there in the future, so please update your application code.
172
+ * MantaClient was moved into the namespace RubyManta::MantaClient.
173
+ Compatibility with the namespaceless 1.0.0 MantaClient was maintained, but it
174
+ may not be there in the future, so please update your application code.
175
175
  * Subuser support was added to the client.
176
176
 
177
177
 
@@ -328,6 +328,26 @@ You can also pass in :origin to most object- and directory-related methods.
328
328
 
329
329
 
330
330
 
331
+ Custom headers
332
+ --------------
333
+
334
+ Manta allows additional custom headers to be
335
+ [added with an object](https://apidocs.joyent.com/manta/storage-reference.html#custom-headers).
336
+ When the object is retrieved, the custom headers are returned as well.
337
+
338
+ ruby-manta supports this, by adding any :m_* arguments as headers to an object.
339
+ For example, to add an 'M-Foobar' header with an object:
340
+
341
+ ```ruby
342
+
343
+ client.put_object(/john/stor/passwd', 'weak', :m_foobar => 'baz')
344
+ ```
345
+
346
+ A reminder when reading back headers (e.g. using get_object()) that header names
347
+ are case-insensitive (see RFC 2616). 'M-Foobar' may return as 'm-foobar'.
348
+
349
+
350
+
331
351
  initialize(manta_host, user, priv_key, _options_)
332
352
  -------------------------------------------------
333
353
 
@@ -850,6 +850,13 @@ module RubyManta
850
850
 
851
851
 
852
852
 
853
+ # :m_some_header becomes "M-Some-Header"
854
+ def symbol_to_header(header_symbol)
855
+ header_symbol.to_s.split('_').map(&:capitalize).join('-')
856
+ end
857
+
858
+
859
+
853
860
  # Creates headers to be given to the HTTP client and sent to the Manta
854
861
  # service. The most important is the Authorization header, without which
855
862
  # none of this class would work.
@@ -889,6 +896,13 @@ module RubyManta
889
896
  headers.push([ 'Origin', origin ])
890
897
  end
891
898
 
899
+ custom_headers = opts.keys.select { |key| key.to_s.start_with? 'm_' }
900
+ unless custom_headers.empty?
901
+ headers += custom_headers.map do |header_key|
902
+ [ symbol_to_header(header_key), opts[header_key] ]
903
+ end
904
+ end
905
+
892
906
  # add md5 hash when sending data
893
907
  data = opts[:data]
894
908
  if data
@@ -1,3 +1,3 @@
1
1
  module RubyManta
2
- VERSION = '2.0.1'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -207,11 +207,13 @@ class TestMantaClient < Minitest::Test
207
207
 
208
208
  @@client.put_object(@@test_dir_path + '/obj1', 'bar-data',
209
209
  :content_type => 'application/wacky',
210
- :durability_level => 3)
210
+ :durability_level => 3,
211
+ :m_zip => 'zap')
211
212
 
212
213
  result, headers = @@client.get_object(@@test_dir_path + '/obj1')
213
214
  assert_equal result, 'bar-data'
214
215
  assert_equal headers['Content-Type'], 'application/wacky'
216
+ assert_equal headers['m-zip'], 'zap'
215
217
 
216
218
  result, headers = @@client.get_object(@@test_dir_path + '/obj1', :head => true)
217
219
  assert_equal result, true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-manta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joyent