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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28aa277ef1e3d61e0a73ca340fce4063ee3e9187
4
- data.tar.gz: b6ee63e3775ee7d9c5a0ea00e04b48e9df687159
3
+ metadata.gz: 80be4fcc389c5eb11f5e440cb0df7b8598bed7ae
4
+ data.tar.gz: f38ee17373a3c0708340ceee7ff7ce2ba64cde41
5
5
  SHA512:
6
- metadata.gz: 9224bf9bc2ac596d1b92f3436568ba28d7d1f021408d219854078727d535c71212eb03e67b92173c25131fc0878d73bc99c6bd118bb3ff9c6587bdeaa8ab64f8
7
- data.tar.gz: 0a6cf9be836d074519da9519500ef74c4bb74518619a02a7e8c5bfcf960690b40f232492820a4c4b39410ee9693f448df4f7cebdc4b805d10e1ab3ec8f8a8b76
6
+ metadata.gz: 9db79b23d637c1741e1bd26cdbe56bcb6771190036903d3a748459594452c305f1f00d60fc31f8124c67505207b5df202bbb9fdab76801574b64e25e6499f5b3
7
+ data.tar.gz: 2c0cf6cc041b8e451dc9c490621f5879723976508b954fa159fcef859cb0698968a09c1f4880c6452089c82c72c2a338416f460e1b178b6eaadc43ac0f72d8ef
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maglove (1.0.8)
4
+ maglove (1.0.9)
5
5
  actionpack (>= 4.0)
6
6
  activesupport (>= 4.0)
7
7
  bundler (~> 1.10)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MagLove
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -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.8
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-05 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler