htmlcompressor 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ 0.0.4 - 16/01/2013
2
+ Preserve empty textarea (issue #3)
1
3
  0.0.3 - 18/05/2012
2
4
  Added customizable options to rack middlewar
3
5
  0.0.2
data/README.md CHANGED
@@ -14,8 +14,8 @@ Please note that Htmlcompressor is still in alpha version and need some addition
14
14
  Using the compressor class is straightforward:
15
15
 
16
16
  ```ruby
17
- compressor = HtmlCompressor.Compressor.new
18
- compressor.compile('<html><body><div id="compress_me"></div></body></html>')
17
+ compressor = HtmlCompressor::Compressor.new
18
+ compressor.compress('<html><body><div id="compress_me"></div></body></html>')
19
19
  ```
20
20
 
21
21
  The compressor ships with some default option that may be overwritten passing the options hash to the constructor:
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.add_dependency 'yui-compressor', '~> 0.9.6'
12
12
  gem.add_development_dependency 'closure-compiler', '~> 1.1.5'
13
13
  gem.add_development_dependency 'rake'
14
+ gem.add_development_dependency 'minitest'
14
15
 
15
16
  gem.files = `git ls-files`.split($\)
16
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -303,13 +303,15 @@ module HtmlCompressor
303
303
  # preserve TEXTAREA tags
304
304
  index = -1
305
305
  html = html.gsub(TA_PATTERN) do |match|
306
+ index += 1
307
+
306
308
  if $2.strip.length > 0
307
309
  taBlocks << $2
308
- index += 1
309
- $1 + message_format(TEMP_TEXT_AREA_BLOCK, index) + $3
310
310
  else
311
- ''
311
+ taBlocks << ''
312
312
  end
313
+
314
+ $1 + message_format(TEMP_TEXT_AREA_BLOCK, index) + $3
313
315
  end
314
316
 
315
317
  # preserve line breaks
@@ -1,3 +1,3 @@
1
1
  module HtmlCompressor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -237,6 +237,15 @@ module HtmlCompressor
237
237
  assert_equal result, compressor.compress(source)
238
238
  end
239
239
 
240
+ def test_preserve_textarea
241
+ source = read_resource("testPreserveTextareas.html")
242
+ result = read_resource("testPreserveTextareasResult.html")
243
+
244
+ compressor = Compressor.new
245
+
246
+ assert_equal result, compressor.compress(source)
247
+ end
248
+
240
249
  private
241
250
 
242
251
  def resource_path
@@ -1,4 +1,4 @@
1
- <a x="aaa 'bbb' ccc" b="1"> <b onclick = " alert('<a> <b>') " /> <c/>
1
+ <a x="aaa 'bbb' ccc" b="1"> <b onclick = " alert('<a> <b>') " /> <c/>
2
2
  <d />
3
3
  <pre a = " 1 "> <x /> <y> </pre>
4
4
  <!-- comment -->
@@ -7,4 +7,5 @@
7
7
  <textarea> <!-- comment --> </textarea>
8
8
  <script> <!-- comment --> </script>
9
9
  <script type="text/x-jquery-tmpl"> <a> <!-- comment --> <b> </script>
10
- <style> <!-- comment --> </style>
10
+ <style> <!-- comment --> </style>
11
+ <textarea></textarea>
@@ -1 +1 @@
1
- <a x="aaa 'bbb' ccc" b="1"> <b onclick=" alert('<a> <b>') "/> <c/> <d/> <pre a=" 1 "> <x /> <y> </pre> <!--[if lt IE 7 ]><body class="ie6"><![endif]--> <!--[if lt IE 7 ]><body class="ie6"><![endif]--> <pre> <!-- comment --> </pre> <textarea> <!-- comment --> </textarea> <script> <!-- comment --> </script> <script type="text/x-jquery-tmpl"> <a> <b> </script> <style> <!-- comment --> </style>
1
+ <a x="aaa 'bbb' ccc" b="1"> <b onclick=" alert('<a> <b>') "/> <c/> <d/> <pre a=" 1 "> <x /> <y> </pre> <!--[if lt IE 7 ]><body class="ie6"><![endif]--> <!--[if lt IE 7 ]><body class="ie6"><![endif]--> <pre> <!-- comment --> </pre> <textarea> <!-- comment --> </textarea> <script> <!-- comment --> </script> <script type="text/x-jquery-tmpl"> <a> <b> </script> <style> <!-- comment --> </style> <textarea></textarea>
@@ -0,0 +1,2 @@
1
+ <textarea rows="10"> content </textarea>
2
+ <textarea></textarea>
@@ -0,0 +1 @@
1
+ <textarea rows="10"> content </textarea> <textarea></textarea>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlcompressor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-18 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yui-compressor
16
- requirement: &2152417880 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.9.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152417880
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.6
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: closure-compiler
27
- requirement: &2152433740 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,31 @@ dependencies:
32
37
  version: 1.1.5
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2152433740
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.5
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &2152433360 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: minitest
64
+ requirement: !ruby/object:Gem::Requirement
39
65
  none: false
40
66
  requirements:
41
67
  - - ! '>='
@@ -43,7 +69,12 @@ dependencies:
43
69
  version: '0'
44
70
  type: :development
45
71
  prerelease: false
46
- version_requirements: *2152433360
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
47
78
  description: Put your html on a diet
48
79
  email:
49
80
  - chiodi84@gmail.com
@@ -131,6 +162,8 @@ files:
131
162
  - test/resources/html/testPreserveLineBreaksResult.html
132
163
  - test/resources/html/testPreservePatterns.html
133
164
  - test/resources/html/testPreservePatternsResult.html
165
+ - test/resources/html/testPreserveTextareas.html
166
+ - test/resources/html/testPreserveTextareasResult.html
134
167
  - test/resources/html/testRemoveComments.html
135
168
  - test/resources/html/testRemoveCommentsResult.html
136
169
  - test/resources/html/testRemoveFormAttributes.html
@@ -193,21 +226,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
226
  - - ! '>='
194
227
  - !ruby/object:Gem::Version
195
228
  version: '0'
196
- segments:
197
- - 0
198
- hash: -1615621865656681193
199
229
  required_rubygems_version: !ruby/object:Gem::Requirement
200
230
  none: false
201
231
  requirements:
202
232
  - - ! '>='
203
233
  - !ruby/object:Gem::Version
204
234
  version: '0'
205
- segments:
206
- - 0
207
- hash: -1615621865656681193
208
235
  requirements: []
209
236
  rubyforge_project:
210
- rubygems_version: 1.8.15
237
+ rubygems_version: 1.8.23
211
238
  signing_key:
212
239
  specification_version: 3
213
240
  summary: htmlcompressor provides a class and a rack middleware to minify html pages
@@ -281,6 +308,8 @@ test_files:
281
308
  - test/resources/html/testPreserveLineBreaksResult.html
282
309
  - test/resources/html/testPreservePatterns.html
283
310
  - test/resources/html/testPreservePatternsResult.html
311
+ - test/resources/html/testPreserveTextareas.html
312
+ - test/resources/html/testPreserveTextareasResult.html
284
313
  - test/resources/html/testRemoveComments.html
285
314
  - test/resources/html/testRemoveCommentsResult.html
286
315
  - test/resources/html/testRemoveFormAttributes.html