maglove 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/maglove/commands/assets.rb +23 -0
- data/lib/maglove/version.rb +1 -1
- data/lib/workspace/workspace_file.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80be4fcc389c5eb11f5e440cb0df7b8598bed7ae
|
4
|
+
data.tar.gz: f38ee17373a3c0708340ceee7ff7ce2ba64cde41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db79b23d637c1741e1bd26cdbe56bcb6771190036903d3a748459594452c305f1f00d60fc31f8124c67505207b5df202bbb9fdab76801574b64e25e6499f5b3
|
7
|
+
data.tar.gz: 2c0cf6cc041b8e451dc9c490621f5879723976508b954fa159fcef859cb0698968a09c1f4880c6452089c82c72c2a338416f460e1b178b6eaadc43ac0f72d8ef
|
data/Gemfile.lock
CHANGED
@@ -32,6 +32,29 @@ module MagLove
|
|
32
32
|
file.asset.write!
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
desc "imageoptim", "Optimize images"
|
37
|
+
option :percent, type: :numeric, required: true, default: 25
|
38
|
+
def imageoptim
|
39
|
+
require "image_optim"
|
40
|
+
optimizer = ImageOptim.new(nice: 20, pngout: true, optipng: {level: 5}, jpegoptim: {allow_lossy: true, max_quality: 80})
|
41
|
+
info("▸ Optimizing Images")
|
42
|
+
theme_dir.files("images/**/*.{jpg,png,gif}").each do |file|
|
43
|
+
if optimizer.optimizable?(file.to_s)
|
44
|
+
new_path = optimizer.optimize_image(file.to_s)
|
45
|
+
if !new_path.nil?
|
46
|
+
new_file = WorkspaceFile.new("/", new_path.to_s)
|
47
|
+
improvement = (file.size.to_f / new_file.size - 1) * 100
|
48
|
+
if improvement >= options.percent
|
49
|
+
info("~> #{file} optimized #{improvement.to_i}% (#{file.size/1000}kb to #{new_file.size/1000}kb)")
|
50
|
+
new_file.move(file)
|
51
|
+
else
|
52
|
+
debug("~> #{file} (#{improvement.to_i}% < #{options.percent}%)")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
35
58
|
|
36
59
|
desc "javascript", "Compile JavaScript"
|
37
60
|
def javascript
|
data/lib/maglove/version.rb
CHANGED
@@ -42,6 +42,11 @@ module Workspace
|
|
42
42
|
target_file.dir.create unless target_file.dir.exists?
|
43
43
|
FileUtils.cp(to_s, target_file.to_s)
|
44
44
|
end
|
45
|
+
|
46
|
+
def move(target_file)
|
47
|
+
target_file.dir.create unless target_file.dir.exists?
|
48
|
+
FileUtils.mv(to_s, target_file.to_s)
|
49
|
+
end
|
45
50
|
|
46
51
|
def to_s
|
47
52
|
File.join(@workspace, @path)
|
@@ -95,5 +100,9 @@ module Workspace
|
|
95
100
|
def absolute_path
|
96
101
|
File.absolute_path(to_s)
|
97
102
|
end
|
103
|
+
|
104
|
+
def size
|
105
|
+
File.size(to_s)
|
106
|
+
end
|
98
107
|
end
|
99
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maglove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Strebitzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|