jekyll-s3 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/README.md +56 -7
- data/changelog.md +5 -0
- data/features/jekyll-s3-website-performance.feature +62 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/_jekyll_s3.yml +5 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_jekyll_s3.yml +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/_jekyll_s3.yml +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.maxage.com/_jekyll_s3.yml +4 -0
- data/features/support/test_site_dirs/site.with.maxage.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.maxage.com/_site/index.html +5 -0
- data/jekyll-s3.gemspec +1 -1
- data/lib/jekyll-s3.rb +2 -1
- data/lib/jekyll-s3/upload.rb +89 -0
- data/lib/jekyll-s3/uploader.rb +5 -9
- data/spec/lib/upload_spec.rb +143 -81
- data/spec/lib/uploader_spec.rb +22 -0
- metadata +31 -2
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -33,6 +33,56 @@ s3_bucket: your.blog.bucket.com
|
|
33
33
|
|
34
34
|
## Additional features
|
35
35
|
|
36
|
+
### Cache Control
|
37
|
+
|
38
|
+
You can use the `max_age` configuration option to enable more effective browser
|
39
|
+
caching of your static assets. There are two possible ways to use the option:
|
40
|
+
you can specify a single age (in seconds) like so:
|
41
|
+
|
42
|
+
```yaml
|
43
|
+
max_age: 300
|
44
|
+
```
|
45
|
+
|
46
|
+
Or you can specify a hash of globs, and all files matching those globs will have
|
47
|
+
the specified age:
|
48
|
+
|
49
|
+
```yaml
|
50
|
+
max_age:
|
51
|
+
"assets/*": 6000
|
52
|
+
"*": 300
|
53
|
+
```
|
54
|
+
|
55
|
+
Place the configuration into the file `_jekyll_s3.yml`.
|
56
|
+
|
57
|
+
### Gzip Compression
|
58
|
+
|
59
|
+
If you choose, you can use compress certain file types before uploading them to
|
60
|
+
S3. This is a recommended practice for maximizing page speed and minimizing
|
61
|
+
bandwidth usage.
|
62
|
+
|
63
|
+
To enable Gzip compression, simply add a `gzip` option to your `_jekyll_s3.yml`
|
64
|
+
configuration file:
|
65
|
+
|
66
|
+
```yaml
|
67
|
+
gzip: true
|
68
|
+
```
|
69
|
+
|
70
|
+
Note that you can additionally specify the file extensions you want to Gzip
|
71
|
+
(`.html`, `.css`, `.js`, and `.txt` will be compressed when `gzip: true`):
|
72
|
+
|
73
|
+
```yaml
|
74
|
+
gzip:
|
75
|
+
- .html
|
76
|
+
- .css
|
77
|
+
- .md
|
78
|
+
```
|
79
|
+
|
80
|
+
Remember that the extensions here are referring to the *compiled* extensions,
|
81
|
+
not the pre-processed extensions.
|
82
|
+
|
83
|
+
The gzip'ed files are always re-uploaded (see the issue
|
84
|
+
[#29](https://github.com/laurilehmijoki/jekyll-s3/issues/29) for more info).
|
85
|
+
|
36
86
|
### Using non-standard AWS regions
|
37
87
|
|
38
88
|
By default, `jekyll-s3` uses the US Standard Region. You can upload your Jekyll
|
@@ -42,7 +92,9 @@ site to other regions by adding the setting `s3_endpoint` into the
|
|
42
92
|
For example, the following line in `_jekyll_s3.yml` will instruct `jekyll_s3` to
|
43
93
|
push your site into the Tokyo region:
|
44
94
|
|
45
|
-
|
95
|
+
```yaml
|
96
|
+
s3_endpoint: ap-northeast-1
|
97
|
+
```
|
46
98
|
|
47
99
|
The valid `s3_endpoint` values consist of the [S3 location constraint
|
48
100
|
values](http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region).
|
@@ -78,12 +130,7 @@ Enable the headless mode by adding the `--headless` or `-h` argument after
|
|
78
130
|
|
79
131
|
## Known issues
|
80
132
|
|
81
|
-
|
82
|
-
|
83
|
-
Jekyll-s3 supports only S3 buckets that are in the US Standard region. If your
|
84
|
-
bucket is currently on some other region, you can set a non-existing bucket in
|
85
|
-
`_jekyll_s3.yml` and then run `configure-s3-website --config-file
|
86
|
-
_jekyll_s3.yml`. This creates you a bucket in the US Standard region.
|
133
|
+
None. Please send a pull request if you spot any.
|
87
134
|
|
88
135
|
## Development
|
89
136
|
|
@@ -126,4 +173,6 @@ Contributors (in alphabetical order)
|
|
126
173
|
* Chris Moos
|
127
174
|
* Lauri Lehmijoki
|
128
175
|
* Mason Turner
|
176
|
+
* Michael Bleigh
|
177
|
+
* Shigeaki Matsumura
|
129
178
|
* stanislas
|
data/changelog.md
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: improve response times of your Jekyll website
|
2
|
+
|
3
|
+
As a blogger
|
4
|
+
I want to benefit from HTTP performance optimisations
|
5
|
+
So that my readers would not have to wait long for my website to load
|
6
|
+
|
7
|
+
@new-files
|
8
|
+
Scenario: Set Cache-Control: max-age for all uploaded files
|
9
|
+
When my Jekyll site is in "features/support/test_site_dirs/site.with.maxage.com"
|
10
|
+
Then jekyll-s3 will push my blog to S3
|
11
|
+
And the output should equal
|
12
|
+
"""
|
13
|
+
Deploying _site/* to jekyll-s3-test.net
|
14
|
+
Uploading 2 new file(s)
|
15
|
+
Upload css/styles.css [max-age=120]: Success!
|
16
|
+
Upload index.html [max-age=120]: Success!
|
17
|
+
Done! Go visit: http://jekyll-s3-test.net.s3-website-us-east-1.amazonaws.com/index.html
|
18
|
+
|
19
|
+
"""
|
20
|
+
|
21
|
+
@new-files
|
22
|
+
Scenario: Set Cache-Control: max-age for CSS files only
|
23
|
+
When my Jekyll site is in "features/support/test_site_dirs/site.with.css-maxage.com"
|
24
|
+
Then jekyll-s3 will push my blog to S3
|
25
|
+
And the output should equal
|
26
|
+
"""
|
27
|
+
Deploying _site/* to jekyll-s3-test.net
|
28
|
+
Uploading 2 new file(s)
|
29
|
+
Upload css/styles.css [max-age=100]: Success!
|
30
|
+
Upload index.html [max-age=0]: Success!
|
31
|
+
Done! Go visit: http://jekyll-s3-test.net.s3-website-us-east-1.amazonaws.com/index.html
|
32
|
+
|
33
|
+
"""
|
34
|
+
|
35
|
+
@new-files
|
36
|
+
Scenario: Set Content-Encoding: gzip HTTP header
|
37
|
+
When my Jekyll site is in "features/support/test_site_dirs/site.with.gzipped-html.com"
|
38
|
+
Then jekyll-s3 will push my blog to S3
|
39
|
+
And the output should equal
|
40
|
+
"""
|
41
|
+
Deploying _site/* to jekyll-s3-test.net
|
42
|
+
Uploading 2 new file(s)
|
43
|
+
Upload css/styles.css: Success!
|
44
|
+
Upload index.html [gzipped]: Success!
|
45
|
+
Done! Go visit: http://jekyll-s3-test.net.s3-website-us-east-1.amazonaws.com/index.html
|
46
|
+
|
47
|
+
"""
|
48
|
+
|
49
|
+
@new-files
|
50
|
+
@wip
|
51
|
+
Scenario: Set both the Content-Encoding: gzip and Cache-Control: max-age headers
|
52
|
+
When my Jekyll site is in "features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com"
|
53
|
+
Then jekyll-s3 will push my blog to S3
|
54
|
+
And the output should equal
|
55
|
+
"""
|
56
|
+
Deploying _site/* to jekyll-s3-test.net
|
57
|
+
Uploading 2 new file(s)
|
58
|
+
Upload css/styles.css [gzipped] [max-age=300]: Success!
|
59
|
+
Upload index.html [gzipped] [max-age=300]: Success!
|
60
|
+
Done! Go visit: http://jekyll-s3-test.net.s3-website-us-east-1.amazonaws.com/index.html
|
61
|
+
|
62
|
+
"""
|
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.4.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"]
|
data/lib/jekyll-s3.rb
CHANGED
@@ -8,10 +8,11 @@ require 'mime/types'
|
|
8
8
|
|
9
9
|
module Jekyll
|
10
10
|
module S3
|
11
|
+
DEFAULT_GZIP_EXTENSIONS = %w(.html .css .js .svg .txt)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
%w{errors uploader cli config_loader retry keyboard diff_helper endpoint}.each do |file|
|
15
|
+
%w{errors upload uploader cli config_loader retry keyboard diff_helper endpoint}.each do |file|
|
15
16
|
require File.dirname(__FILE__) + "/jekyll-s3/#{file}"
|
16
17
|
end
|
17
18
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'zlib'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module S3
|
6
|
+
class Upload
|
7
|
+
attr_reader :config, :file, :path, :full_path, :s3
|
8
|
+
|
9
|
+
def initialize(path, s3, config, site_dir)
|
10
|
+
@path = path
|
11
|
+
@full_path = "#{site_dir}/#{path}"
|
12
|
+
@file = File.open("#{site_dir}/#{path}")
|
13
|
+
@s3 = s3
|
14
|
+
@config = config
|
15
|
+
end
|
16
|
+
|
17
|
+
def perform!
|
18
|
+
success = s3.buckets[config['s3_bucket']].objects[path].write(upload_file, upload_options)
|
19
|
+
upload_file.close
|
20
|
+
success
|
21
|
+
end
|
22
|
+
|
23
|
+
def upload_file
|
24
|
+
@upload_file ||= gzip? ? gzipped_file : file
|
25
|
+
end
|
26
|
+
|
27
|
+
def gzip?
|
28
|
+
return false unless !!config['gzip']
|
29
|
+
|
30
|
+
extensions = config['gzip'].is_a?(Array) ? config['gzip'] : Jekyll::S3::DEFAULT_GZIP_EXTENSIONS
|
31
|
+
extensions.include?(File.extname(path))
|
32
|
+
end
|
33
|
+
|
34
|
+
def gzipped_file
|
35
|
+
tempfile = Tempfile.new(File.basename(path))
|
36
|
+
|
37
|
+
gz = Zlib::GzipWriter.new(tempfile, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_STRATEGY)
|
38
|
+
|
39
|
+
gz.mtime = File.mtime(full_path)
|
40
|
+
gz.orig_name = File.basename(path)
|
41
|
+
gz.write(file.read)
|
42
|
+
|
43
|
+
gz.flush
|
44
|
+
tempfile.flush
|
45
|
+
|
46
|
+
gz.close
|
47
|
+
tempfile.open
|
48
|
+
|
49
|
+
tempfile
|
50
|
+
end
|
51
|
+
|
52
|
+
def details
|
53
|
+
"#{path}#{" [gzipped]" if gzip?}#{" [max-age=#{max_age}]" if cache_control?}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def upload_options
|
57
|
+
opts = {
|
58
|
+
:content_type => mime_type,
|
59
|
+
:reduced_redundancy => config['s3_reduced_redundancy']
|
60
|
+
}
|
61
|
+
|
62
|
+
opts[:content_encoding] = "gzip" if gzip?
|
63
|
+
opts[:cache_control] = "max-age=#{max_age}" if cache_control?
|
64
|
+
|
65
|
+
opts
|
66
|
+
end
|
67
|
+
|
68
|
+
def cache_control?
|
69
|
+
!!config['max_age']
|
70
|
+
end
|
71
|
+
|
72
|
+
def max_age
|
73
|
+
if config['max_age'].is_a?(Hash)
|
74
|
+
config['max_age'].each_pair do |glob, age|
|
75
|
+
return age if File.fnmatch(glob, path)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
return config['max_age']
|
79
|
+
end
|
80
|
+
|
81
|
+
return 0
|
82
|
+
end
|
83
|
+
|
84
|
+
def mime_type
|
85
|
+
MIME::Types.type_for(path).first
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/jekyll-s3/uploader.rb
CHANGED
@@ -53,16 +53,12 @@ module Jekyll
|
|
53
53
|
|
54
54
|
def self.upload_file(file, s3, config, site_dir)
|
55
55
|
Retry.run_with_retry do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
:reduced_redundancy => config['s3_reduced_redundancy']
|
61
|
-
)
|
62
|
-
if upload_succeeded
|
63
|
-
puts("Upload #{file}: Success!")
|
56
|
+
upload = Upload.new(file, s3, config, site_dir)
|
57
|
+
|
58
|
+
if upload.perform!
|
59
|
+
puts "Upload #{upload.details}: Success!"
|
64
60
|
else
|
65
|
-
puts
|
61
|
+
puts "Upload #{upload.details}: FAILURE!"
|
66
62
|
end
|
67
63
|
end
|
68
64
|
end
|
data/spec/lib/upload_spec.rb
CHANGED
@@ -1,104 +1,166 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Jekyll::S3::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
3
|
+
describe Jekyll::S3::Upload do
|
4
|
+
describe 'reduced redundancy setting' do
|
5
|
+
let(:config) {
|
6
|
+
{ 's3_reduced_redundancy' => true }
|
7
|
+
}
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
Jekyll::S3::Uploader.send(:upload_file,
|
20
|
-
file_to_upload,
|
21
|
-
s3_client,
|
22
|
-
config,
|
23
|
-
'features/support/test_site_dirs/my.blog.com/_site')
|
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
|
+
)
|
24
17
|
end
|
18
|
+
Jekyll::S3::Upload.new(file_to_upload,
|
19
|
+
s3_client,
|
20
|
+
config,
|
21
|
+
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
25
22
|
end
|
23
|
+
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
describe 'content type resolving' do
|
26
|
+
let(:config) {
|
27
|
+
{ 's3_reduced_redundancy' => false }
|
28
|
+
}
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
Jekyll::S3::Uploader.send(:upload_file,
|
42
|
-
file_to_upload,
|
43
|
-
s3_client,
|
44
|
-
config,
|
45
|
-
'features/support/test_site_dirs/my.blog.com/_site')
|
30
|
+
it 'adds the content type of the uploaded CSS file into the S3 object' do
|
31
|
+
file_to_upload = 'css/styles.css'
|
32
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
33
|
+
s3_object.should_receive(:write).with(
|
34
|
+
anything(),
|
35
|
+
:content_type => 'text/css',
|
36
|
+
:reduced_redundancy => false
|
37
|
+
)
|
46
38
|
end
|
39
|
+
Jekyll::S3::Upload.new(file_to_upload,
|
40
|
+
s3_client,
|
41
|
+
config,
|
42
|
+
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
Jekyll::S3::Uploader.send(:upload_file,
|
58
|
-
file_to_upload,
|
59
|
-
s3_client,
|
60
|
-
config,
|
61
|
-
'features/support/test_site_dirs/my.blog.com/_site')
|
45
|
+
it 'adds the content type of the uploaded HTML file into the S3 object' do
|
46
|
+
file_to_upload = 'index.html'
|
47
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
48
|
+
s3_object.should_receive(:write).with(
|
49
|
+
anything(),
|
50
|
+
:content_type => 'text/html',
|
51
|
+
:reduced_redundancy => false
|
52
|
+
)
|
62
53
|
end
|
54
|
+
Jekyll::S3::Upload.new(file_to_upload,
|
55
|
+
s3_client,
|
56
|
+
config,
|
57
|
+
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
63
58
|
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'gzip compression' do
|
62
|
+
let(:config){
|
63
|
+
{
|
64
|
+
's3_reduced_redundancy' => false,
|
65
|
+
'gzip' => true
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
subject{ Jekyll::S3::Upload.new("index.html", mock(), config, 'features/support/test_site_dirs/my.blog.com/_site') }
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
yield s3_object
|
70
|
-
s3_object
|
71
|
-
end
|
72
|
-
objects = {}
|
73
|
-
objects[file_to_upload] = create_html_s3_object(file_to_upload, &block)
|
74
|
-
objects
|
71
|
+
describe '#gzip?' do
|
72
|
+
it 'should be false if the config does not specify gzip' do
|
73
|
+
config.delete 'gzip'
|
74
|
+
subject.should_not be_gzip
|
75
75
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
|
77
|
+
it 'should be false if gzip is true but does not match a default extension' do
|
78
|
+
subject.stub(:path).and_return("index.bork")
|
79
|
+
subject.should_not be_gzip
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should be true if gzip is true and file extension matches' do
|
83
|
+
subject.should be_gzip
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should be true if gzip is true and file extension matches custom supplied' do
|
87
|
+
config['gzip'] = %w(.bork)
|
88
|
+
subject.stub(:path).and_return('index.bork')
|
89
|
+
subject.should be_gzip
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#gzipped_file' do
|
94
|
+
it 'should return a gzipped version of the file' do
|
95
|
+
gz = Zlib::GzipReader.new(subject.gzipped_file)
|
96
|
+
gz.read.should == File.read('features/support/test_site_dirs/my.blog.com/_site/index.html')
|
80
97
|
end
|
81
|
-
buckets = stub('buckets')
|
82
|
-
buckets.stub(:[] => create_bucket(file_to_upload, &block))
|
83
|
-
s3 = stub('s3')
|
84
|
-
s3.stub(:buckets => buckets)
|
85
|
-
s3
|
86
98
|
end
|
87
99
|
end
|
88
100
|
|
89
|
-
|
90
|
-
let(:
|
91
|
-
|
92
|
-
|
101
|
+
describe 'cache control' do
|
102
|
+
let(:config){
|
103
|
+
{
|
104
|
+
's3_reduced_redundancy' => false,
|
105
|
+
'max_age' => 300
|
106
|
+
}
|
93
107
|
}
|
94
108
|
|
95
|
-
|
96
|
-
|
97
|
-
|
109
|
+
subject{ Jekyll::S3::Upload.new("index.html", mock(), config, 'features/support/test_site_dirs/my.blog.com/_site') }
|
110
|
+
|
111
|
+
describe '#cache_control?' do
|
112
|
+
it 'should be false if max_age is missing' do
|
113
|
+
config.delete 'max_age'
|
114
|
+
subject.should_not be_cache_control
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should be true if max_age is present' do
|
118
|
+
subject.should be_cache_control
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should be true if max_age is a hash' do
|
122
|
+
config['max_age'] = {'*' => 300}
|
123
|
+
subject.should be_cache_control
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#max_age' do
|
128
|
+
it 'should be the universal value if one is set' do
|
129
|
+
subject.max_age.should == 300
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should be the file-specific value if one is set' do
|
133
|
+
config['max_age'] = {'*index.html' => 500}
|
134
|
+
subject.max_age.should == 500
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should be zero if no file-specific value hit' do
|
138
|
+
config['max_age'] = {'*.js' => 500}
|
139
|
+
subject.max_age.should == 0
|
140
|
+
end
|
98
141
|
end
|
142
|
+
end
|
99
143
|
|
100
|
-
|
101
|
-
|
144
|
+
def create_verifying_s3_client(file_to_upload, &block)
|
145
|
+
def create_objects(file_to_upload, &block)
|
146
|
+
def create_html_s3_object(file_to_upload, &block)
|
147
|
+
s3_object = stub('s3_object')
|
148
|
+
yield s3_object
|
149
|
+
s3_object
|
150
|
+
end
|
151
|
+
objects = {}
|
152
|
+
objects[file_to_upload] = create_html_s3_object(file_to_upload, &block)
|
153
|
+
objects
|
154
|
+
end
|
155
|
+
def create_bucket(file_to_upload, &block)
|
156
|
+
bucket = stub('bucket')
|
157
|
+
bucket.stub(:objects => create_objects(file_to_upload, &block))
|
158
|
+
bucket
|
102
159
|
end
|
160
|
+
buckets = stub('buckets')
|
161
|
+
buckets.stub(:[] => create_bucket(file_to_upload, &block))
|
162
|
+
s3 = stub('s3')
|
163
|
+
s3.stub(:buckets => buckets)
|
164
|
+
s3
|
103
165
|
end
|
104
|
-
end
|
166
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jekyll::S3::Uploader do
|
4
|
+
context '#upload_file' do
|
5
|
+
end
|
6
|
+
|
7
|
+
context '#load_all_local_files' do
|
8
|
+
let(:files) {
|
9
|
+
Jekyll::S3::Uploader.send(:load_all_local_files,
|
10
|
+
'spec/sample_files/hyde_site/_site')
|
11
|
+
}
|
12
|
+
|
13
|
+
it 'loads regular files' do
|
14
|
+
files.should include('css/styles.css')
|
15
|
+
files.should include('index.html')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'loads also dotfiles' do
|
19
|
+
files.should include('.vimrc')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.4.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: 2013-
|
13
|
+
date: 2013-02-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- features/jekyll-s3-cloudfront.feature
|
254
254
|
- features/jekyll-s3-delete.feature
|
255
255
|
- features/jekyll-s3-upload.feature
|
256
|
+
- features/jekyll-s3-website-performance.feature
|
256
257
|
- features/step_definitions/steps.rb
|
257
258
|
- features/support/env.rb
|
258
259
|
- features/support/test_site_dirs/cdn-powered.blog.fi/_jekyll_s3.yml
|
@@ -276,6 +277,18 @@ files:
|
|
276
277
|
- features/support/test_site_dirs/only-changed-files.com/_jekyll_s3.yml
|
277
278
|
- features/support/test_site_dirs/only-changed-files.com/_site/css/styles.css
|
278
279
|
- features/support/test_site_dirs/only-changed-files.com/_site/index.html
|
280
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_jekyll_s3.yml
|
281
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css
|
282
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html
|
283
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_jekyll_s3.yml
|
284
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/css/styles.css
|
285
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/index.html
|
286
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_jekyll_s3.yml
|
287
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_site/css/styles.css
|
288
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_site/index.html
|
289
|
+
- features/support/test_site_dirs/site.with.maxage.com/_jekyll_s3.yml
|
290
|
+
- features/support/test_site_dirs/site.with.maxage.com/_site/css/styles.css
|
291
|
+
- features/support/test_site_dirs/site.with.maxage.com/_site/index.html
|
279
292
|
- features/support/test_site_dirs/unpublish-a-post.com/_jekyll_s3.yml
|
280
293
|
- features/support/test_site_dirs/unpublish-a-post.com/_site/css/styles.css
|
281
294
|
- features/support/vcr.rb
|
@@ -289,11 +302,13 @@ files:
|
|
289
302
|
- lib/jekyll-s3/errors.rb
|
290
303
|
- lib/jekyll-s3/keyboard.rb
|
291
304
|
- lib/jekyll-s3/retry.rb
|
305
|
+
- lib/jekyll-s3/upload.rb
|
292
306
|
- lib/jekyll-s3/uploader.rb
|
293
307
|
- spec/lib/config_loader_spec.rb
|
294
308
|
- spec/lib/keyboard_spec.rb
|
295
309
|
- spec/lib/retry_spec.rb
|
296
310
|
- spec/lib/upload_spec.rb
|
311
|
+
- spec/lib/uploader_spec.rb
|
297
312
|
- spec/sample_files/hyde_site/_jekyll_s3.yml
|
298
313
|
- spec/sample_files/hyde_site/_site/.vimrc
|
299
314
|
- spec/sample_files/hyde_site/_site/css/styles.css
|
@@ -341,6 +356,7 @@ test_files:
|
|
341
356
|
- features/jekyll-s3-cloudfront.feature
|
342
357
|
- features/jekyll-s3-delete.feature
|
343
358
|
- features/jekyll-s3-upload.feature
|
359
|
+
- features/jekyll-s3-website-performance.feature
|
344
360
|
- features/step_definitions/steps.rb
|
345
361
|
- features/support/env.rb
|
346
362
|
- features/support/test_site_dirs/cdn-powered.blog.fi/_jekyll_s3.yml
|
@@ -364,6 +380,18 @@ test_files:
|
|
364
380
|
- features/support/test_site_dirs/only-changed-files.com/_jekyll_s3.yml
|
365
381
|
- features/support/test_site_dirs/only-changed-files.com/_site/css/styles.css
|
366
382
|
- features/support/test_site_dirs/only-changed-files.com/_site/index.html
|
383
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_jekyll_s3.yml
|
384
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css
|
385
|
+
- features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html
|
386
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_jekyll_s3.yml
|
387
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/css/styles.css
|
388
|
+
- features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/index.html
|
389
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_jekyll_s3.yml
|
390
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_site/css/styles.css
|
391
|
+
- features/support/test_site_dirs/site.with.gzipped-html.com/_site/index.html
|
392
|
+
- features/support/test_site_dirs/site.with.maxage.com/_jekyll_s3.yml
|
393
|
+
- features/support/test_site_dirs/site.with.maxage.com/_site/css/styles.css
|
394
|
+
- features/support/test_site_dirs/site.with.maxage.com/_site/index.html
|
367
395
|
- features/support/test_site_dirs/unpublish-a-post.com/_jekyll_s3.yml
|
368
396
|
- features/support/test_site_dirs/unpublish-a-post.com/_site/css/styles.css
|
369
397
|
- features/support/vcr.rb
|
@@ -371,6 +399,7 @@ test_files:
|
|
371
399
|
- spec/lib/keyboard_spec.rb
|
372
400
|
- spec/lib/retry_spec.rb
|
373
401
|
- spec/lib/upload_spec.rb
|
402
|
+
- spec/lib/uploader_spec.rb
|
374
403
|
- spec/sample_files/hyde_site/_jekyll_s3.yml
|
375
404
|
- spec/sample_files/hyde_site/_site/.vimrc
|
376
405
|
- spec/sample_files/hyde_site/_site/css/styles.css
|