yuicompressor 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/yuicompressor.rb +8 -0
- data/lib/yuicompressor/shell.rb +5 -10
- data/test/js_test.rb +6 -0
- data/yuicompressor.gemspec +2 -2
- metadata +2 -2
data/lib/yuicompressor.rb
CHANGED
|
@@ -64,6 +64,14 @@ module YUICompressor
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def stringify(stream_or_string) #:nodoc:
|
|
68
|
+
case stream_or_string
|
|
69
|
+
when IO then stream_or_string.read
|
|
70
|
+
when String then stream_or_string
|
|
71
|
+
else raise ArgumentError, 'Stream or string required'
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
67
75
|
# If we're on JRuby we can use the YUI Compressor Java classes directly. This
|
|
68
76
|
# gives a huge speed boost. Otherwise we need to make a system call to the
|
|
69
77
|
# Java interpreter and stream IO to/from the shell.
|
data/lib/yuicompressor/shell.rb
CHANGED
|
@@ -38,7 +38,7 @@ module YUICompressor
|
|
|
38
38
|
def compress(stream_or_string, options={})
|
|
39
39
|
raise ArgumentError, 'Option :type required' unless options.key?(:type)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
string = stringify(stream_or_string)
|
|
42
42
|
|
|
43
43
|
case options[:type].to_s
|
|
44
44
|
when 'js'
|
|
@@ -52,15 +52,10 @@ module YUICompressor
|
|
|
52
52
|
command = [ options.delete(:java) || 'java', '-jar', JAR_FILE ]
|
|
53
53
|
command.concat(command_arguments(options))
|
|
54
54
|
|
|
55
|
-
Open3.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
input.close_write
|
|
59
|
-
|
|
60
|
-
output.read
|
|
61
|
-
rescue Exception => e
|
|
62
|
-
raise 'Compression failed: %s' % e
|
|
63
|
-
end
|
|
55
|
+
stdout_str, stderr_str, status = Open3.capture3(command.join(' '), stdin_data: string, binmode: true)
|
|
56
|
+
unless status.success?
|
|
57
|
+
raise "Compression failed: #{stderr_str}"
|
|
64
58
|
end
|
|
59
|
+
stdout_str
|
|
65
60
|
end
|
|
66
61
|
end
|
data/test/js_test.rb
CHANGED
|
@@ -86,4 +86,10 @@ CODE
|
|
|
86
86
|
def test_large_stream
|
|
87
87
|
assert compress_js(File.new(File.expand_path('../_files/jquery-1.4.2.js', __FILE__), 'r'))
|
|
88
88
|
end
|
|
89
|
+
|
|
90
|
+
def test_error_reporting
|
|
91
|
+
assert_raises RuntimeError do
|
|
92
|
+
compress_js('function() {;') # syntax error
|
|
93
|
+
end
|
|
94
|
+
end
|
|
89
95
|
end
|
data/yuicompressor.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'yuicompressor'
|
|
3
|
-
s.version = '1.3.
|
|
4
|
-
s.date = '2014-01
|
|
3
|
+
s.version = '1.3.3'
|
|
4
|
+
s.date = '2014-03-01'
|
|
5
5
|
|
|
6
6
|
s.summary = 'A YUI JavaScript and CSS compressor for Ruby and JRuby'
|
|
7
7
|
s.description = 'A YUI JavaScript and CSS compressor for Ruby and JRuby'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yuicompressor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-01
|
|
12
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|