middleman-smusher 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,51 +1,28 @@
1
1
  module Middleman
2
2
  module Features
3
3
  module Smusher
4
- module ThorActions
5
- def smush_pngs
6
- # Read cache
7
- cache_file = File.join(Middleman::Server.root, ".smush-cache")
8
- cache_data = if File.exists?(cache_file)
9
- Marshal.restore(File.read(cache_file))
10
- else
11
- {}
12
- end
13
-
14
- smush_dir = File.join(Middleman::Server.build_dir, Middleman::Server.images_dir)
15
-
16
- files = ::Smusher.class_eval do
17
- images_in_folder(smush_dir)
18
- end
19
-
20
- files.each do |file|
21
- ::Smusher.class_eval do
22
- original_file_size = size(file)
23
- return if original_file_size.zero?
24
- return if cache_data[file] && cache_data[file] == original_file_size
25
-
26
- with_logging(file, true) do
27
- write_optimized_data(file)
28
- cache_data[file] = size(file) # Add or update cache
29
- File.open(cache_file, "w") { |f| f.write Marshal.dump(cache_data) } # Write cache
30
- end
31
- end
32
-
33
- say_status :smushed, file.gsub(Middleman::Server.build_dir+"/", "")
34
- end
35
- end
36
- end
37
-
38
4
  class << self
39
5
  def registered(app)
40
- require "middleman/builder"
41
6
  require "smusher"
42
- require "json/pure"
43
-
44
- Middleman::Builder.send :include, ThorActions
45
- Middleman::Builder.after_run "smush_pngs" do
46
- smush_pngs
7
+
8
+ app.after_build do
9
+ smush_dir = File.join(app.build_dir, app.images_dir)
10
+
11
+ files = ::Smusher.class_eval do
12
+ images_in_folder(smush_dir)
13
+ end
14
+
15
+ files.each do |file|
16
+ ::Smusher.optimize_image(
17
+ [file],
18
+ { :service => 'PunyPng', :quiet => true }
19
+ )
20
+
21
+ say_status :smushed, file.gsub(app.build_dir+"/", "")
22
+ end
47
23
  end
48
- end
24
+ end
25
+ alias :included :registered
49
26
  end
50
27
  end
51
28
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Smusher
3
- VERSION = "0.0.3"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency("middleman", ["~> 1.2.0"])
23
- s.add_runtime_dependency("smusher", ["~> 0.4.6"])
22
+ s.add_runtime_dependency("middleman", ["~> 2.0.0"])
23
+ s.add_runtime_dependency("smusher", ["~> 0.4.8"])
24
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-smusher
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thomas Reynolds
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-04 00:00:00 -07:00
19
- default_executable:
18
+ date: 2011-08-14 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: middleman
@@ -26,12 +25,12 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 31
28
+ hash: 15
30
29
  segments:
31
- - 1
32
30
  - 2
33
31
  - 0
34
- version: 1.2.0
32
+ - 0
33
+ version: 2.0.0
35
34
  type: :runtime
36
35
  version_requirements: *id001
37
36
  - !ruby/object:Gem::Dependency
@@ -42,12 +41,12 @@ dependencies:
42
41
  requirements:
43
42
  - - ~>
44
43
  - !ruby/object:Gem::Version
45
- hash: 3
44
+ hash: 31
46
45
  segments:
47
46
  - 0
48
47
  - 4
49
- - 6
50
- version: 0.4.6
48
+ - 8
49
+ version: 0.4.8
51
50
  type: :runtime
52
51
  version_requirements: *id002
53
52
  description: Compress images in your Middleman project
@@ -66,7 +65,6 @@ files:
66
65
  - lib/middleman-smusher.rb
67
66
  - lib/middleman-smusher/version.rb
68
67
  - middleman-smusher.gemspec
69
- has_rdoc: true
70
68
  homepage: https://github.com/tdreyno/middleman-smusher
71
69
  licenses: []
72
70
 
@@ -96,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
94
  requirements: []
97
95
 
98
96
  rubyforge_project: middleman-smusher
99
- rubygems_version: 1.5.0
97
+ rubygems_version: 1.8.6
100
98
  signing_key:
101
99
  specification_version: 3
102
100
  summary: Compress images in your Middleman project