yui-compressor 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yui/compressor.rb +4 -0
- data/test/compressor_test.rb +9 -0
- metadata +4 -4
data/lib/yui/compressor.rb
CHANGED
@@ -5,6 +5,8 @@ module YUI #:nodoc:
|
|
5
5
|
class Compressor
|
6
6
|
VERSION = "0.9.4"
|
7
7
|
|
8
|
+
YUI_ERROR_MARKER = '[ERROR]'
|
9
|
+
|
8
10
|
class Error < StandardError; end
|
9
11
|
class OptionError < Error; end
|
10
12
|
class RuntimeError < Error; end
|
@@ -64,6 +66,8 @@ module YUI #:nodoc:
|
|
64
66
|
stdin.binmode
|
65
67
|
transfer(stream, stdin)
|
66
68
|
|
69
|
+
raise if stderr.read.include?(YUI_ERROR_MARKER)
|
70
|
+
|
67
71
|
if block_given?
|
68
72
|
yield stdout
|
69
73
|
else
|
data/test/compressor_test.rb
CHANGED
@@ -33,6 +33,8 @@ module YUI
|
|
33
33
|
}
|
34
34
|
})("hello");
|
35
35
|
END_JS
|
36
|
+
|
37
|
+
FIXTURE_ERROR_JS = "var x = {class: 'name'};"
|
36
38
|
|
37
39
|
def test_compressor_should_raise_when_instantiated
|
38
40
|
assert_raises YUI::Compressor::Error do
|
@@ -95,5 +97,12 @@ module YUI
|
|
95
97
|
@compressor = YUI::JavaScriptCompressor.new(:preserve_semicolons => true)
|
96
98
|
assert_equal "var Foo={a:1};Foo.bar=(function(baz){if(false){doSomething();}else{for(var index=0;index<baz.length;index++){doSomething(baz[index]);}}})(\"hello\");", @compressor.compress(FIXTURE_JS)
|
97
99
|
end
|
100
|
+
|
101
|
+
def test_compress_should_raise_on_javascript_syntax_error
|
102
|
+
@compressor = YUI::JavaScriptCompressor.new
|
103
|
+
assert_raise YUI::Compressor::RuntimeError do
|
104
|
+
@compressor.compress(FIXTURE_ERROR_JS)
|
105
|
+
end
|
106
|
+
end
|
98
107
|
end
|
99
108
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yui-compressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 5
|
10
|
+
version: 0.9.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Stephenson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-29 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|