awestruct 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ require 'fileutils'
2
+
3
+ module Awestruct
4
+ module Extensions
5
+ class Minify
6
+
7
+ def initialize(types = [ :css, :js ])
8
+ @types = types
9
+ end
10
+
11
+ def transform(site, page, input)
12
+ if site.minify
13
+ ext = File.extname(page.output_path)[1..-1].to_sym
14
+ if @types.include?(ext)
15
+ case ext
16
+ when :html
17
+ print "minifying html #{page.output_path}"
18
+ htmlcompressor(page, input)
19
+ when :css
20
+ print "minifying css #{page.output_path}"
21
+ yuicompressor(page, input, :css)
22
+ when :js
23
+ print "minifying js #{page.output_path}"
24
+ yuicompressor(page, input, :js)
25
+ when :png
26
+ print "minifying png #{page.output_path}"
27
+ pngcrush(page, input)
28
+ else
29
+ input
30
+ end
31
+ end
32
+ end
33
+ input
34
+ end
35
+
36
+ private
37
+
38
+ def htmlcompressor(page, input)
39
+ output = ''
40
+ Open3.popen3("htmlcompressor --remove-intertag-spaces") do |stdin, stdout, stderr|
41
+ threads = []
42
+ threads << Thread.new(stdout) do |o|
43
+ while ( ! o.eof? )
44
+ output << o.readline
45
+ end
46
+ end
47
+ threads << Thread.new(stdin) do |i|
48
+ i.write input
49
+ i.close
50
+ end
51
+ threads.each{ |t|t.join }
52
+ end
53
+
54
+ input_len = input.length
55
+ output_len = output.length
56
+
57
+ if input_len > output_len
58
+ puts " %d bytes -> %d bytes = %.1f%%" % [ input_len, output_len, 100 * output_len/input_len ]
59
+ output
60
+ else
61
+ puts " no gain"
62
+ input
63
+ end
64
+ end
65
+
66
+ def yuicompressor(page, input, type)
67
+ output = ''
68
+ Open3.popen3("yuicompressor --type #{type}") do |stdin, stdout, stderr|
69
+ threads = []
70
+ threads << Thread.new(stdout) do |o|
71
+ while ( ! o.eof? )
72
+ output << o.readline
73
+ end
74
+ end
75
+ threads << Thread.new(stdin) do |i|
76
+ i.write input
77
+ i.close
78
+ end
79
+ threads.each{ |t|t.join }
80
+ end
81
+
82
+ input_len = input.length
83
+ output_len = output.length
84
+
85
+ if input_len > output_len
86
+ puts " %d bytes -> %d bytes = %.1f%%" % [ input_len, output_len, 100 * output_len/input_len ]
87
+ output
88
+ else
89
+ puts " no gain"
90
+ input
91
+ end
92
+ end
93
+
94
+ def pngcrush(page, input)
95
+ filename = page.source_path
96
+ cmd = "pngcrush #{filename} /tmp/pngcrush"
97
+ `#{cmd}`
98
+ if $?.exitstatus != 0
99
+ raise "Failed to execute pngcrush: #{cmd}"
100
+ end
101
+ output = File.read('/tmp/pngcrush')
102
+
103
+ input_len = File.stat(filename).size
104
+ output_len = output.length
105
+
106
+ if input_len > output_len
107
+ puts " %d bytes -> %d bytes = %.1f%%" % [ input_len, output_len, 100 * output_len/input_len ]
108
+ output
109
+ else
110
+ puts " no gain"
111
+ input
112
+ end
113
+ end
114
+ end
115
+
116
+ end
117
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Awestruct
3
- VERSION='0.2.12'
3
+ VERSION='0.2.13'
4
4
  end
metadata CHANGED
@@ -1,144 +1,223 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: awestruct
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.12
3
+ version: !ruby/object:Gem::Version
4
+ hash: 13
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 13
10
+ version: 0.2.13
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Bob McWhirter
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-01-30 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-02-07 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: hpricot
16
- requirement: &70193604316820 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 51
29
+ segments:
30
+ - 0
31
+ - 8
32
+ - 6
33
+ version: 0.8.6
22
34
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70193604316820
25
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
26
37
  name: versionomy
27
- requirement: &70193604316200 !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
28
40
  none: false
29
- requirements:
30
- - - =
31
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 13
45
+ segments:
46
+ - 0
47
+ - 4
48
+ - 1
32
49
  version: 0.4.1
33
50
  type: :runtime
34
- prerelease: false
35
- version_requirements: *70193604316200
36
- - !ruby/object:Gem::Dependency
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
37
53
  name: haml
38
- requirement: &70193604315580 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
39
56
  none: false
40
- requirements:
41
- - - <=
42
- - !ruby/object:Gem::Version
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 3
63
+ - 1
64
+ - 0
43
65
  version: 3.1.0
44
66
  type: :runtime
45
- prerelease: false
46
- version_requirements: *70193604315580
47
- - !ruby/object:Gem::Dependency
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
48
69
  name: sass
49
- requirement: &70193604315120 !ruby/object:Gem::Requirement
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
50
72
  none: false
51
- requirements:
52
- - - <=
53
- - !ruby/object:Gem::Version
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 3
79
+ - 1
80
+ - 0
54
81
  version: 3.1.0
55
82
  type: :runtime
56
- prerelease: false
57
- version_requirements: *70193604315120
58
- - !ruby/object:Gem::Dependency
83
+ version_requirements: *id004
84
+ - !ruby/object:Gem::Dependency
59
85
  name: hashery
60
- requirement: &70193604314540 !ruby/object:Gem::Requirement
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
61
88
  none: false
62
- requirements:
63
- - - =
64
- - !ruby/object:Gem::Version
89
+ requirements:
90
+ - - ~>
91
+ - !ruby/object:Gem::Version
92
+ hash: 7
93
+ segments:
94
+ - 1
95
+ - 4
96
+ - 0
65
97
  version: 1.4.0
66
98
  type: :runtime
67
- prerelease: false
68
- version_requirements: *70193604314540
69
- - !ruby/object:Gem::Dependency
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
70
101
  name: rdiscount
71
- requirement: &70193604313960 !ruby/object:Gem::Requirement
102
+ prerelease: false
103
+ requirement: &id006 !ruby/object:Gem::Requirement
72
104
  none: false
73
- requirements:
74
- - - =
75
- - !ruby/object:Gem::Version
105
+ requirements:
106
+ - - ~>
107
+ - !ruby/object:Gem::Version
108
+ hash: 31
109
+ segments:
110
+ - 1
111
+ - 6
112
+ - 8
76
113
  version: 1.6.8
77
114
  type: :runtime
78
- prerelease: false
79
- version_requirements: *70193604313960
80
- - !ruby/object:Gem::Dependency
115
+ version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
81
117
  name: RedCloth
82
- requirement: &70193604313340 !ruby/object:Gem::Requirement
118
+ prerelease: false
119
+ requirement: &id007 !ruby/object:Gem::Requirement
83
120
  none: false
84
- requirements:
85
- - - <=
86
- - !ruby/object:Gem::Version
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ hash: 61
125
+ segments:
126
+ - 4
127
+ - 2
128
+ - 5
87
129
  version: 4.2.5
88
130
  type: :runtime
89
- prerelease: false
90
- version_requirements: *70193604313340
91
- - !ruby/object:Gem::Dependency
131
+ version_requirements: *id007
132
+ - !ruby/object:Gem::Dependency
92
133
  name: compass
93
- requirement: &70193604312860 !ruby/object:Gem::Requirement
134
+ prerelease: false
135
+ requirement: &id008 !ruby/object:Gem::Requirement
94
136
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
137
+ requirements:
138
+ - - ~>
139
+ - !ruby/object:Gem::Version
140
+ hash: 57
141
+ segments:
142
+ - 0
143
+ - 11
144
+ - 5
98
145
  version: 0.11.5
99
146
  type: :runtime
100
- prerelease: false
101
- version_requirements: *70193604312860
102
- - !ruby/object:Gem::Dependency
147
+ version_requirements: *id008
148
+ - !ruby/object:Gem::Dependency
103
149
  name: compass-960-plugin
104
- requirement: &70193604312300 !ruby/object:Gem::Requirement
150
+ prerelease: false
151
+ requirement: &id009 !ruby/object:Gem::Requirement
105
152
  none: false
106
- requirements:
107
- - - <=
108
- - !ruby/object:Gem::Version
153
+ requirements:
154
+ - - ~>
155
+ - !ruby/object:Gem::Version
156
+ hash: 63
157
+ segments:
158
+ - 0
159
+ - 10
160
+ - 4
109
161
  version: 0.10.4
110
162
  type: :runtime
111
- prerelease: false
112
- version_requirements: *70193604312300
113
- - !ruby/object:Gem::Dependency
163
+ version_requirements: *id009
164
+ - !ruby/object:Gem::Dependency
114
165
  name: org-ruby
115
- requirement: &70193604311460 !ruby/object:Gem::Requirement
166
+ prerelease: false
167
+ requirement: &id010 !ruby/object:Gem::Requirement
116
168
  none: false
117
- requirements:
118
- - - =
119
- - !ruby/object:Gem::Version
169
+ requirements:
170
+ - - ~>
171
+ - !ruby/object:Gem::Version
172
+ hash: 13
173
+ segments:
174
+ - 0
175
+ - 5
176
+ - 3
120
177
  version: 0.5.3
121
178
  type: :runtime
122
- prerelease: false
123
- version_requirements: *70193604311460
124
- - !ruby/object:Gem::Dependency
179
+ version_requirements: *id010
180
+ - !ruby/object:Gem::Dependency
125
181
  name: fssm
126
- requirement: &70193604309980 !ruby/object:Gem::Requirement
182
+ prerelease: false
183
+ requirement: &id011 !ruby/object:Gem::Requirement
127
184
  none: false
128
- requirements:
129
- - - =
130
- - !ruby/object:Gem::Version
185
+ requirements:
186
+ - - ~>
187
+ - !ruby/object:Gem::Version
188
+ hash: 25
189
+ segments:
190
+ - 0
191
+ - 2
192
+ - 7
131
193
  version: 0.2.7
132
194
  type: :runtime
195
+ version_requirements: *id011
196
+ - !ruby/object:Gem::Dependency
197
+ name: json
133
198
  prerelease: false
134
- version_requirements: *70193604309980
199
+ requirement: &id012 !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ~>
203
+ - !ruby/object:Gem::Version
204
+ hash: 5
205
+ segments:
206
+ - 1
207
+ - 6
208
+ - 5
209
+ version: 1.6.5
210
+ type: :runtime
211
+ version_requirements: *id012
135
212
  description: Awestruct is a framework for creating static HTML sites.
136
213
  email: bob@mcwhirter.org
137
- executables:
214
+ executables:
138
215
  - awestruct
139
216
  extensions: []
217
+
140
218
  extra_rdoc_files: []
141
- files:
219
+
220
+ files:
142
221
  - lib/awestruct/commands/deploy.rb
143
222
  - lib/awestruct/commands/frameworks/base_pipeline.rb
144
223
  - lib/awestruct/commands/generate.rb
@@ -160,6 +239,7 @@ files:
160
239
  - lib/awestruct/extensions/gsub.rb
161
240
  - lib/awestruct/extensions/indexifier.rb
162
241
  - lib/awestruct/extensions/intense_debate.rb
242
+ - lib/awestruct/extensions/minify.rb
163
243
  - lib/awestruct/extensions/obfuscate.rb
164
244
  - lib/awestruct/extensions/paginator.rb
165
245
  - lib/awestruct/extensions/partial.rb
@@ -198,26 +278,36 @@ files:
198
278
  - bin/awestruct
199
279
  homepage: http://awestruct.org
200
280
  licenses: []
281
+
201
282
  post_install_message:
202
283
  rdoc_options: []
203
- require_paths:
284
+
285
+ require_paths:
204
286
  - lib
205
- required_ruby_version: !ruby/object:Gem::Requirement
287
+ required_ruby_version: !ruby/object:Gem::Requirement
206
288
  none: false
207
- requirements:
208
- - - ! '>='
209
- - !ruby/object:Gem::Version
210
- version: '0'
211
- required_rubygems_version: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ hash: 3
293
+ segments:
294
+ - 0
295
+ version: "0"
296
+ required_rubygems_version: !ruby/object:Gem::Requirement
212
297
  none: false
213
- requirements:
214
- - - ! '>='
215
- - !ruby/object:Gem::Version
216
- version: '0'
298
+ requirements:
299
+ - - ">="
300
+ - !ruby/object:Gem::Version
301
+ hash: 3
302
+ segments:
303
+ - 0
304
+ version: "0"
217
305
  requirements: []
306
+
218
307
  rubyforge_project:
219
308
  rubygems_version: 1.8.10
220
309
  signing_key:
221
310
  specification_version: 3
222
311
  summary: Static site-baking utility
223
312
  test_files: []
313
+