jekyll-s3 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .rvmrc
1
2
  *.gem
2
3
  .bundle
3
4
  Gemfile.lock
data/README.md CHANGED
@@ -22,18 +22,29 @@ s3_bucket: your.blog.bucket.com
22
22
 
23
23
  * Run `jekyll-s3`. Done.
24
24
 
25
- ## Want `http://www.my-awesome-blog.com/` to render `'index.html'`?
26
-
27
- * Setup Cloudfront to distribute your s3 bucket files (you can do that
28
- through the [AWS management console](https://console.aws.amazon.com/s3/home))
29
- * Set the cloudfront root object to index.html (you can use the
30
- [aws-cloudfront gem](https://github.com/iltempo/aws-cloudfront) to do so)
25
+ ## Want the root url to render index.html?
26
+
27
+ * Log into <https://console.aws.amazon.com/s3/home>
28
+ * Set the Index document to index.html in Bucket Properties >
29
+ Website.
30
+ * Visit the website endpoint:
31
+ (http://yourblog.s3-website...amazonaws.com)
31
32
 
32
33
  ## Todo
33
34
 
34
- * Upload new / updated files *only*
35
- * Setup Cloudfront distribution
36
- * Invalidate updated files on Cloudfront
35
+ * Upload new / updated files *only* (using s3-sync?)
36
+
37
+ ## Development
38
+
39
+ * Install bundler and run `bundle install`
40
+ * Run the integration tests by running `bundle exec cucumber`
41
+ * Run the unit tests by running `bundle exec rspec spec/lib/*.rb`
42
+
43
+ ## License
44
+
45
+ MIT
37
46
 
47
+ ## Copyright
38
48
 
49
+ Copyright (c) 2011 VersaPay, Philippe Creux.
39
50
 
@@ -5,7 +5,7 @@ Feature: jekyll-s3
5
5
  I want to run jekyll-s3 and say OMG it just worked!
6
6
 
7
7
  Scenario: Run jekyll-s3 in the wrong directory
8
- When I run "jekyll-s3"
8
+ When I run `jekyll-s3`
9
9
  Then the output should contain:
10
10
  """
11
11
  I can't find any directory called _site. Are you in the right directory?
@@ -13,7 +13,7 @@ Feature: jekyll-s3
13
13
 
14
14
  Scenario: Run jekyll-s3 for the first time
15
15
  Given a directory named "_site"
16
- When I run "jekyll-s3"
16
+ When I run `jekyll-s3`
17
17
  Then the output should contain:
18
18
  """
19
19
  I've just generated a file called _jekyll_s3.yml. Go put your details in it!
@@ -28,7 +28,7 @@ Feature: jekyll-s3
28
28
  Scenario: Run jekyll-s3 with an empty configuration file
29
29
  Given a directory named "_site"
30
30
  And an empty file named "_jekyll_s3.yml"
31
- When I run "jekyll-s3"
31
+ When I run `jekyll-s3`
32
32
  Then the output should contain:
33
33
  """
34
34
  I can't parse the file _jekyll_s3.yml. It should look like this:
@@ -44,7 +44,7 @@ Feature: jekyll-s3
44
44
  s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
45
45
  this is not yaml
46
46
  """
47
- When I run "jekyll-s3"
47
+ When I run `jekyll-s3`
48
48
  Then the output should contain:
49
49
  """
50
50
  I can't parse the file _jekyll_s3.yml. It should look like this:
@@ -61,7 +61,7 @@ Feature: jekyll-s3
61
61
  s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
62
62
  s3_bucket:
63
63
  """
64
- When I run "jekyll-s3"
64
+ When I run `jekyll-s3`
65
65
  Then the output should contain:
66
66
  """
67
67
  I can't parse the file _jekyll_s3.yml. It should look like this:
@@ -78,10 +78,8 @@ Feature: jekyll-s3
78
78
  s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
79
79
  s3_bucket: your.blog.bucket.com
80
80
  """
81
- When I run "jekyll-s3"
81
+ When I run `jekyll-s3`
82
82
  Then the output should contain:
83
83
  """
84
- Uploading _site/* to your.blog.bucket.com
84
+ Deploying _site/* to your.blog.bucket.com
85
85
  """
86
-
87
-
@@ -4,6 +4,7 @@ require 'bundler'
4
4
  Bundler.require
5
5
 
6
6
  require 'aruba/cucumber'
7
+ require 'cucumber/rspec/doubles'
7
8
 
8
9
  # Following from 'aruba/cucumber'
9
10
  Before do
data/jekyll-s3.gemspec CHANGED
@@ -17,8 +17,9 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency 'aws-s3'
18
18
 
19
19
  s.add_development_dependency 'rspec'
20
+ s.add_development_dependency 'mocha'
20
21
  s.add_development_dependency 'cucumber'
21
- s.add_development_dependency 'aruba'
22
+ s.add_development_dependency 'aruba', '>= 0.4.7'
22
23
 
23
24
  s.files = `git ls-files`.split("\n")
24
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -22,8 +22,22 @@ s3_bucket: your.blog.bucket.com
22
22
  end
23
23
 
24
24
  protected
25
-
26
- include AWS::S3
25
+
26
+ def run_with_retry
27
+ begin
28
+ yield
29
+ rescue AWS::S3::RequestTimeout => e
30
+ $stderr.puts "Exception Occurred: #{e.message} (#{e.class}) Retrying in 5 seconds..."
31
+ sleep 5
32
+ retry
33
+ end
34
+ end
35
+
36
+ def local_files
37
+ Dir[SITE_DIR + '/**/*'].
38
+ delete_if { |f| File.directory?(f) }.
39
+ map { |f| f.gsub(SITE_DIR + '/', '') }
40
+ end
27
41
 
28
42
  # Please spec me!
29
43
  def upload_to_s3!
@@ -34,25 +48,23 @@ s3_bucket: your.blog.bucket.com
34
48
  :secret_access_key => @s3_secret,
35
49
  :use_ssl => true
36
50
  )
37
- unless Service.buckets.map(&:name).include?(@s3_bucket)
51
+ unless AWS::S3::Service.buckets.map(&:name).include?(@s3_bucket)
38
52
  puts("Creating bucket #{@s3_bucket}")
39
- Bucket.create(@s3_bucket)
53
+ AWS::S3::Bucket.create(@s3_bucket)
40
54
  end
41
55
 
42
- bucket = Bucket.find(@s3_bucket)
43
-
44
- local_files = Dir[SITE_DIR + '/**/*'].
45
- delete_if { |f| File.directory?(f) }.
46
- map { |f| f.gsub(SITE_DIR + '/', '') }
56
+ bucket = AWS::S3::Bucket.find(@s3_bucket)
47
57
 
48
58
  remote_files = bucket.objects.map { |f| f.key }
49
59
 
50
60
  to_upload = local_files
51
- to_upload.each do |f|
52
- if S3Object.store(f, open("#{SITE_DIR}/#{f}"), @s3_bucket, :access => 'public-read')
53
- puts("Upload #{f}: Success!")
54
- else
55
- puts("Upload #{f}: FAILURE!")
61
+ to_upload.each do |f|
62
+ run_with_retry do
63
+ if AWS::S3::S3Object.store(f, open("#{SITE_DIR}/#{f}"), @s3_bucket, :access => 'public-read')
64
+ puts("Upload #{f}: Success!")
65
+ else
66
+ puts("Upload #{f}: FAILURE!")
67
+ end
56
68
  end
57
69
  end
58
70
 
@@ -73,15 +85,18 @@ s3_bucket: your.blog.bucket.com
73
85
  end
74
86
  end
75
87
  if (delete_all || delete) && !(keep_all || keep)
76
- if S3Object.delete(f, @s3_bucket)
77
- puts("Delete #{f}: Success!")
78
- else
79
- puts("Delete #{f}: FAILURE!")
88
+ run_with_retry do
89
+ if AWS::S3::S3Object.delete(f, @s3_bucket)
90
+ puts("Delete #{f}: Success!")
91
+ else
92
+ puts("Delete #{f}: FAILURE!")
93
+ end
80
94
  end
81
95
  end
82
96
  end
83
97
 
84
98
  puts "Done! Go visit: http://#{@s3_bucket}.s3.amazonaws.com/index.html"
99
+ true
85
100
  end
86
101
 
87
102
  def check_jekyll_project!
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module S3
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,33 @@
1
+ require File.dirname(__FILE__) + "/../../lib/jekyll-s3.rb"
2
+
3
+ RSpec.configure do |config|
4
+ config.mock_framework = :mocha
5
+ end
6
+
7
+ describe Jekyll::S3::Uploader do
8
+ describe "#upload_to_s3" do
9
+
10
+ before :each do
11
+ AWS::S3::Base.expects(:establish_connection!).at_least(1).returns true
12
+ AWS::S3::Service.expects(:buckets).at_least(1).returns []
13
+ AWS::S3::Bucket.expects(:create).at_least(1).returns true
14
+ bucket = mock()
15
+ bucket.expects(:objects).returns []
16
+ AWS::S3::Bucket.expects(:find).at_least(1).returns bucket
17
+
18
+ @uploader = Jekyll::S3::Uploader.new
19
+ @uploader.expects(:local_files).at_least(1).returns ['index.html']
20
+ @uploader.expects(:open).at_least(1).returns true
21
+ end
22
+
23
+ it "should work right when there are no exceptions" do
24
+ AWS::S3::S3Object.expects(:store).at_least(1).returns(true)
25
+ @uploader.send(:upload_to_s3!).should
26
+ end
27
+
28
+ it "should properly handle exceptions on uploading to S3" do
29
+ AWS::S3::S3Object.expects(:store).raises(AWS::S3::RequestTimeout.new('timeout', 'timeout')).then.at_least(1).returns(true)
30
+ @uploader.send(:upload_to_s3!).should
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-s3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philippe Creux
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-07 00:00:00 -07:00
19
- default_executable: jekyll-s3
18
+ date: 2011-11-18 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: aws-s3
@@ -47,7 +46,7 @@ dependencies:
47
46
  type: :development
48
47
  version_requirements: *id002
49
48
  - !ruby/object:Gem::Dependency
50
- name: cucumber
49
+ name: mocha
51
50
  prerelease: false
52
51
  requirement: &id003 !ruby/object:Gem::Requirement
53
52
  none: false
@@ -61,7 +60,7 @@ dependencies:
61
60
  type: :development
62
61
  version_requirements: *id003
63
62
  - !ruby/object:Gem::Dependency
64
- name: aruba
63
+ name: cucumber
65
64
  prerelease: false
66
65
  requirement: &id004 !ruby/object:Gem::Requirement
67
66
  none: false
@@ -74,6 +73,22 @@ dependencies:
74
73
  version: "0"
75
74
  type: :development
76
75
  version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: aruba
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 1
85
+ segments:
86
+ - 0
87
+ - 4
88
+ - 7
89
+ version: 0.4.7
90
+ type: :development
91
+ version_requirements: *id005
77
92
  description: Push your jekyll blog to AWS S3
78
93
  email:
79
94
  - pcreux@gmail.com
@@ -97,7 +112,7 @@ files:
97
112
  - lib/jekyll-s3/errors.rb
98
113
  - lib/jekyll-s3/uploader.rb
99
114
  - lib/jekyll-s3/version.rb
100
- has_rdoc: true
115
+ - spec/lib/uploader_spec.rb
101
116
  homepage: https://github.com/versapay/jekyll-s3
102
117
  licenses: []
103
118
 
@@ -127,10 +142,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
142
  requirements: []
128
143
 
129
144
  rubyforge_project:
130
- rubygems_version: 1.3.7
145
+ rubygems_version: 1.8.11
131
146
  signing_key:
132
147
  specification_version: 3
133
148
  summary: Push your jekyll blog to S3"
134
- test_files:
135
- - features/jekyll-s3.feature
136
- - features/support/env.rb
149
+ test_files: []
150
+