dronejob 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f5e9e2f89bca4a32b5c4d2e22355dd8119a1e35
4
- data.tar.gz: efe88d06655a102c61f49ed16e14c9f93372753b
3
+ metadata.gz: 7535e1f622ba59d4768130550558e57c02efad5e
4
+ data.tar.gz: b658855bb26b80dbdf3c8c127f170a30dfb440c3
5
5
  SHA512:
6
- metadata.gz: cb7465f7d2a81c1a8c515164bcb0a7588f3edd9d91ac594b13b31a1579c1e5f02dee99f729639024feda35b07844a75abe6611b0faa951dd2b26100bc358e807
7
- data.tar.gz: 60f63fd603c97fbfd8122c6179f4959f87cdd910c16acc2aa411bd753d50e1d158f2f17c663f580581a5b96727d11ff9eb91e76556456963f633261b214dd4e8
6
+ metadata.gz: 5bb4eb0f05a5ade24c4c20afedaa20576d951fc7ffa471713abdc1ee5b27f0997fabc1a26af14166dd3e24174b6d0478736b1cf6f58fb13bc163aa9975d70b01
7
+ data.tar.gz: 56faebec1f89774cffcbdf7e69dde7cbf13cbb4c4da41426889cced857beb4803433dc9ea08b18cf4c19e8d51be3e37dfd690e570f86bb96734801f148be413a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dronejob (1.3.0)
4
+ dronejob (1.3.1)
5
5
  actionpack (>= 4.0)
6
6
  activejob (~> 4.2)
7
7
  bundler (>= 1.3.0, < 2.0)
@@ -10,6 +10,7 @@ PATH
10
10
  google-cloud-storage (~> 0.23)
11
11
  haml (~> 4.0)
12
12
  open_uri_redirections (~> 0.2)
13
+ piet (~> 0.2)
13
14
  pusher (~> 1.3)
14
15
  rubyzip (~> 1.1)
15
16
  sidekiq (~> 4.1)
@@ -59,7 +60,7 @@ GEM
59
60
  git (1.3.0)
60
61
  globalid (0.4.0)
61
62
  activesupport (>= 4.2.0)
62
- google-api-client (0.10.2)
63
+ google-api-client (0.10.3)
63
64
  addressable (~> 2.3)
64
65
  googleauth (~> 0.5)
65
66
  httpclient (~> 2.7)
@@ -78,13 +79,13 @@ GEM
78
79
  digest-crc (~> 0.4)
79
80
  google-api-client (~> 0.10.0)
80
81
  google-cloud-core (~> 0.21.0)
81
- google-gax (0.8.2)
82
+ google-gax (0.8.3)
82
83
  google-protobuf (~> 3.2)
83
84
  googleapis-common-protos (~> 1.3.5)
84
85
  googleauth (~> 0.5.1)
85
86
  grpc (~> 1.0)
86
87
  rly (~> 0.2.3)
87
- google-protobuf (3.2.0.2-universal-darwin)
88
+ google-protobuf (3.3.0-universal-darwin)
88
89
  googleapis-common-protos (1.3.5)
89
90
  google-protobuf (~> 3.2)
90
91
  grpc (~> 1.0)
@@ -96,14 +97,14 @@ GEM
96
97
  multi_json (~> 1.11)
97
98
  os (~> 0.9)
98
99
  signet (~> 0.7)
99
- grpc (1.2.5-universal-darwin)
100
+ grpc (1.3.4-universal-darwin)
100
101
  google-protobuf (~> 3.1)
101
102
  googleauth (~> 0.5.1)
102
103
  haml (4.0.7)
103
104
  tilt
104
105
  httpclient (2.8.3)
105
106
  hurley (0.2)
106
- i18n (0.8.1)
107
+ i18n (0.8.4)
107
108
  jwt (1.5.6)
108
109
  little-plugger (1.1.4)
109
110
  logging (2.2.2)
@@ -116,14 +117,17 @@ GEM
116
117
  mime-types (3.1)
117
118
  mime-types-data (~> 3.2015)
118
119
  mime-types-data (3.2016.0521)
119
- mini_portile2 (2.1.0)
120
- minitest (5.10.1)
120
+ mini_portile2 (2.2.0)
121
+ minitest (5.10.2)
121
122
  multi_json (1.12.1)
122
123
  multipart-post (2.0.0)
123
- nokogiri (1.7.1)
124
- mini_portile2 (~> 2.1.0)
124
+ nokogiri (1.8.0)
125
+ mini_portile2 (~> 2.2.0)
125
126
  open_uri_redirections (0.2.1)
126
127
  os (0.9.6)
128
+ piet (0.2.5)
129
+ png_quantizator
130
+ png_quantizator (0.2.1)
127
131
  pry (0.10.3)
128
132
  coderay (~> 1.1.0)
129
133
  method_source (~> 0.8.1)
@@ -134,8 +138,8 @@ GEM
134
138
  multi_json (~> 1.0)
135
139
  pusher-signature (~> 0.1.8)
136
140
  pusher-signature (0.1.8)
137
- rack (1.6.5)
138
- rack-protection (1.5.3)
141
+ rack (1.6.8)
142
+ rack-protection (2.0.0)
139
143
  rack
140
144
  rack-test (0.6.3)
141
145
  rack (>= 1.0)
@@ -152,7 +156,7 @@ GEM
152
156
  declarative (< 0.1.0)
153
157
  declarative-option (< 0.2.0)
154
158
  uber (< 0.2.0)
155
- retriable (3.0.1)
159
+ retriable (3.0.2)
156
160
  rly (0.2.3)
157
161
  rspec (3.4.0)
158
162
  rspec-core (~> 3.4.0)
data/dronejob.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency "google-cloud-storage", "~> 0.23"
28
28
  s.add_runtime_dependency "google-cloud-logging", "~> 0.23"
29
29
  s.add_runtime_dependency "pusher", "~> 1.3"
30
+ s.add_runtime_dependency "piet", "~> 0.2"
30
31
  s.add_development_dependency "rspec", "~> 3.3"
31
32
  s.add_development_dependency "pry", "~> 0.10"
32
33
  s.files = `git ls-files`.split("\n")
@@ -1,3 +1,3 @@
1
1
  module Dronejob
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -6,10 +6,10 @@ module Dronejob
6
6
 
7
7
  def extract(target_dir)
8
8
  target_dir.create
9
- if extension == "zip"
10
- extract_zip(target_dir)
11
- elsif extension == "gz"
9
+ if extension == "gz"
12
10
  extract_gz(target_dir)
11
+ else
12
+ extract_zip(target_dir)
13
13
  end
14
14
  self
15
15
  end
@@ -20,6 +20,8 @@ module Dronejob
20
20
  require "zip"
21
21
  Zip::File.open(to_s) do |archive|
22
22
  archive.each do |entry|
23
+ extract_dir = target_dir.file(entry.name).dir
24
+ extract_dir.create unless extract_dir.exists?
23
25
  entry.extract(File.join(target_dir.to_s, entry.name))
24
26
  end
25
27
  end
@@ -1,3 +1,5 @@
1
+ require "piet"
2
+
1
3
  module Dronejob
2
4
  class WorkspaceFile
3
5
  module Media
@@ -48,11 +50,24 @@ module Dronejob
48
50
  self
49
51
  end
50
52
 
53
+ def fit(width, height)
54
+ require "rmagick"
55
+ image = Magick::Image.read(to_s).first
56
+ image.change_geometry!("#{width}x^#{height}") { |cols, rows| image.thumbnail!(cols, rows) }
57
+ image.crop!(0, 0, width, height)
58
+ image.write(to_s) { self.quality = Dronejob::Base.option(:image_quality) }
59
+ image.destroy!
60
+ end
61
+
51
62
  def optimize!
52
- return false if !exists?
53
- return optimize_jpg! if image? and ["jpg", "jpeg"].include?(extension)
54
- return optimize_png! if image? and ["png"].include?(extension)
55
- false
63
+ return false if !exists? or !image?
64
+ optimize_png! if ["png"].include?(extension)
65
+ optimize_jpg! if ["jpg", "jpeg"].include?(extension)
66
+
67
+ # optimize
68
+ Piet.optimize(to_s, verbose: false)
69
+
70
+ true
56
71
  end
57
72
 
58
73
  private
@@ -48,8 +48,15 @@ module Dronejob
48
48
  File.join(@workspace, @path)
49
49
  end
50
50
 
51
- def relative_path
52
- @path.gsub(/^\//, "")
51
+ def relative_path(relative_dir=nil)
52
+ if relative_dir
53
+ relative_dir = relative_dir.dir if relative_dir.class == WorkspaceFile
54
+ first = Pathname.new(relative_dir.path)
55
+ second = Pathname.new(path)
56
+ second.relative_path_from(first).to_s
57
+ else
58
+ @path.gsub(/^\//, "")
59
+ end
53
60
  end
54
61
 
55
62
  def absolute_path
@@ -71,6 +78,10 @@ module Dronejob
71
78
  def delete!
72
79
  FileUtils.rm_f(to_s)
73
80
  end
81
+
82
+ def name
83
+ "#{basename}.#{extension}"
84
+ end
74
85
 
75
86
  def basename
76
87
  File.basename(path, ".*")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dronejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,6 +198,20 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: '1.3'
201
+ - !ruby/object:Gem::Dependency
202
+ name: piet
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - "~>"
206
+ - !ruby/object:Gem::Version
207
+ version: '0.2'
208
+ type: :runtime
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '0.2'
201
215
  - !ruby/object:Gem::Dependency
202
216
  name: rspec
203
217
  requirement: !ruby/object:Gem::Requirement