dpl 1.6.4.travis.459.1 → 1.6.4.travis.462.1

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
- YzY3Nzg4NzE5Njk1MWMxMTVjM2I5YzgxMjIwNzg3YjZmMWVhOWZhYg==
4
+ OGU5Y2M2MGQ3MDlmMWRiYTIzMzIzNDE5NTkxNGJlN2FkMTAyZDhmNg==
5
5
  data.tar.gz: !binary |-
6
- Zjc2N2I4MGJmMTM1NWY3YzgyMWM2N2ZmNzgwN2ViMTIyODYwZmRhZg==
6
+ YmIxODQ3YjFhZmRjZTBlYTA2N2QzY2Y0ZTc4ZmY4ODc1MjZmYzQzMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzliOTEyOGE1MTExNmRjYzAyNjM4NjZlY2Y1NjM0MzI1Yjk3ZTE5NDNmNjAx
10
- NzRlNTJmYzVlNmFkZTkyNjU1ZWExZjlmNmE3YjgyMmFiMmYxZDRlNmZlMDJj
11
- M2ZkODBlZjcwMzhhZTdhNTJiODFiOTk5NWMzYzZjMWY1NDk1MmQ=
9
+ OTU5YTAyZjVkMjM1MGNiMjRlYzc0OGY0ZGMyMWNiMDNlNGZlNGQxMjkyZjJi
10
+ YmE1NjA4MDQ1MTExNmUzNWIxMzA0MGExMjY3NmIzMGU0Y2Q5N2JmNjAwZDBm
11
+ MWFlNjUwMzBiYTMzMjMwZTE3MGI2NGYyMmQzZjI3MTcxODJhNDI=
12
12
  data.tar.gz: !binary |-
13
- OTAwZjM0N2ZkNGFhNDcwNzJkNzZlZmM5MWY1MTYzOWE0YzI2NTQ5ZTljMjdm
14
- YjYyOTdhMGJkOGM0MDJhZjg0ZTViZjI4NjEwNTFmOWVmMGRmOTFiNDIxZjEw
15
- YWNiNmJlMDNmNTJmNDBmZDY2ZDJmNzc4ZGEwNWE1MzU4ODdiYjk=
13
+ ZTc4NjA3MWE1ODVhZWMzZTg1MTc0NTZkYWEzZWRlOTc3MDY4MTllYjViM2Ew
14
+ NDMzZjlhNDk2Zjg5NjhhMjY2YWU4MDFmZTQzMWM5MTMxMGI5MTU1OTkxY2E3
15
+ OGQyYjkyMWVlNmExYTZlY2MyNjU2Y2IzMDA3YmM2ZDI0OGRiZjA=
@@ -35,7 +35,10 @@ module DPL
35
35
  Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
36
36
  Dir.glob("**/*") do |filename|
37
37
  content_type = MIME::Types.type_for(filename).first.to_s
38
- api.buckets[option(:bucket)].objects.create(upload_path(filename), File.read(filename), :content_type => content_type) unless File.directory?(filename)
38
+ opts = { :content_type => content_type }.merge(encoding_option_for(filename))
39
+ unless File.directory?(filename)
40
+ api.buckets[option(:bucket)].objects.create(upload_path(filename), File.read(filename), opts)
41
+ end
39
42
  end
40
43
  end
41
44
  end
@@ -50,6 +53,28 @@ module DPL
50
53
  raise Error, "Oops, It looks like you tried to write to a bucket that isn't yours or doesn't exist yet. Please create the bucket before trying to write to it."
51
54
  end
52
55
 
56
+ private
57
+ def detect_encoding?
58
+ options[:detect_encoding]
59
+ end
60
+
61
+ def encoding_for(path)
62
+ file_cmd_output = `file #{path}`
63
+ case file_cmd_output
64
+ when /gzip compressed/
65
+ 'gzip'
66
+ when /compress'd/
67
+ 'compress'
68
+ end
69
+ end
70
+
71
+ def encoding_option_for(path)
72
+ if detect_encoding? && encoding_for(path)
73
+ {:content_encoding => encoding_for(path)}
74
+ else
75
+ {}
76
+ end
77
+ end
53
78
  end
54
79
  end
55
80
  end
@@ -48,7 +48,7 @@ describe DPL::Provider::S3 do
48
48
  end
49
49
  end
50
50
 
51
- describe "#needs_key?" do
51
+ describe "#needs_key?" do
52
52
  example do
53
53
  expect(provider.needs_key?).to eq(false)
54
54
  end
@@ -72,6 +72,16 @@ describe "#needs_key?" do
72
72
  expect_any_instance_of(AWS::S3::ObjectCollection).to receive(:create).with(anything(), anything(), hash_including(:content_type => 'application/x-ruby'))
73
73
  provider.push_app
74
74
  end
75
+
76
+ example "when detect_encoding is set" do
77
+ path = 'foo.js'
78
+ provider.options.update(:detect_encoding => true)
79
+ expect(Dir).to receive(:glob).and_yield(path)
80
+ expect(provider).to receive(:`).at_least(1).times.with("file #{path}").and_return('gzip compressed')
81
+ expect(File).to receive(:read).with(path).and_return("")
82
+ expect_any_instance_of(AWS::S3::ObjectCollection).to receive(:create).with(anything(), anything(), hash_including(:content_encoding => 'gzip'))
83
+ provider.push_app
84
+ end
75
85
  end
76
86
 
77
87
  describe "#api" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4.travis.459.1
4
+ version: 1.6.4.travis.462.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-10 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec