massive_sitemap-writer-s3 0.0.1.rc3 → 0.0.1.rc4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1.rc3
1
+ 0.0.1.rc4
@@ -25,6 +25,7 @@ module MassiveSitemap
25
25
  object.save
26
26
  end
27
27
  end
28
+ ::File.delete(@filename) unless @options[:keep]
28
29
  end
29
30
 
30
31
  def load_stream_ids
data/spec/s3_spec.rb CHANGED
@@ -6,8 +6,8 @@ describe MassiveSitemap::Writer::S3 do
6
6
  let(:objects) { mock('objects', :find_all => [], :build => object) }
7
7
  let(:bucket) { mock('bucket', :objects => objects) }
8
8
  let(:service) { mock('service', :buckets => mock('buckets', :find => bucket)) }
9
- let(:writer) { MassiveSitemap::Writer::S3.new(s3_options) }
10
- let(:s3_options) { Hash.new(:access_key_id => "ak", :secret_access_key => "sa", :bucket => "bucket") }
9
+ let(:writer) { MassiveSitemap::Writer::S3.new(s3_cfg, :keep => true) }
10
+ let(:s3_cfg) { Hash.new(:access_key_id => "ak", :secret_access_key => "sa", :bucket => "bucket") }
11
11
 
12
12
  before do
13
13
  ::S3::Service.stub(:new).and_return(service)
@@ -15,7 +15,7 @@ describe MassiveSitemap::Writer::S3 do
15
15
 
16
16
  describe "initialize" do
17
17
  it "creates service" do
18
- ::S3::Service.should_receive(:new).with(s3_options).and_return(service)
18
+ ::S3::Service.should_receive(:new).with(s3_cfg).and_return(service)
19
19
  writer
20
20
  end
21
21
 
@@ -27,10 +27,12 @@ describe MassiveSitemap::Writer::S3 do
27
27
 
28
28
  describe "close_stream" do
29
29
  let(:filename) { "sitemap.xml.gz" }
30
- before do
31
- writer.init!
32
- end
33
30
 
31
+ before do
32
+ writer.init!
33
+ end
34
+
35
+ context "with keep option" do
34
36
  after do
35
37
  FileUtils.rm(filename)
36
38
  end
@@ -45,5 +47,15 @@ describe MassiveSitemap::Writer::S3 do
45
47
  object.should_receive(:"content=").once().and_return(true)
46
48
  writer.close!
47
49
  end
50
+ end
51
+
52
+ context "without keep option" do
53
+ let(:writer) { MassiveSitemap::Writer::S3.new(s3_cfg, :keep => false) }
54
+
55
+ it "deletes file on local system" do
56
+ writer.close!
57
+ File.exists?(filename).should be_false
58
+ end
59
+ end
48
60
  end
49
61
  end
data/spec/spec_helper.rb CHANGED
@@ -1,60 +1,3 @@
1
1
  $:.unshift File.expand_path("../../lib", __FILE__)
2
2
  require 'bundler/setup'
3
3
  require 'massive_sitemap-writer-s3'
4
-
5
-
6
- def setup
7
- @buckets_list_body = <<-EOBuckets
8
- <?xml version="1.0" encoding="UTF-8"?>\n<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Owner> <ID>123u1odhkhfoadf</ID> <DisplayName>JohnDoe</DisplayName> </Owner> <Buckets> <Bucket> <Name>data.example.com</Name> <CreationDate>2009-07-02T11:56:58.000Z</CreationDate> </Bucket> <Bucket> <Name>images</Name> <CreationDate>2009-06-05T12:26:33.000Z</CreationDate> </Bucket> </Buckets> </ListAllMyBucketsResult>
9
- EOBuckets
10
-
11
- @bucket_not_exists = <<-EOBucketNoexists
12
- <?xml version="1.0" encoding="UTF-8"?>\n<Error> <Code>NoSuchBucket</Code> <Message>The specified bucket does not exists</Message> <BucketName>data2.example.com</BucketName> <RequestId>8D7519AAE74E9E99</RequestId> <HostId>DvKnnNSMnPHd1oXukyRaFNv8Lg/bpwhuUtY8Kj7eDLbaIrIT8JebSnHwi89AK1P+</HostId> </Error>
13
- EOBucketNoexists
14
-
15
- @bucket_exists = <<-EOBucketexists
16
- <?xml version="1.0" encoding="UTF-8"?>\n<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Name>data.synergypeople.net</Name> <Prefix></Prefix> <Marker></Marker> <MaxKeys>1000</MaxKeys> <IsTruncated>false</IsTruncated> </ListBucketResult>
17
- EOBucketexists
18
-
19
- @service_empty_buckets_list = S3::Service.new(
20
- :access_key_id => "12345678901234567890",
21
- :secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
22
- )
23
- @response_empty_buckets_list = Net::HTTPOK.new("1.1", "200", "OK")
24
- @service_empty_buckets_list.stubs(:service_request).returns(@response_empty_buckets_list)
25
- @response_empty_buckets_list.stubs(:body).returns(@buckets_empty_list_body)
26
-
27
- @service_buckets_list = S3::Service.new(
28
- :access_key_id => "12345678901234567890",
29
- :secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
30
- )
31
- @response_buckets_list = Net::HTTPOK.new("1.1", "200", "OK")
32
- @service_buckets_list.stubs(:service_request).returns(@response_buckets_list)
33
- @response_buckets_list.stubs(:body).returns(@buckets_list_body)
34
-
35
- @service_bucket_exists = S3::Service.new(
36
- :access_key_id => "12345678901234567890",
37
- :secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
38
- )
39
- @response_bucket_exists = Net::HTTPNotFound.new("1.1", "200", "OK")
40
- @service_bucket_exists.stubs(:service_request).returns(@response_bucket_exists)
41
- @response_bucket_exists.stubs(:body).returns(@bucket_exists)
42
-
43
- @service_bucket_not_exists = S3::Service.new(
44
- :access_key_id => "12345678901234567890",
45
- :secret_access_key => "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDF"
46
- )
47
- @response_bucket_not_exists = Net::HTTPNotFound.new("1.1", "404", "Not Found")
48
- @service_bucket_not_exists.stubs(:service_request).raises(S3::Error::NoSuchBucket.new(404, @response_bucket_not_exists))
49
- @response_bucket_not_exists.stubs(:body).returns(@bucket_not_exists)
50
-
51
- @buckets_empty_list = []
52
- @buckets_empty_list_body = <<-EOEmptyBuckets
53
- <?xml version="1.0" encoding="UTF-8"?>\n<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Owner> <ID>123u1odhkhfoadf</ID> <DisplayName>JohnDoe</DisplayName> </Owner> <Buckets> </Buckets> </ListAllMyBucketsResult>
54
- EOEmptyBuckets
55
-
56
- @buckets_list = [
57
- S3::Bucket.send(:new, @service_buckets_list, "data.example.com"),
58
- S3::Bucket.send(:new, @service_buckets_list, "images")
59
- ]
60
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: massive_sitemap-writer-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.rc3
4
+ version: 0.0.1.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-16 00:00:00.000000000Z
12
+ date: 2012-03-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: s3
16
- requirement: &70254065150480 !ruby/object:Gem::Requirement
16
+ requirement: &70202609466920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70254065150480
24
+ version_requirements: *70202609466920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: massive_sitemap
27
- requirement: &70254065150020 !ruby/object:Gem::Requirement
27
+ requirement: &70202609466460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70254065150020
35
+ version_requirements: *70202609466460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: retryable
38
- requirement: &70254065149560 !ruby/object:Gem::Requirement
38
+ requirement: &70202604080760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70254065149560
46
+ version_requirements: *70202604080760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70254068290660 !ruby/object:Gem::Requirement
49
+ requirement: &70202604080240 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70254068290660
57
+ version_requirements: *70202604080240
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70254068290200 !ruby/object:Gem::Requirement
60
+ requirement: &70202604079780 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70254068290200
68
+ version_requirements: *70202604079780
69
69
  description: Amazon S3 Writer extension for MassiveSitemap
70
70
  email:
71
71
  - tobi@soundcloud.com