fog 0.2.25 → 0.2.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.2.25'
10
+ s.version = '0.2.26'
11
11
  s.date = '2010-08-18'
12
12
  s.rubyforge_project = 'fog'
13
13
 
data/lib/fog.rb CHANGED
@@ -41,7 +41,7 @@ require 'fog/vcloud'
41
41
  module Fog
42
42
 
43
43
  unless const_defined?(:VERSION)
44
- VERSION = '0.2.25'
44
+ VERSION = '0.2.26'
45
45
  end
46
46
 
47
47
  module Mock
@@ -30,6 +30,7 @@ module Fog
30
30
  options
31
31
  )
32
32
  if parent
33
+ merge_attributes(parent.files.attributes)
33
34
  load(parent.files.map {|file| file.attributes})
34
35
  else
35
36
  nil
@@ -61,23 +61,28 @@ module Fog
61
61
  end
62
62
  response = Excon::Response.new
63
63
  if bucket = @data[:buckets][bucket_name]
64
+ contents = bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
65
+ (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
66
+ (options['marker'] && object['Key'] <= options['marker'])
67
+ end.map do |object|
68
+ data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)}
69
+ data.merge!({
70
+ 'LastModified' => Time.parse(data['LastModified']),
71
+ 'Owner' => bucket['Owner'],
72
+ 'Size' => data['Size'].to_i
73
+ })
74
+ data
75
+ end
76
+ max_keys = options['max-keys'] || 1000
77
+ size = [max_keys, 1000].min
78
+ truncated_contents = contents[0...size]
79
+
64
80
  response.status = 200
65
81
  response.body = {
66
- 'Contents' => bucket[:objects].values.sort {|x,y| x['Key'] <=> y['Key']}.reject do |object|
67
- (options['prefix'] && object['Key'][0...options['prefix'].length] != options['prefix']) ||
68
- (options['marker'] && object['Key'] <= options['marker'])
69
- end.map do |object|
70
- data = object.reject {|key, value| !['ETag', 'Key', 'LastModified', 'Size', 'StorageClass'].include?(key)}
71
- data.merge!({
72
- 'LastModified' => Time.parse(data['LastModified']),
73
- 'Owner' => bucket['Owner'],
74
- 'Size' => data['Size'].to_i
75
- })
76
- data
77
- end,
78
- 'IsTruncated' => false,
82
+ 'Contents' => truncated_contents,
83
+ 'IsTruncated' => truncated_contents.size != contents.size,
79
84
  'Marker' => options['marker'],
80
- 'MaxKeys' => options['max-keys'] || 1000,
85
+ 'MaxKeys' => max_keys,
81
86
  'Name' => bucket['Name'],
82
87
  'Prefix' => options['prefix']
83
88
  }
@@ -3,10 +3,13 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
3
3
  describe 'Fog::AWS::S3::Files' do
4
4
 
5
5
  before(:each) do
6
- @directory = AWS[:s3].directories.create(:key => 'fogdirectoryname')
6
+ @directory = AWS[:s3].directories.create(:key => "fog#{Time.now.to_f}")
7
7
  end
8
8
 
9
9
  after(:each) do
10
+ until @directory.files.reload.empty?
11
+ @directory.files.each {|file| file.destroy}
12
+ end
10
13
  @directory.destroy
11
14
  end
12
15
 
@@ -34,6 +37,25 @@ describe 'Fog::AWS::S3::Files' do
34
37
  directory.files.all.should be_nil
35
38
  end
36
39
 
40
+ it "should return 1000 files and report truncated" do
41
+ 1010.times do |n|
42
+ @directory.files.create(:key => "file-#{n}")
43
+ end
44
+ response = @directory.files.all
45
+ response.should have(1000).items
46
+ response.is_truncated.should be_true
47
+ end
48
+
49
+ it "should limit the max_keys to 1000" do
50
+ 1010.times do |n|
51
+ @directory.files.create(:key => "file-#{n}")
52
+ end
53
+ response = @directory.files.all(:max_keys => 2000)
54
+ response.should have(1000).items
55
+ response.max_keys.should == 2000
56
+ response.is_truncated.should be_true
57
+ end
58
+
37
59
  end
38
60
 
39
61
  describe "#create" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 25
9
- version: 0.2.25
8
+ - 26
9
+ version: 0.2.26
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)