maglove 1.0.3 → 1.0.4

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: ba272d7f5bbb561afb0f11895cb453e5b4d57d59
4
- data.tar.gz: 05a7b2259684673d40c685a4b6658a14f2626940
3
+ metadata.gz: d03f49f976b135dca9ed23f2ea614b5a2a6c876c
4
+ data.tar.gz: 0ca45fd7c19b37c84f85e1db4eabab05c0e34152
5
5
  SHA512:
6
- metadata.gz: a73eac01829081e36ae03bde5f01c932a804446b9a3b9c3951842d15d131345e544f6a06ad72f07400cbf99f737fc7782586890eb3c6e11646661691d49433e8
7
- data.tar.gz: 1dd43fa97def50820dbed7745d7aaffecd107bf3bcd46f4b461a1f136bfc2a1b9aa4c92f5be4f89a1c0c23d1495ea10895118d3bf340a71c7acead15995646d3
6
+ metadata.gz: d941d6beeadb0023f4fdaf48d4ca2b5455445fbe8d86f64f6fef8a1c4c70883753ffa839c2df1fed94d451e8c288d96ed1a6e2d08602f312b6b2ae69cf2656c0
7
+ data.tar.gz: 129e6ca7bfc95d9cfa40e9133c71d23164324caa7566bed6712fa8d6e80814b8ae591562b645fdce214842537f8e33b5794802d9db1e701fb082d77d96415ba4
data/Gemfile.lock CHANGED
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maglove (1.0.3)
4
+ maglove (1.0.4)
5
5
  actionpack (>= 4.0)
6
6
  activesupport (>= 4.0)
7
7
  bundler (~> 1.10)
8
8
  coffee-script (~> 2.4)
9
9
  dialers (~> 0.2)
10
- faraday (~> 0.9)
11
10
  faye (~> 1.2)
12
11
  filewatcher (~> 0.5)
13
12
  haml (~> 4.0)
@@ -24,6 +23,7 @@ PATH
24
23
  therubyracer (~> 0.12)
25
24
  thor (~> 0.19)
26
25
  tilt (~> 1.4)
26
+ typhoeus (~> 1.1)
27
27
 
28
28
  GEM
29
29
  remote: https://rubygems.org/
@@ -69,6 +69,8 @@ GEM
69
69
  em-socksify (0.3.1)
70
70
  eventmachine (>= 1.0.0.beta.4)
71
71
  erubis (2.7.0)
72
+ ethon (0.9.1)
73
+ ffi (>= 1.3.0)
72
74
  eventmachine (1.2.0.1)
73
75
  execjs (2.7.0)
74
76
  exifr (1.2.5)
@@ -89,6 +91,7 @@ GEM
89
91
  faye-websocket (0.10.4)
90
92
  eventmachine (>= 0.12.0)
91
93
  websocket-driver (>= 0.5.1)
94
+ ffi (1.9.14)
92
95
  filewatcher (0.5.3)
93
96
  trollop (~> 2.0)
94
97
  fspath (3.0.1)
@@ -119,7 +122,7 @@ GEM
119
122
  multi_json (~> 1.10)
120
123
  loofah (2.0.3)
121
124
  nokogiri (>= 1.5.9)
122
- maglove-widgets (1.0.0)
125
+ maglove-widgets (1.0.1)
123
126
  bundler (~> 1.10)
124
127
  haml (~> 4.0)
125
128
  hamloft (~> 0.2.4)
@@ -161,6 +164,8 @@ GEM
161
164
  thread_safe (0.3.5)
162
165
  tilt (1.4.1)
163
166
  trollop (2.1.2)
167
+ typhoeus (1.1.0)
168
+ ethon (>= 0.9.0)
164
169
  tzinfo (1.2.2)
165
170
  thread_safe (~> 0.1)
166
171
  unicode-display_width (1.1.0)
data/bin/maglove CHANGED
@@ -6,6 +6,7 @@ require 'coffee_script'
6
6
  require "active_support/all"
7
7
  require "hamloft"
8
8
  require "workspace"
9
+ require "typhoeus"
9
10
  require "maglove"
10
11
  require "action_dispatch/http/mime_type"
11
12
 
@@ -14,5 +14,12 @@ module MagLoft
14
14
  response = conn.put(nil, File.read(file_path))
15
15
  return (response.status == 200)
16
16
  end
17
+
18
+ def queue_upload_thumbnail(file_path, &block)
19
+ return false if thumbnail_policy.nil?
20
+ request = Typhoeus::Request.new(thumbnail_policy["url"], method: :put, headers: thumbnail_policy["headers"], body: File.read(file_path), timeout: 200000)
21
+ request.on_complete(&block) if block
22
+ request
23
+ end
17
24
  end
18
25
  end
@@ -14,5 +14,12 @@ module MagLoft
14
14
  response = conn.put(nil, File.read(file_path))
15
15
  return (response.status == 200)
16
16
  end
17
+
18
+ def queue_upload(file_path, &block)
19
+ return false if policy.nil?
20
+ request = Typhoeus::Request.new(policy["url"], method: :put, headers: policy["headers"], body: File.read(file_path), timeout: 200000)
21
+ request.on_complete(&block) if block
22
+ request
23
+ end
17
24
  end
18
25
  end
@@ -14,5 +14,12 @@ module MagLoft
14
14
  response = conn.put(nil, File.read(file_path))
15
15
  return (response.status == 200)
16
16
  end
17
+
18
+ def queue_upload_thumbnail(file_path, &block)
19
+ return false if thumbnail_policy.nil?
20
+ request = Typhoeus::Request.new(thumbnail_policy["url"], method: :put, headers: thumbnail_policy["headers"], body: File.read(file_path), timeout: 200000)
21
+ request.on_complete(&block) if block
22
+ request
23
+ end
17
24
  end
18
25
  end
@@ -90,21 +90,23 @@ module MagLove
90
90
  info("▸ Synchronizing Images")
91
91
  theme_images = theme.typeloft_images.all
92
92
  theme_images_map = Hash[theme_images.map { |image| [image.remote_file, image] }]
93
+ hydra = Typhoeus::Hydra.new
93
94
  theme_dir(root: "dist").files("images/**/*.{jpg,png,gif,svg}").each do |image_file|
94
95
  remote_file = "themes/#{options.theme}/#{image_file.relative_path}"
95
96
  if (existing_image = theme_images_map[remote_file])
96
97
  if image_file.md5 != existing_image.md5
97
98
  info("▸ Updating Image '#{remote_file}'")
98
99
  existing_image.md5 = image_file.md5
99
- existing_image.upload(image_file.to_s)
100
+ hydra.queue(existing_image.queue_upload(image_file.to_s) {debug("▸ Finished updating Image '#{remote_file}'")})
100
101
  existing_image.save
101
102
  end
102
103
  else
103
104
  info("▸ Creating Image '#{remote_file}'")
104
105
  new_image = theme.typeloft_images.create(remote_file: remote_file, title: image_file.basename.titlecase, md5: image_file.md5)
105
- new_image.upload(image_file.to_s)
106
+ hydra.queue(new_image.upload(image_file.to_s) {info("▸ Finished creating Image '#{remote_file}'")})
106
107
  end
107
108
  end
109
+ hydra.run
108
110
 
109
111
  # upload css/js
110
112
  info("▸ Synchronizing JavaScript and Stylesheet")
@@ -136,13 +138,14 @@ module MagLove
136
138
  # update thumbnails
137
139
  if options.thumbnails
138
140
  invoke(:thumbnails, [], { theme: options.theme })
139
-
141
+ hydra = Typhoeus::Hydra.new
142
+
140
143
  info("▸ Synchronizing Template Thumbnails")
141
144
  theme.typeloft_templates.all.each do |template|
142
145
  thumbnail_file = theme_dir(root: "dist").dir("templates").file("#{template.identifier}.png")
143
146
  if thumbnail_file.exists?
144
147
  info("~> Uploading Thumbnail for '#{template.identifier}'")
145
- template.upload_thumbnail(thumbnail_file.to_s)
148
+ hydra.queue(template.queue_upload_thumbnail(thumbnail_file.to_s) {info("▸ Finished uploading Thumbnail for '#{template.identifier}'")})
146
149
  end
147
150
  end
148
151
 
@@ -151,9 +154,10 @@ module MagLove
151
154
  thumbnail_file = theme_dir(root: "dist").dir("blocks").file("#{block.identifier}.png")
152
155
  if thumbnail_file.exists?
153
156
  info("~> Uploading Thumbnail for '#{block.identifier}'")
154
- block.upload_thumbnail(thumbnail_file.to_s)
157
+ hydra.queue(block.queue_upload_thumbnail(thumbnail_file.to_s) {info("▸ Finished uploading Thumbnail for '#{block.identifier}'")})
155
158
  end
156
159
  end
160
+ hydra.run
157
161
  end
158
162
 
159
163
  info("▸ Successfully Pushed Theme")
@@ -1,3 +1,3 @@
1
1
  module MagLove
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
data/maglove.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_runtime_dependency "puma", "~> 3.6"
35
35
  s.add_runtime_dependency "filewatcher", "~> 0.5"
36
36
  s.add_runtime_dependency "faye", "~> 1.2"
37
- s.add_runtime_dependency "faraday", "~> 0.9"
37
+ s.add_runtime_dependency "typhoeus", "~> 1.1"
38
38
  s.add_development_dependency "rubocop", "~> 0.32"
39
39
  s.files = `git ls-files`.split("\n")
40
40
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maglove
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
@@ -305,19 +305,19 @@ dependencies:
305
305
  - !ruby/object:Gem::Version
306
306
  version: '1.2'
307
307
  - !ruby/object:Gem::Dependency
308
- name: faraday
308
+ name: typhoeus
309
309
  requirement: !ruby/object:Gem::Requirement
310
310
  requirements:
311
311
  - - "~>"
312
312
  - !ruby/object:Gem::Version
313
- version: '0.9'
313
+ version: '1.1'
314
314
  type: :runtime
315
315
  prerelease: false
316
316
  version_requirements: !ruby/object:Gem::Requirement
317
317
  requirements:
318
318
  - - "~>"
319
319
  - !ruby/object:Gem::Version
320
- version: '0.9'
320
+ version: '1.1'
321
321
  - !ruby/object:Gem::Dependency
322
322
  name: rubocop
323
323
  requirement: !ruby/object:Gem::Requirement