s3_website 1.6.5 → 1.6.6
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.
- checksums.yaml +13 -5
- data/changelog.md +4 -0
- data/features/support/test_site_dirs/site-with-text-doc.com/_site/file.txt +1 -0
- data/lib/s3_website/upload.rb +13 -8
- data/s3_website.gemspec +1 -1
- data/spec/lib/upload_spec.rb +62 -60
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDYyZDQwYWE3MDMzYmQ1ZjBmY2RjNjg5OTMzMjA1YjYwM2NjOGFjNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGRhNmEyZDhiYmQ5ZTIwNGNlYmMyOTFiOTYwOWJjMTJjOWMzZTU1YQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTU4NGIzMDIxYjQxYTMzMzFiNWZmZDQ0MjQxOTY2MmNiNWY3YjExOTRmMzUy
|
10
|
+
MGM2ZjJiZWY4ZjZlMzQzODIxMzgzMTQyMzE3NDU1M2M1MzNhZGNkODdhZjU2
|
11
|
+
ZDQ4OTFhMDI2ZGI5NTcwMDdkM2ExYTI3YmI0NDViZDUwOWE1ZGE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmNiN2Q5OTdiNzQ5NzUxNTU4YTU0ZThjODA4NzAxNTE3MzhhMGM4ZmU3MDRh
|
14
|
+
MWEyMzNkOGY4YjRmNGEwNmI2NjZjZDRmMDZhMDcxOGUxMDQzYzkzOTdjMmI1
|
15
|
+
YmQwMjhhNmY2MzQ3YzgwMGEyMzhlZDY5YzZlMTc1ZTY4ZGU2ZjU=
|
data/changelog.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
hello world
|
data/lib/s3_website/upload.rb
CHANGED
@@ -67,18 +67,23 @@ module S3Website
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def upload_options
|
70
|
-
opts = {
|
71
|
-
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
opts[:content_type] = "text/html; charset=utf-8" if mime_type == 'text/html'
|
70
|
+
opts = {}
|
71
|
+
opts[:reduced_redundancy] = config['s3_reduced_redundancy']
|
72
|
+
opts[:content_type] = resolve_content_type
|
76
73
|
opts[:content_encoding] = "gzip" if gzip?
|
77
74
|
opts[:cache_control] = cache_control_value if cache_control?
|
78
|
-
|
79
75
|
opts
|
80
76
|
end
|
81
77
|
|
78
|
+
def resolve_content_type
|
79
|
+
is_text = mime_type.start_with? 'text/' || mime_type == 'application/json'
|
80
|
+
if is_text
|
81
|
+
"#{mime_type}; charset=utf-8" # Let's consider UTF-8 as the de-facto encoding standard for text
|
82
|
+
else
|
83
|
+
mime_type
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
82
87
|
def cache_control_value
|
83
88
|
if max_age == 0
|
84
89
|
"no-cache, max-age=0"
|
@@ -120,7 +125,7 @@ module S3Website
|
|
120
125
|
if !!config['extensionless_mime_type'] && File.extname(path) == ""
|
121
126
|
config['extensionless_mime_type']
|
122
127
|
else
|
123
|
-
MIME::Types.type_for(path).first
|
128
|
+
MIME::Types.type_for(path).first.to_s
|
124
129
|
end
|
125
130
|
end
|
126
131
|
end
|
data/s3_website.gemspec
CHANGED
data/spec/lib/upload_spec.rb
CHANGED
@@ -50,78 +50,70 @@ describe S3Website::Upload do
|
|
50
50
|
}
|
51
51
|
|
52
52
|
it 'allows storing a file under the Reduced Redundancy Storage' do
|
53
|
-
|
54
|
-
|
53
|
+
should_upload(
|
54
|
+
file = 'index.html',
|
55
|
+
site = 'features/support/test_site_dirs/my.blog.com/_site', config) { |s3_object|
|
55
56
|
s3_object.should_receive(:write).with(
|
56
57
|
anything(),
|
57
|
-
:
|
58
|
-
:reduced_redundancy => true
|
58
|
+
include(:reduced_redundancy => true)
|
59
59
|
)
|
60
|
-
|
61
|
-
S3Website::Upload.new(file_to_upload,
|
62
|
-
s3_client,
|
63
|
-
config,
|
64
|
-
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
60
|
+
}
|
65
61
|
end
|
66
62
|
end
|
67
63
|
|
68
64
|
describe 'content type resolving' do
|
69
|
-
let(:config) {
|
70
|
-
{ 's3_reduced_redundancy' => false }
|
71
|
-
}
|
72
|
-
|
73
65
|
it 'adds the content type of the uploaded CSS file into the S3 object' do
|
74
|
-
|
75
|
-
|
66
|
+
should_upload(
|
67
|
+
file = 'css/styles.css',
|
68
|
+
site = 'features/support/test_site_dirs/my.blog.com/_site') { |s3_object|
|
76
69
|
s3_object.should_receive(:write).with(
|
77
70
|
anything(),
|
78
|
-
:content_type => 'text/css'
|
79
|
-
:reduced_redundancy => false
|
71
|
+
include(:content_type => 'text/css; charset=utf-8')
|
80
72
|
)
|
81
|
-
|
82
|
-
S3Website::Upload.new(file_to_upload,
|
83
|
-
s3_client,
|
84
|
-
config,
|
85
|
-
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
73
|
+
}
|
86
74
|
end
|
87
75
|
|
88
76
|
it 'adds the content type of the uploaded HTML file into the S3 object' do
|
89
|
-
|
90
|
-
|
77
|
+
should_upload(
|
78
|
+
file = 'index.html',
|
79
|
+
site = 'features/support/test_site_dirs/my.blog.com/_site') { |s3_object|
|
91
80
|
s3_object.should_receive(:write).with(
|
92
81
|
anything(),
|
93
|
-
:content_type => 'text/html; charset=utf-8'
|
94
|
-
:reduced_redundancy => false
|
82
|
+
include(:content_type => 'text/html; charset=utf-8')
|
95
83
|
)
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'encoding of text documents' do
|
88
|
+
it 'should mark all text documents as utf-8' do
|
89
|
+
should_upload(
|
90
|
+
file = 'file.txt',
|
91
|
+
site = 'features/support/test_site_dirs/site-with-text-doc.com/_site') { |s3_object|
|
92
|
+
s3_object.should_receive(:write).with(
|
93
|
+
anything(),
|
94
|
+
include(:content_type => 'text/plain; charset=utf-8')
|
95
|
+
)
|
96
|
+
}
|
96
97
|
end
|
97
|
-
S3Website::Upload.new(file_to_upload,
|
98
|
-
s3_client,
|
99
|
-
config,
|
100
|
-
'features/support/test_site_dirs/my.blog.com/_site').perform!
|
101
98
|
end
|
102
99
|
|
103
100
|
context 'the user specifies a mime-type for extensionless files' do
|
104
101
|
let(:config) {{
|
105
|
-
'extensionless_mime_type' => "text/html"
|
106
|
-
's3_reduced_redundancy' => false
|
102
|
+
'extensionless_mime_type' => "text/html"
|
107
103
|
}}
|
108
104
|
|
109
105
|
it 'adds the content type of the uploaded extensionless file into the S3 object' do
|
110
|
-
|
111
|
-
|
106
|
+
should_upload(
|
107
|
+
file = 'index',
|
108
|
+
site = 'features/support/test_site_dirs/my.blog-with-clean-urls.com/_site',
|
109
|
+
config) { |s3_object|
|
112
110
|
s3_object.should_receive(:write).with(
|
113
111
|
anything(),
|
114
|
-
:content_type => 'text/html; charset=utf-8'
|
115
|
-
:reduced_redundancy => false
|
112
|
+
include(:content_type => 'text/html; charset=utf-8')
|
116
113
|
)
|
117
|
-
|
118
|
-
S3Website::Upload.new(file_to_upload,
|
119
|
-
s3_client,
|
120
|
-
config,
|
121
|
-
'features/support/test_site_dirs/my.blog-with-clean-urls.com/_site').perform!
|
114
|
+
}
|
122
115
|
end
|
123
116
|
end
|
124
|
-
|
125
117
|
end
|
126
118
|
|
127
119
|
describe 'gzip compression' do
|
@@ -256,26 +248,36 @@ describe S3Website::Upload do
|
|
256
248
|
end
|
257
249
|
end
|
258
250
|
|
259
|
-
def
|
260
|
-
def
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
|
251
|
+
def should_upload(file_to_upload, site_dir, config = {})
|
252
|
+
def create_verifying_s3_client(file_to_upload, &block)
|
253
|
+
def create_objects(file_to_upload, &block)
|
254
|
+
def create_html_s3_object(file_to_upload, &block)
|
255
|
+
s3_object = stub('s3_object')
|
256
|
+
yield s3_object
|
257
|
+
s3_object
|
258
|
+
end
|
259
|
+
objects = {}
|
260
|
+
objects[file_to_upload] = create_html_s3_object(file_to_upload, &block)
|
261
|
+
objects
|
265
262
|
end
|
266
|
-
|
267
|
-
|
268
|
-
|
263
|
+
def create_bucket(file_to_upload, &block)
|
264
|
+
bucket = stub('bucket')
|
265
|
+
bucket.stub(:objects => create_objects(file_to_upload, &block))
|
266
|
+
bucket
|
267
|
+
end
|
268
|
+
buckets = stub('buckets')
|
269
|
+
buckets.stub(:[] => create_bucket(file_to_upload, &block))
|
270
|
+
s3 = stub('s3')
|
271
|
+
s3.stub(:buckets => buckets)
|
272
|
+
s3
|
269
273
|
end
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
bucket
|
274
|
+
|
275
|
+
s3_client = create_verifying_s3_client(file_to_upload) do |s3_object|
|
276
|
+
yield s3_object
|
274
277
|
end
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
s3
|
278
|
+
S3Website::Upload.new(file_to_upload,
|
279
|
+
s3_client,
|
280
|
+
config,
|
281
|
+
site_dir).perform!
|
280
282
|
end
|
281
283
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lauri Lehmijoki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -112,42 +112,42 @@ dependencies:
|
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - '>='
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - '>='
|
122
|
+
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec-expectations
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - '>='
|
129
|
+
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - '>='
|
136
|
+
- - ! '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: cucumber
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - '>='
|
143
|
+
- - ! '>='
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - '>='
|
150
|
+
- - ! '>='
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
@@ -168,14 +168,14 @@ dependencies:
|
|
168
168
|
name: rake
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - '>='
|
171
|
+
- - ! '>='
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - '>='
|
178
|
+
- - ! '>='
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
@@ -206,7 +206,7 @@ dependencies:
|
|
206
206
|
- - ~>
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 1.8.0
|
209
|
-
description: "\n Sync website files, set redirects, use HTTP performance optimisations,
|
209
|
+
description: ! "\n Sync website files, set redirects, use HTTP performance optimisations,
|
210
210
|
deliver via\n CloudFront.\n "
|
211
211
|
email:
|
212
212
|
- lauri.lehmijoki@iki.fi
|
@@ -292,6 +292,7 @@ files:
|
|
292
292
|
- features/support/test_site_dirs/only-changed-files.com/s3_website.yml
|
293
293
|
- features/support/test_site_dirs/site-that-contains-s3-website-file.com/_site/s3_website.yml
|
294
294
|
- features/support/test_site_dirs/site-that-contains-s3-website-file.com/s3_website.yml
|
295
|
+
- features/support/test_site_dirs/site-with-text-doc.com/_site/file.txt
|
295
296
|
- features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css
|
296
297
|
- features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html
|
297
298
|
- features/support/test_site_dirs/site.with.css-maxage.com/s3_website.yml
|
@@ -354,17 +355,17 @@ require_paths:
|
|
354
355
|
- lib
|
355
356
|
required_ruby_version: !ruby/object:Gem::Requirement
|
356
357
|
requirements:
|
357
|
-
- - '>='
|
358
|
+
- - ! '>='
|
358
359
|
- !ruby/object:Gem::Version
|
359
360
|
version: '0'
|
360
361
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
361
362
|
requirements:
|
362
|
-
- - '>='
|
363
|
+
- - ! '>='
|
363
364
|
- !ruby/object:Gem::Version
|
364
365
|
version: '0'
|
365
366
|
requirements: []
|
366
367
|
rubyforge_project:
|
367
|
-
rubygems_version: 2.
|
368
|
+
rubygems_version: 2.1.9
|
368
369
|
signing_key:
|
369
370
|
specification_version: 4
|
370
371
|
summary: Manage your S3 website
|
@@ -436,6 +437,7 @@ test_files:
|
|
436
437
|
- features/support/test_site_dirs/only-changed-files.com/s3_website.yml
|
437
438
|
- features/support/test_site_dirs/site-that-contains-s3-website-file.com/_site/s3_website.yml
|
438
439
|
- features/support/test_site_dirs/site-that-contains-s3-website-file.com/s3_website.yml
|
440
|
+
- features/support/test_site_dirs/site-with-text-doc.com/_site/file.txt
|
439
441
|
- features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css
|
440
442
|
- features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html
|
441
443
|
- features/support/test_site_dirs/site.with.css-maxage.com/s3_website.yml
|