jekyll-s3 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -12
- data/features/cli-output.feature +5 -0
- data/features/support/env.rb +1 -0
- data/jekyll-s3.gemspec +2 -2
- data/lib/jekyll-s3/config_loader.rb +1 -0
- data/lib/jekyll-s3/uploader.rb +16 -16
- data/spec/lib/upload_spec.rb +64 -29
- metadata +4 -4
data/README.md
CHANGED
@@ -18,30 +18,28 @@ Deploy your jekyll site to S3.
|
|
18
18
|
|
19
19
|
## Setup
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
* Go to your jekyll site directory
|
22
|
+
* Run `jekyll-s3`. It generates a configuration file called `_jekyll_s3.yml` that looks like this:
|
23
23
|
<pre>
|
24
24
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
25
25
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
26
26
|
s3_bucket: your.blog.bucket.com
|
27
|
-
cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
28
27
|
</pre>
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
want to store the AWS credentials as environmental variables.
|
29
|
+
* Edit it with your details (you can use [ERB](http://ruby-doc.org/stdlib-1.9.3/libdoc/erb/rdoc/ERB.html) in the file)
|
30
|
+
* [Configure your S3 bucket to function like a website](http://docs.amazonwebservices.com/AmazonS3/latest/dev/HostingWebsiteOnS3Setup.html)
|
33
31
|
|
34
32
|
## Deploy!
|
35
33
|
|
36
34
|
* Run `jekyll-s3`. Done.
|
37
35
|
|
38
|
-
##
|
36
|
+
## Reduced Redundancy
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
*
|
44
|
-
|
38
|
+
You can reduce the cost of hosting your blog on S3 by using Reduced Redundancy Storage:
|
39
|
+
|
40
|
+
* In `_jekyll_s3.yml`, set `s3_reduced_redundancy: true`
|
41
|
+
* All objects uploaded after this change will use the Reduced Redundancy Storage.
|
42
|
+
* If you want to change all of the files in the bucket, you can change them through the AWS console, or update the timestamp on the files before running `jekyll-s3` again
|
45
43
|
|
46
44
|
## How to use Cloudfront to deliver your blog
|
47
45
|
|
@@ -68,6 +66,10 @@ Enable the headless mode by adding the `--headless` or `-h` argument after
|
|
68
66
|
|
69
67
|
## Changelog
|
70
68
|
|
69
|
+
### 2.1.0
|
70
|
+
|
71
|
+
* Added support for S3 reduced redundancy storage
|
72
|
+
|
71
73
|
### 2.0.0
|
72
74
|
|
73
75
|
* Set content type of the uploaded files
|
@@ -120,3 +122,4 @@ Contributors (in alphabetical order)
|
|
120
122
|
* Chris Kelly
|
121
123
|
* Chris Moos
|
122
124
|
* Lauri Lehmijoki
|
125
|
+
* Mason Turner
|
data/features/cli-output.feature
CHANGED
@@ -21,6 +21,7 @@ Feature: Command-line interface feedback
|
|
21
21
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
22
22
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
23
23
|
s3_bucket: your.blog.bucket.com
|
24
|
+
s3_reduced_redundancy: false
|
24
25
|
cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
25
26
|
"""
|
26
27
|
|
@@ -34,6 +35,7 @@ Feature: Command-line interface feedback
|
|
34
35
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
35
36
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
36
37
|
s3_bucket: your.blog.bucket.com
|
38
|
+
s3_reduced_redundancy: false
|
37
39
|
"""
|
38
40
|
|
39
41
|
Scenario: Run jekyll-s3 with a malformed configuration file
|
@@ -50,6 +52,7 @@ Feature: Command-line interface feedback
|
|
50
52
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
51
53
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
52
54
|
s3_bucket: your.blog.bucket.com
|
55
|
+
s3_reduced_redundancy: false
|
53
56
|
"""
|
54
57
|
|
55
58
|
Scenario: Run jekyll-s3 with a configuration file that does not contain a bucket
|
@@ -59,6 +62,7 @@ Feature: Command-line interface feedback
|
|
59
62
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
60
63
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
61
64
|
s3_bucket:
|
65
|
+
s3_reduced_redundancy: false
|
62
66
|
"""
|
63
67
|
When I run `jekyll-s3`
|
64
68
|
Then the output should contain:
|
@@ -67,6 +71,7 @@ Feature: Command-line interface feedback
|
|
67
71
|
s3_id: YOUR_AWS_S3_ACCESS_KEY_ID
|
68
72
|
s3_secret: YOUR_AWS_S3_SECRET_ACCESS_KEY
|
69
73
|
s3_bucket: your.blog.bucket.com
|
74
|
+
s3_reduced_redundancy: false
|
70
75
|
"""
|
71
76
|
|
72
77
|
Scenario: Run jekyll-s3
|
data/features/support/env.rb
CHANGED
@@ -10,6 +10,7 @@ require 'cucumber/rspec/doubles'
|
|
10
10
|
Before do
|
11
11
|
@__aruba_original_paths = (ENV['PATH'] || '').split(File::PATH_SEPARATOR)
|
12
12
|
ENV['PATH'] = ([File.expand_path('bin')] + @__aruba_original_paths).join(File::PATH_SEPARATOR)
|
13
|
+
@aruba_timeout_seconds = 5
|
13
14
|
end
|
14
15
|
|
15
16
|
After do
|
data/jekyll-s3.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "jekyll-s3"
|
6
|
-
s.version = "2.
|
6
|
+
s.version = "2.1.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Philippe Creux", "Lauri Lehmijoki"]
|
9
9
|
s.email = ["pcreux@gmail.com", "lauri.lehmijoki@iki.fi"]
|
@@ -15,7 +15,7 @@ distribution, making it easy to deliver your blog via the CDN.}
|
|
15
15
|
|
16
16
|
s.default_executable = %q{jekyll-s3}
|
17
17
|
|
18
|
-
s.add_dependency 'aws-sdk', '~> 1.
|
18
|
+
s.add_dependency 'aws-sdk', '~> 1.8.0'
|
19
19
|
s.add_dependency 'filey-diff', '~> 0.0.2'
|
20
20
|
s.add_dependency 'simple-cloudfront-invalidator', '~> 1.0.0'
|
21
21
|
s.add_dependency 'erubis', '~> 2.7.0'
|
data/lib/jekyll-s3/uploader.rb
CHANGED
@@ -2,22 +2,21 @@ module Jekyll
|
|
2
2
|
module S3
|
3
3
|
class Uploader
|
4
4
|
def self.run(site_dir, config, in_headless_mode = false)
|
5
|
-
|
6
|
-
s3_secret = config['s3_secret']
|
7
|
-
s3_bucket_name = config['s3_bucket']
|
8
|
-
puts "Deploying _site/* to #{s3_bucket_name}"
|
5
|
+
puts "Deploying _site/* to #{config['s3_bucket']}"
|
9
6
|
|
10
|
-
s3 = AWS::S3.new(:access_key_id => s3_id,
|
11
|
-
:secret_access_key => s3_secret)
|
7
|
+
s3 = AWS::S3.new(:access_key_id => config['s3_id'],
|
8
|
+
:secret_access_key => config['s3_secret'])
|
12
9
|
|
13
|
-
create_bucket_if_needed(s3,
|
10
|
+
create_bucket_if_needed(s3, config['s3_bucket'])
|
14
11
|
|
15
|
-
new_files_count, changed_files_count, changed_files = upload_files(
|
12
|
+
new_files_count, changed_files_count, changed_files = upload_files(
|
13
|
+
s3, config, site_dir
|
14
|
+
)
|
16
15
|
|
17
16
|
deleted_files_count = remove_superfluous_files(
|
18
|
-
s3,
|
17
|
+
s3, config['s3_bucket'], site_dir, in_headless_mode)
|
19
18
|
|
20
|
-
puts "Done! Go visit: http://#{
|
19
|
+
puts "Done! Go visit: http://#{config['s3_bucket']}.s3.amazonaws.com/index.html"
|
21
20
|
[new_files_count, changed_files_count, deleted_files_count, changed_files]
|
22
21
|
end
|
23
22
|
|
@@ -30,9 +29,9 @@ module Jekyll
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
def self.upload_files(s3,
|
32
|
+
def self.upload_files(s3, config, site_dir)
|
34
33
|
changed_files, new_files = DiffHelper.resolve_files_to_upload(
|
35
|
-
s3.buckets[
|
34
|
+
s3.buckets[config['s3_bucket']], site_dir)
|
36
35
|
to_upload = changed_files + new_files
|
37
36
|
if to_upload.empty?
|
38
37
|
puts "No new or changed files to upload"
|
@@ -45,18 +44,19 @@ module Jekyll
|
|
45
44
|
pre_upload_report << "file(s)"
|
46
45
|
puts pre_upload_report.join(' ')
|
47
46
|
to_upload.each do |f|
|
48
|
-
upload_file(f, s3,
|
47
|
+
upload_file(f, s3, config, site_dir)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
[new_files.length, changed_files.length, changed_files]
|
52
51
|
end
|
53
52
|
|
54
|
-
def self.upload_file(file, s3,
|
53
|
+
def self.upload_file(file, s3, config, site_dir)
|
55
54
|
Retry.run_with_retry do
|
56
55
|
mime_type = MIME::Types.type_for(file)
|
57
|
-
upload_succeeded = s3.buckets[
|
56
|
+
upload_succeeded = s3.buckets[config['s3_bucket']].objects[file].write(
|
58
57
|
File.read("#{site_dir}/#{file}"),
|
59
|
-
:content_type => mime_type.first
|
58
|
+
:content_type => mime_type.first ,
|
59
|
+
:reduced_redundancy => config['s3_reduced_redundancy'],
|
60
60
|
)
|
61
61
|
if upload_succeeded
|
62
62
|
puts("Upload #{file}: Success!")
|
data/spec/lib/upload_spec.rb
CHANGED
@@ -1,51 +1,86 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Jekyll::S3::Uploader do
|
4
|
+
describe 'reduced redundancy setting' do
|
5
|
+
let(:config) {
|
6
|
+
{ 's3_reduced_redundancy' => true }
|
7
|
+
}
|
8
|
+
|
9
|
+
it 'allows storing a file under the Reduced Redundancy Storage' do
|
10
|
+
file_to_upload = 'index.html'
|
11
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
12
|
+
s3_object.should_receive(:write).with(
|
13
|
+
anything(),
|
14
|
+
:content_type => 'text/html',
|
15
|
+
:reduced_redundancy => true
|
16
|
+
)
|
17
|
+
end
|
18
|
+
Jekyll::S3::Uploader.send(:upload_file,
|
19
|
+
file_to_upload,
|
20
|
+
s3_client,
|
21
|
+
config,
|
22
|
+
'features/support/test_site_dirs/my.blog.com/_site')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
4
26
|
describe 'content type resolving' do
|
27
|
+
let(:config) {
|
28
|
+
{ 's3_reduced_redundancy' => false }
|
29
|
+
}
|
30
|
+
|
5
31
|
it 'adds the content type of the uploaded CSS file into the S3 object' do
|
6
32
|
file_to_upload = 'css/styles.css'
|
33
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
34
|
+
s3_object.should_receive(:write).with(
|
35
|
+
anything(),
|
36
|
+
:content_type => 'text/css',
|
37
|
+
:reduced_redundancy => false
|
38
|
+
)
|
39
|
+
end
|
7
40
|
Jekyll::S3::Uploader.send(:upload_file,
|
8
41
|
file_to_upload,
|
9
|
-
|
10
|
-
|
42
|
+
s3_client,
|
43
|
+
config,
|
11
44
|
'features/support/test_site_dirs/my.blog.com/_site')
|
12
45
|
end
|
13
46
|
|
14
47
|
it 'adds the content type of the uploaded HTML file into the S3 object' do
|
15
48
|
file_to_upload = 'index.html'
|
49
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
50
|
+
s3_object.should_receive(:write).with(
|
51
|
+
anything(),
|
52
|
+
:content_type => 'text/html',
|
53
|
+
:reduced_redundancy => false
|
54
|
+
)
|
55
|
+
end
|
16
56
|
Jekyll::S3::Uploader.send(:upload_file,
|
17
57
|
file_to_upload,
|
18
|
-
|
19
|
-
|
58
|
+
s3_client,
|
59
|
+
config,
|
20
60
|
'features/support/test_site_dirs/my.blog.com/_site')
|
21
61
|
end
|
62
|
+
end
|
22
63
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
anything(),
|
30
|
-
# Ensure that the write method is called with the correct content type:
|
31
|
-
:content_type => content_type
|
32
|
-
)
|
33
|
-
s3_object
|
34
|
-
end
|
35
|
-
objects = {}
|
36
|
-
objects[file_to_upload] = create_html_s3_object(file_to_upload)
|
37
|
-
objects
|
38
|
-
end
|
39
|
-
def create_bucket(file_to_upload)
|
40
|
-
bucket = stub('bucket')
|
41
|
-
bucket.stub(:objects => create_objects(file_to_upload))
|
42
|
-
bucket
|
64
|
+
def create_verifying_s3_client(file_to_upload, &block)
|
65
|
+
def create_objects(file_to_upload, &block)
|
66
|
+
def create_html_s3_object(file_to_upload, &block)
|
67
|
+
s3_object = stub('s3_object')
|
68
|
+
yield s3_object
|
69
|
+
s3_object
|
43
70
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
71
|
+
objects = {}
|
72
|
+
objects[file_to_upload] = create_html_s3_object(file_to_upload, &block)
|
73
|
+
objects
|
74
|
+
end
|
75
|
+
def create_bucket(file_to_upload, &block)
|
76
|
+
bucket = stub('bucket')
|
77
|
+
bucket.stub(:objects => create_objects(file_to_upload, &block))
|
78
|
+
bucket
|
49
79
|
end
|
80
|
+
buckets = stub('buckets')
|
81
|
+
buckets.stub(:[] => create_bucket(file_to_upload, &block))
|
82
|
+
s3 = stub('s3')
|
83
|
+
s3.stub(:buckets => buckets)
|
84
|
+
s3
|
50
85
|
end
|
51
86
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
22
|
+
version: 1.8.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 1.
|
30
|
+
version: 1.8.0
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: filey-diff
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|