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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjljNGI4OTY4ZGZkMWUxYzg5NTI5Mjk3NDQ2YWQ4ODk2ZjY2ZGZjNg==
4
+ ZGRhOWVkOGU4NTIyNGI3MTNjMTcxNWFiOWY1OTZmMzcwZGZlNTFjMg==
5
5
  data.tar.gz: !binary |-
6
- MGRlNzZjMDdhZTk4ZDU2YjA5OGVkYTc2OWQxY2E5NWE1NTIyM2U1OQ==
6
+ NjdjMTZmNDk4YmQ5MDkxMTMwOGM5N2JlYjRmNjVhNDJlZDg5ZDc3NQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmE3ZWRhMGQwMmE3NTIxODRkMTVkMGIyZjU2Y2ZmZDI1OTI3ZDNiM2E3Nzk4
10
- MjY3YWNlNzlhZWJkMTA5MWIyZDk0ZTAzZGQzZDQ0NGIxYTU0ODNkZTQyZDhm
11
- ZGZkZDRjYjRiOWRlNzJjMDc2ZDliOGE0MmVhYzdiNjFiY2U2Zjc=
9
+ Njk3MzVjMzc2OTgzOGFjNGQ5ZTZlNmVjNGVmMjM2Zjk1OWMyMTQzM2YxNGU0
10
+ Yzk0YThhOTNjMWUzNzhkNjA0Mzg5NzBhMmE4NDU1ZGM2MjJhZWM5ZGIyNGY1
11
+ ZTUxMTNhOGJmYmJhYmJiNjI5MmQ1ZmU2YmYzNjgzOGZjM2RkNTU=
12
12
  data.tar.gz: !binary |-
13
- ZTM5NzIwZTBmZmJiY2U0NmRkYTVkNGNiYjE2NGZlMTg4ZWZkYjFhNTdiY2Uw
14
- MTkxNzZmZjNkZDBjMmViMWRjNDg1NjA4NTE2MWRkNjVkODE0YTRlZjkwNmE5
15
- MjU0NjMxMzkwZDJhOTI3MDIwMTIyMTU1ZmIzODdlOGE1YTRjNWQ=
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
 
@@ -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
 
@@ -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
- content_type = MIME::Types.type_for(filename).first.to_s
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 %p" % filename
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 encoding_option_for(path)
84
- if detect_encoding? && encoding_for(path)
85
- {:content_encoding => encoding_for(path)}
86
- else
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)
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.17.travis.1460.4
4
+ version: 1.8.17.travis.1464.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase