fakes3 0.2.1 → 0.2.2

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: 35ac3fdceddeef49ddeb95137f2dbfc8a719a4e2
4
- data.tar.gz: c88fa58f1a7b52b9fcbb1dae974175bed5c1c178
3
+ metadata.gz: 241deda826d3d91b172ce08830a500ee014d452a
4
+ data.tar.gz: 0fff1ebd2cd5e02f5f7ec9d5228927eef3802e2a
5
5
  SHA512:
6
- metadata.gz: d9a5a1c68ee5187593a2bb3aedec7e888b6f400b6c0882a1ebb8cb4323d81ed7d29c53657833da2564fea09bb3e9732eb34f6f78cfa63e2274910ae2f128c8d8
7
- data.tar.gz: 21cd19d83eed82e5b89511ad0a7b60e934c516f97295ce54b09135240f36c0523dd2927bf68765cb6ba219233c59595c0df17dbb425db84f562c215a8c3bf913
6
+ metadata.gz: 11825967dc25673fe37a311a7fc52e631c7c695186c9b0721b4468f6cb560ad7a22d1efbf06880759c8ae6d8cb27c900a5771820ae122a92fbc6e754c7fe5572
7
+ data.tar.gz: 9a5c1824a3fad9d4c59e71335e9231d7526acd7d2ce1a8415fbbf5ce6e27605ff9bdc4c4304b63e9136f3b2b88b3436d44a49d8ed06f32dfc179921cc53b92da
data/.gitignore CHANGED
@@ -6,3 +6,6 @@ test_root
6
6
 
7
7
  # Don't check in RVM/rbenv files
8
8
  .ruby-version
9
+
10
+ # RubyMine
11
+ .idea
data/README.md CHANGED
@@ -58,3 +58,5 @@ It is a still a TODO to get this to be just one command
58
58
  ## More Information
59
59
 
60
60
  Check out the [wiki](https://github.com/jubos/fake-s3/wiki)
61
+
62
+ [![Join the chat at https://gitter.im/jubos/fake-s3](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jubos/fake-s3?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -263,14 +263,18 @@ module FakeS3
263
263
  metadata[:content_type] = request.header["content-type"].first
264
264
  metadata[:size] = File.size(content)
265
265
  metadata[:modified_date] = File.mtime(content).utc.iso8601(SUBSECOND_PRECISION)
266
+ metadata[:amazon_metadata] = {}
266
267
  metadata[:custom_metadata] = {}
267
268
 
268
269
  # Add custom metadata from the request header
269
270
  request.header.each do |key, value|
270
- match = /^x-amz-meta-(.*)$/.match(key)
271
- if match && (match_key = match[1])
271
+ match = /^x-amz-([^-]+)-(.*)$/.match(key)
272
+ next unless match
273
+ if match[1].eql?('meta') && (match_key = match[2])
272
274
  metadata[:custom_metadata][match_key] = value.join(', ')
275
+ next
273
276
  end
277
+ metadata[:amazon_metadata][key.gsub(/^x-amz-/, '')] = value.join(', ')
274
278
  end
275
279
  return metadata
276
280
  end
@@ -1,3 +1,3 @@
1
1
  module FakeS3
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -28,4 +28,32 @@ class AwsSdkCommandsTest < Test::Unit::TestCase
28
28
  assert object.exists?
29
29
  assert_equal "thisisaverybigfile", object.read
30
30
  end
31
+
32
+ def test_metadata
33
+ file_path = './test_root/test_metadata/metaobject'
34
+ FileUtils.rm_rf file_path
35
+
36
+ bucket = @s3.buckets["test_metadata"]
37
+ object = bucket.objects["metaobject"]
38
+ object.write(
39
+ 'data',
40
+ # this is sent as header x-amz-storage-class
41
+ :storage_class => 'REDUCED_REDUNDANCY',
42
+ # this is sent as header x-amz-meta-custom1
43
+ :metadata => {
44
+ "custom1" => "foobar"
45
+ }
46
+ )
47
+ assert object.exists?
48
+ metadata_file = YAML.load(IO.read("#{file_path}/.fakes3_metadataFFF/metadata"))
49
+
50
+ assert metadata_file.has_key?(:custom_metadata), 'Metadata file does not contain a :custom_metadata key'
51
+ assert metadata_file[:custom_metadata].has_key?('custom1'), ':custom_metadata does not contain field "custom1"'
52
+ assert_equal 'foobar', metadata_file[:custom_metadata]['custom1'], '"custom1" does not equal expected value "foobar"'
53
+
54
+ assert metadata_file.has_key?(:amazon_metadata), 'Metadata file does not contain an :amazon_metadata key'
55
+ assert metadata_file[:amazon_metadata].has_key?('storage-class'), ':amazon_metadata does not contain field "storage-class"'
56
+ assert_equal 'REDUCED_REDUNDANCY', metadata_file[:amazon_metadata]['storage-class'], '"storage-class" does not equal expected value "REDUCED_REDUNDANCY"'
57
+
58
+ end
31
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakes3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curtis Spencer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler