dpl 1.8.17.travis.1460.4 → 1.8.17.travis.1464.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -0
- data/lib/dpl/provider.rb +12 -0
- data/lib/dpl/provider/s3.rb +16 -8
- data/spec/provider_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGRhOWVkOGU4NTIyNGI3MTNjMTcxNWFiOWY1OTZmMzcwZGZlNTFjMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjdjMTZmNDk4YmQ5MDkxMTMwOGM5N2JlYjRmNjVhNDJlZDg5ZDc3NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Njk3MzVjMzc2OTgzOGFjNGQ5ZTZlNmVjNGVmMjM2Zjk1OWMyMTQzM2YxNGU0
|
10
|
+
Yzk0YThhOTNjMWUzNzhkNjA0Mzg5NzBhMmE4NDU1ZGM2MjJhZWM5ZGIyNGY1
|
11
|
+
ZTUxMTNhOGJmYmJhYmJiNjI5MmQ1ZmU2YmYzNjgzOGZjM2RkNTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTllYjczNTY0OWE2Mjc2YWFjYWE0YzE2NzI3NmNlN2QwZWZiYTBhMmNmOTRi
|
14
|
+
MGI5NGU0MjJlNGNhZjRlNzk2MDVmNTJkN2IzNTNmMmJkMGMzM2Q5YTg5NTYz
|
15
|
+
YWZkZjVjMjg5ZTFmYTAwNGUyNmI0Mzg4Y2QwN2IyYWMzODkxMDM=
|
data/README.md
CHANGED
@@ -321,6 +321,7 @@ For authentication you can also use Travis CI secure environment variable:
|
|
321
321
|
* **acl**: Sets the access control for the uploaded objects. Defaults to `private`. Valid options are `private`, `public_read`, `public_read_write`, `authenticated_read`, `bucket_owner_read`, `bucket_owner_full_control`.
|
322
322
|
* **dot_match**: When set to `true`, upload files starting a `.`.
|
323
323
|
* **index_document_suffix**: Set the index document of a S3 website.
|
324
|
+
* **default_text_charset**: Set the default character set to append to the content-type of text files you are uploading.
|
324
325
|
|
325
326
|
#### File-specific `Cache-Control` and `Expires` headers
|
326
327
|
|
data/lib/dpl/provider.rb
CHANGED
@@ -212,6 +212,14 @@ module DPL
|
|
212
212
|
options[:detect_encoding]
|
213
213
|
end
|
214
214
|
|
215
|
+
def default_text_charset?
|
216
|
+
options[:default_text_charset]
|
217
|
+
end
|
218
|
+
|
219
|
+
def default_text_charset
|
220
|
+
options[:default_text_charset].downcase
|
221
|
+
end
|
222
|
+
|
215
223
|
def encoding_for(path)
|
216
224
|
file_cmd_output = `file '#{path}'`
|
217
225
|
case file_cmd_output
|
@@ -219,6 +227,10 @@ module DPL
|
|
219
227
|
'gzip'
|
220
228
|
when /compress'd/
|
221
229
|
'compress'
|
230
|
+
when /text/
|
231
|
+
'text'
|
232
|
+
when /data/
|
233
|
+
# Shrugs?
|
222
234
|
end
|
223
235
|
end
|
224
236
|
|
data/lib/dpl/provider/s3.rb
CHANGED
@@ -46,13 +46,12 @@ module DPL
|
|
46
46
|
glob_args << File::FNM_DOTMATCH if options[:dot_match]
|
47
47
|
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
|
48
48
|
Dir.glob(*glob_args) do |filename|
|
49
|
-
|
50
|
-
opts = { :content_type => content_type }.merge(encoding_option_for(filename))
|
49
|
+
opts = content_data_for(filename)
|
51
50
|
opts[:cache_control] = get_option_value_by_filename(options[:cache_control], filename) if options[:cache_control]
|
52
51
|
opts[:acl] = options[:acl].gsub(/_/, '-') if options[:acl]
|
53
52
|
opts[:expires] = get_option_value_by_filename(options[:expires], filename) if options[:expires]
|
54
53
|
unless File.directory?(filename)
|
55
|
-
log "uploading
|
54
|
+
log "uploading #{filename.inspect} with #{opts.inspect}"
|
56
55
|
api.bucket(option(:bucket)).object(upload_path(filename)).upload_file(filename, opts)
|
57
56
|
end
|
58
57
|
end
|
@@ -80,12 +79,21 @@ module DPL
|
|
80
79
|
end
|
81
80
|
|
82
81
|
private
|
83
|
-
def
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
def content_data_for(path)
|
83
|
+
content_data = {}
|
84
|
+
content_type = MIME::Types.type_for(path).first
|
85
|
+
content_data[:content_type] = content_type.to_s
|
86
|
+
|
87
|
+
encoding = encoding_for(path)
|
88
|
+
if detect_encoding?
|
89
|
+
content_data[:content_encoding] = encoding if encoding
|
90
|
+
end
|
91
|
+
|
92
|
+
if encoding == 'text' && default_text_charset?
|
93
|
+
content_data[:content_type] = "#{content_data[:content_type]}; charset=#{default_text_charset}"
|
88
94
|
end
|
95
|
+
|
96
|
+
return content_data
|
89
97
|
end
|
90
98
|
|
91
99
|
def get_option_value_by_filename(option_values, filename)
|
data/spec/provider_spec.rb
CHANGED
@@ -159,6 +159,19 @@ describe DPL::Provider do
|
|
159
159
|
expect(provider).to receive(:`).at_least(1).times.with("file '#{path}'").and_return("#{path}: empty")
|
160
160
|
expect(provider.encoding_for(path)).to be_nil
|
161
161
|
end
|
162
|
+
|
163
|
+
example do
|
164
|
+
path = 'foo.js'
|
165
|
+
expect(provider).to receive(:`).at_least(1).times.with("file '#{path}'").and_return("#{path}: ASCII text, with very long line")
|
166
|
+
expect(provider.encoding_for(path)).to eq('text')
|
167
|
+
end
|
168
|
+
|
169
|
+
example do
|
170
|
+
path = 'foo.js'
|
171
|
+
provider.options.update(:default_text_charset => 'UTF-8')
|
172
|
+
expect(provider).to receive(:`).at_least(1).times.with("file '#{path}'").and_return("#{path}: ASCII text, with very long line")
|
173
|
+
expect(provider.encoding_for(path)).to eq('text')
|
174
|
+
end
|
162
175
|
end
|
163
176
|
|
164
177
|
describe "#log" do
|