juicer 1.0.16 → 1.0.17
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/Gemfile.lock +27 -11
- data/History.txt +3 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/juicer.rb +1 -1
- data/lib/juicer/install/yui_compressor_installer.rb +2 -2
- metadata +29 -113
- data/GPATH +0 -0
- data/GRTAGS +0 -0
- data/GSYMS +0 -0
- data/GTAGS +0 -0
- data/test/bin/jslint-1.0.js +0 -523
- data/test/bin/jslint.js +0 -523
- data/test/bin/rhino1_7R1.zip +0 -0
- data/test/bin/rhino1_7R2-RC1.jar +0 -0
- data/test/bin/rhino1_7R2-RC1.zip +0 -0
- data/test/bin/rhino1_7R3.jar +0 -0
- data/test/bin/rhino1_7R3.zip +0 -0
- data/test/bin/yuicompressor +0 -0
- data/test/bin/yuicompressor-2.3.5.zip +0 -0
- data/test/bin/yuicompressor-2.4.2.jar +0 -0
- data/test/bin/yuicompressor-2.4.2.zip +0 -0
- data/test/data/Changelog.txt +0 -10
- data/test/data/a.css +0 -3
- data/test/data/a.js +0 -5
- data/test/data/a1.css +0 -5
- data/test/data/b.css +0 -1
- data/test/data/b.js +0 -5
- data/test/data/b1.css +0 -5
- data/test/data/b2.css +0 -5
- data/test/data/c1.css +0 -3
- data/test/data/css/2.gif +0 -1
- data/test/data/css/test.css +0 -15
- data/test/data/css/test2.css +0 -1
- data/test/data/css/test3.css +0 -12
- data/test/data/d1.css +0 -3
- data/test/data/images/1.png +0 -1
- data/test/data/my_app.js +0 -2
- data/test/data/not-ok.js +0 -2
- data/test/data/ok.js +0 -3
- data/test/data/path_test.css +0 -5
- data/test/data/path_test2.css +0 -14
- data/test/data/pkg/module/moda.js +0 -2
- data/test/data/pkg/module/modb.js +0 -3
- data/test/data/pkg/pkg.js +0 -1
- data/test/fixtures/rhino-download.html +0 -42
- data/test/fixtures/yui-download.html +0 -375
- data/test/test_helper.rb +0 -204
- data/test/unit/juicer/asset/path_resolver_test.rb +0 -76
- data/test/unit/juicer/asset/path_test.rb +0 -376
- data/test/unit/juicer/cache_buster_test.rb +0 -128
- data/test/unit/juicer/chainable_test.rb +0 -94
- data/test/unit/juicer/command/install_test.rb +0 -58
- data/test/unit/juicer/command/list_test.rb +0 -81
- data/test/unit/juicer/command/merge_test.rb +0 -162
- data/test/unit/juicer/command/util_test.rb +0 -58
- data/test/unit/juicer/command/verify_test.rb +0 -48
- data/test/unit/juicer/css_cache_buster_test.rb +0 -122
- data/test/unit/juicer/datafy_test.rb +0 -37
- data/test/unit/juicer/dependency_resolver/css_dependency_resolver_test.rb +0 -36
- data/test/unit/juicer/dependency_resolver/javascript_dependency_resolver_test.rb +0 -50
- data/test/unit/juicer/ext/string_test.rb +0 -59
- data/test/unit/juicer/ext/symbol_test.rb +0 -27
- data/test/unit/juicer/image_embed_test.rb +0 -339
- data/test/unit/juicer/install/installer_base_test.rb +0 -214
- data/test/unit/juicer/install/jslint_installer_test.rb +0 -54
- data/test/unit/juicer/install/rhino_installer_test.rb +0 -57
- data/test/unit/juicer/install/yui_compressor_test.rb +0 -56
- data/test/unit/juicer/jslint_test.rb +0 -60
- data/test/unit/juicer/merger/base_test.rb +0 -122
- data/test/unit/juicer/merger/javascript_merger_test.rb +0 -74
- data/test/unit/juicer/merger/stylesheet_merger_test.rb +0 -262
- data/test/unit/juicer/minifyer/closure_compressor_test.rb +0 -107
- data/test/unit/juicer/minifyer/yui_compressor_test.rb +0 -133
- data/test/unit/juicer_test.rb +0 -1
@@ -1,74 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestJavaScriptMerger < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
@file_merger = Juicer::Merger::JavaScriptMerger.new
|
7
|
-
Juicer::Test::FileSetup.new.create
|
8
|
-
end
|
9
|
-
|
10
|
-
def teardown
|
11
|
-
file = path('test_out.js')
|
12
|
-
File.delete(file) if File.exists?(file)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_init
|
16
|
-
Juicer::Merger::JavaScriptMerger.publicize_methods do
|
17
|
-
assert_equal Juicer::JavaScriptDependencyResolver, @file_merger.dependency_resolver.class
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_merge
|
22
|
-
Juicer::Merger::JavaScriptMerger.publicize_methods do
|
23
|
-
a_content = <<EOF
|
24
|
-
/**
|
25
|
-
* @depend b.js
|
26
|
-
*/
|
27
|
-
|
28
|
-
/* Dette er a.js */
|
29
|
-
|
30
|
-
EOF
|
31
|
-
content = @file_merger.merge(path('a.js'))
|
32
|
-
assert_equal a_content, content
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_constructor
|
37
|
-
file_merger = Juicer::Merger::JavaScriptMerger.new(path('a.js'))
|
38
|
-
assert_equal 2, file_merger.files.length
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_append
|
42
|
-
@file_merger << path('a.js')
|
43
|
-
assert_equal 2, @file_merger.files.length
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_save
|
47
|
-
a_js = path('a.js')
|
48
|
-
b_js = path('b.js')
|
49
|
-
merged = <<EOF
|
50
|
-
/**
|
51
|
-
* @depends a.js
|
52
|
-
*/
|
53
|
-
|
54
|
-
/* Dette er b.css */
|
55
|
-
|
56
|
-
/**
|
57
|
-
* @depend b.js
|
58
|
-
*/
|
59
|
-
|
60
|
-
/* Dette er a.js */
|
61
|
-
|
62
|
-
EOF
|
63
|
-
|
64
|
-
@file_merger << a_js
|
65
|
-
ios = StringIO.new
|
66
|
-
@file_merger.save(ios)
|
67
|
-
assert_equal merged, ios.string
|
68
|
-
|
69
|
-
output_file = path('test_out.js')
|
70
|
-
@file_merger.save(output_file)
|
71
|
-
|
72
|
-
assert_equal merged, IO.read(output_file)
|
73
|
-
end
|
74
|
-
end
|
@@ -1,262 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestStylesheetMerger < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@file_merger = Juicer::Merger::StylesheetMerger.new
|
6
|
-
Juicer::Test::FileSetup.new.create
|
7
|
-
@cwd = Dir.pwd
|
8
|
-
Dir.chdir path("")
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
file = path('test_out.css')
|
13
|
-
File.delete(file) if File.exists?(file)
|
14
|
-
Dir.chdir(@cwd)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "stylesheet merger" do
|
18
|
-
should "keep reference to css dependency resolver" do
|
19
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
20
|
-
resolver = @file_merger.dependency_resolver
|
21
|
-
|
22
|
-
assert_equal Juicer::CssDependencyResolver, resolver.class
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
should "merge single file" do
|
27
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
28
|
-
a_content = "\n\n/* Dette er a.css */\n"
|
29
|
-
content = @file_merger.merge(path('a.css'))
|
30
|
-
|
31
|
-
assert_equal a_content + "\n", content
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
should "recognize all files" do
|
36
|
-
file_merger = Juicer::Merger::StylesheetMerger.new(path('a.css'))
|
37
|
-
|
38
|
-
assert_equal 2, file_merger.files.length
|
39
|
-
end
|
40
|
-
|
41
|
-
should "not append existing file" do
|
42
|
-
@file_merger << path('a.css')
|
43
|
-
assert_equal 2, @file_merger.files.length
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "saving files" do
|
48
|
-
should "merge files and strip @includes" do
|
49
|
-
a_css = path('a.css')
|
50
|
-
b_css = path('b.css')
|
51
|
-
merged = <<EOF
|
52
|
-
/* Dette er b.css */
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
/* Dette er a.css */
|
57
|
-
|
58
|
-
EOF
|
59
|
-
|
60
|
-
@file_merger << a_css
|
61
|
-
ios = StringIO.new
|
62
|
-
@file_merger.save(ios)
|
63
|
-
assert_equal merged, ios.string
|
64
|
-
|
65
|
-
output_file = path('test_out.css')
|
66
|
-
@file_merger.save(output_file)
|
67
|
-
|
68
|
-
assert_equal merged, IO.read(output_file)
|
69
|
-
end
|
70
|
-
|
71
|
-
should "strip @includes for quoted urls" do
|
72
|
-
css = path('b2.css')
|
73
|
-
|
74
|
-
merged = <<EOF
|
75
|
-
h2 {
|
76
|
-
font-size: 10px;
|
77
|
-
}
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
html {
|
82
|
-
background: red;
|
83
|
-
}
|
84
|
-
|
85
|
-
EOF
|
86
|
-
|
87
|
-
@file_merger << css
|
88
|
-
ios = StringIO.new
|
89
|
-
@file_merger.save(ios)
|
90
|
-
assert_equal merged, ios.string
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "resolving paths" do
|
95
|
-
should "re-reference relative paths" do
|
96
|
-
@file_merger << path("path_test.css")
|
97
|
-
ios = StringIO.new
|
98
|
-
@file_merger.save(ios)
|
99
|
-
files = ios.string.scan(/url\(([^\)]*)\)/).collect { |f| f.first }.uniq.sort
|
100
|
-
|
101
|
-
assert_equal "a1.css::css/2.gif::images/1.png", files.join("::")
|
102
|
-
end
|
103
|
-
|
104
|
-
should "not touch absolute urls" do
|
105
|
-
merger = Juicer::Merger::StylesheetMerger.new
|
106
|
-
url = "/some/url"
|
107
|
-
|
108
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
109
|
-
assert_equal url, merger.resolve_path(url, nil)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
should "raise when mapping absolute to relative path without document root" do
|
114
|
-
merger = Juicer::Merger::StylesheetMerger.new [], :relative_urls => true
|
115
|
-
|
116
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
117
|
-
assert_raise ArgumentError do
|
118
|
-
merger.resolve_path("/some/url", nil)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
should "make absolute urls relative" do
|
124
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
125
|
-
:relative_urls => true,
|
126
|
-
:document_root => "/home/usr")
|
127
|
-
|
128
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
129
|
-
merger.instance_eval { @root = Pathname.new "/home/usr/design" }
|
130
|
-
|
131
|
-
assert_equal "../some/url", merger.resolve_path("/some/url", nil)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
should "should leave full urls" do
|
136
|
-
merger = Juicer::Merger::StylesheetMerger.new []
|
137
|
-
url = "http://test.com"
|
138
|
-
|
139
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
140
|
-
merger.instance_eval { @root = Pathname.new "/home/usr/design" }
|
141
|
-
|
142
|
-
assert_equal url, merger.resolve_path(url, nil)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
should "error when missing document root for absolute urls" do
|
147
|
-
merger = Juicer::Merger::StylesheetMerger.new [], :absolute_urls => true
|
148
|
-
|
149
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
150
|
-
assert_raise ArgumentError do
|
151
|
-
merger.resolve_path("../some/url", nil)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
should "make relative urls absolute" do
|
157
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
158
|
-
:absolute_urls => true,
|
159
|
-
:document_root => "/home/usr")
|
160
|
-
|
161
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
162
|
-
merger.instance_eval { @root = Pathname.new "/home/usr/design" }
|
163
|
-
assert_equal "/design/images/1.png", merger.resolve_path("../images/1.png", "/home/usr/design/css")
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
should "redefine relative urls" do
|
168
|
-
merger = Juicer::Merger::StylesheetMerger.new [], :relative_urls => true
|
169
|
-
|
170
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
171
|
-
merger.instance_eval { @root = Pathname.new "/home/usr/design2/css" }
|
172
|
-
assert_equal "../../design/images/1.png", merger.resolve_path("../images/1.png", "/home/usr/design/css")
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
should "redefine absolute urls" do
|
177
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
178
|
-
:relative_urls => true,
|
179
|
-
:document_root => "/home/usr")
|
180
|
-
|
181
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
182
|
-
merger.instance_eval { @root = Pathname.new "/home/usr/design2/css" }
|
183
|
-
result = merger.resolve_path("/images/1.png", "/home/usr/design/css")
|
184
|
-
|
185
|
-
assert_equal "../../images/1.png", result
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
should "cycle asset hosts" do
|
190
|
-
hosts = ["http://assets1", "http://assets2", "http://assets3"]
|
191
|
-
merger = Juicer::Merger::StylesheetMerger.new([], :hosts => hosts)
|
192
|
-
|
193
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
194
|
-
merger.instance_eval do
|
195
|
-
@root = Pathname.new "/home/usr/design2/css"
|
196
|
-
end
|
197
|
-
|
198
|
-
assert_equal "http://assets1/images/1.png", merger.resolve_path("/images/1.png", nil)
|
199
|
-
assert_equal "http://assets2/images/1.png", merger.resolve_path("/images/1.png", nil)
|
200
|
-
assert_equal "http://assets3/images/1.png", merger.resolve_path("/images/1.png", nil)
|
201
|
-
assert_equal "http://assets1/images/1.png", merger.resolve_path("/images/1.png", nil)
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
should "handle relative document roots" do
|
206
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
207
|
-
:document_root => "test/data",
|
208
|
-
:relative_urls => true)
|
209
|
-
merger << File.expand_path("css/test2.css")
|
210
|
-
|
211
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
212
|
-
merger.instance_eval do
|
213
|
-
@root = Pathname.new File.expand_path("test/data/css")
|
214
|
-
end
|
215
|
-
|
216
|
-
assert_equal "../images/1.png", merger.resolve_path("/images/1.png", nil)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
should "leave data URLs untouched" do
|
221
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
222
|
-
:document_root => "test/data",
|
223
|
-
:hosts => ["http://assets1/"])
|
224
|
-
merger << File.expand_path("path_test2.css")
|
225
|
-
|
226
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
227
|
-
merger.instance_eval do
|
228
|
-
@root = Pathname.new(File.expand_path("test/data/css"))
|
229
|
-
end
|
230
|
-
|
231
|
-
expected = "data:image/png;base64,ERJW"
|
232
|
-
assert_equal expected, merger.resolve_path("data:image/png;base64,ERJW", "test/data/css")
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
should "cycle hosts for relative urls" do
|
237
|
-
merger = Juicer::Merger::StylesheetMerger.new([],
|
238
|
-
:document_root => "test/data",
|
239
|
-
:hosts => ["http://assets1/"])
|
240
|
-
merger << File.expand_path("path_test2.css")
|
241
|
-
|
242
|
-
Juicer::Merger::StylesheetMerger.publicize_methods do
|
243
|
-
merger.instance_eval do
|
244
|
-
@root = Pathname.new(File.expand_path("test/data/css"))
|
245
|
-
end
|
246
|
-
|
247
|
-
expected = "http://assets1/images/1.png"
|
248
|
-
assert_equal expected, merger.resolve_path("../images/1.png", "test/data/css")
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
should "use same host for same url when cycling asset hosts" do
|
253
|
-
@file_merger = Juicer::Merger::StylesheetMerger.new nil, :hosts => ["http://assets1", "http://assets2", "http://assets3"]
|
254
|
-
@file_merger << path("path_test2.css")
|
255
|
-
ios = StringIO.new
|
256
|
-
@file_merger.save(ios)
|
257
|
-
files = ios.string.scan(/url\(([^\)]*)\)/).collect { |f| f.first }
|
258
|
-
|
259
|
-
assert_equal "1/images/1.png::2/css/2.gif::3/a1.css::2/css/2.gif::1/a2.css".gsub(/(\d\/)/, 'http://assets\1'), files.join("::")
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
require "juicer/minifyer/closure_compiler"
|
3
|
-
|
4
|
-
class ClosureCompilerTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@jar = "compiler.jar"
|
7
|
-
@input = "in-file.css"
|
8
|
-
@output = "out-file.css"
|
9
|
-
@cmd = %Q{-jar "#@jar"}
|
10
|
-
@closure = Juicer::Minifyer::ClosureCompiler.new
|
11
|
-
@closure.stubs(:locate_jar).returns(@jar)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "#save" do
|
15
|
-
should "overwrite existing file" do
|
16
|
-
@closure.expects(:execute).with(%Q{#@cmd --js_output_file "#@output" --js "#@output"})
|
17
|
-
@closure.save(@output, @output)
|
18
|
-
end
|
19
|
-
|
20
|
-
should "write compressed input to output" do
|
21
|
-
@closure.expects(:execute).with(%Q{#@cmd --js_output_file "#@output" --js "#@input"})
|
22
|
-
@closure.save(@input, @output)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "create non-existant path" do
|
26
|
-
output = "some/nested/directory"
|
27
|
-
@closure.expects(:execute).with(%Q{#@cmd --js_output_file "#{output}/file.css" --js "#@input"})
|
28
|
-
FileUtils.expects(:mkdir_p).with(output)
|
29
|
-
@closure.save(@input, "#{output}/file.css")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "locating jar" do
|
34
|
-
setup do
|
35
|
-
# Avoid developer env settings
|
36
|
-
@closure_home = ENV['CLOSUREC_HOME']
|
37
|
-
ENV.delete('CLOSUREC_HOME')
|
38
|
-
end
|
39
|
-
|
40
|
-
teardown do
|
41
|
-
ENV['CLOSUREC_HOME'] = @closure_home
|
42
|
-
File.delete('compiler-2.3.4.jar') if File.exists?('compiler-2.3.4.jar')
|
43
|
-
File.delete('compiler-2.3.5.jar') if File.exists?('compiler-2.3.5.jar')
|
44
|
-
File.delete('compiler.jar') if File.exists?('compiler.jar')
|
45
|
-
FileUtils.rm_rf("another") if File.exists?("another")
|
46
|
-
end
|
47
|
-
|
48
|
-
should "not find jar when no jars on path" do
|
49
|
-
Juicer::Minifyer::ClosureCompiler.publicize_methods do
|
50
|
-
closure = Juicer::Minifyer::ClosureCompiler.new
|
51
|
-
|
52
|
-
assert_nil closure.locate_jar
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
should "find only jar in path" do
|
57
|
-
Juicer::Minifyer::ClosureCompiler.publicize_methods do
|
58
|
-
File.open('compiler-2.3.4.jar', 'w') { |f| f.puts '' }
|
59
|
-
closure = Juicer::Minifyer::ClosureCompiler.new
|
60
|
-
|
61
|
-
assert_equal File.expand_path('compiler-2.3.4.jar'), closure.locate_jar
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
should "find most recent of two jars on path" do
|
66
|
-
Juicer::Minifyer::ClosureCompiler.publicize_methods do
|
67
|
-
# Create files
|
68
|
-
File.open('compiler-2.3.4.jar', 'w') { |f| f.puts '' }
|
69
|
-
File.open('compiler-2.3.5.jar', 'w') { |f| f.puts '' }
|
70
|
-
|
71
|
-
closure = Juicer::Minifyer::ClosureCompiler.new
|
72
|
-
|
73
|
-
# Test
|
74
|
-
assert_equal File.expand_path('compiler-2.3.5.jar'), closure.locate_jar
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
should "find most recent of three jar files on path" do
|
79
|
-
Juicer::Minifyer::ClosureCompiler.publicize_methods do
|
80
|
-
# Create files
|
81
|
-
File.open('compiler-2.3.4.jar', 'w') { |f| f.puts '' }
|
82
|
-
File.open('compiler-2.3.5.jar', 'w') { |f| f.puts '' }
|
83
|
-
File.open('compiler.jar', 'w') { |f| f.puts '' }
|
84
|
-
|
85
|
-
closure = Juicer::Minifyer::ClosureCompiler.new
|
86
|
-
|
87
|
-
# Test
|
88
|
-
assert_equal File.expand_path('compiler.jar'), closure.locate_jar
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
should "find jar in custom directory" do
|
93
|
-
Juicer::Minifyer::ClosureCompiler.publicize_methods do
|
94
|
-
# Prepare
|
95
|
-
Dir.mkdir('another')
|
96
|
-
File.open('another/compiler-2.3.4.jar', 'w') { |f| f.puts "" }
|
97
|
-
|
98
|
-
closure = Juicer::Minifyer::ClosureCompiler.new
|
99
|
-
|
100
|
-
# Test
|
101
|
-
assert_nil closure.locate_jar
|
102
|
-
closure = Juicer::Minifyer::ClosureCompiler.new({ :bin_path => 'another' })
|
103
|
-
assert_equal File.expand_path('another/compiler-2.3.4.jar'), closure.locate_jar
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class TestYuiCompressor < Test::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@jar = "yuicompressor-2.4.2.jar"
|
6
|
-
@input = "in-file.css"
|
7
|
-
@output = "out-file.css"
|
8
|
-
@cmd = %Q{-jar "#@jar"}
|
9
|
-
@yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
10
|
-
@yui_compressor.stubs(:locate_jar).returns(@jar)
|
11
|
-
end
|
12
|
-
|
13
|
-
context "#save" do
|
14
|
-
should "overwrite existing file" do
|
15
|
-
@yui_compressor.expects(:execute).with(%Q{#@cmd -o "#@output" "#@output"})
|
16
|
-
@yui_compressor.save(@output)
|
17
|
-
end
|
18
|
-
|
19
|
-
should "use provided symbol type" do
|
20
|
-
@yui_compressor.expects(:execute).with(%Q{#@cmd -o "#@output" "#@input"})
|
21
|
-
@yui_compressor.save(@input, @output, :css)
|
22
|
-
end
|
23
|
-
|
24
|
-
should "use provided string type" do
|
25
|
-
@yui_compressor.expects(:execute).with(%Q{#@cmd -o "#@output" "#@input"})
|
26
|
-
@yui_compressor.save(@input, @output, "css")
|
27
|
-
end
|
28
|
-
|
29
|
-
should "write compressed input to output" do
|
30
|
-
@yui_compressor.expects(:execute).with(%Q{#@cmd -o "#@output" "#@input"})
|
31
|
-
@yui_compressor.save(@input, @output)
|
32
|
-
end
|
33
|
-
|
34
|
-
should "create non-existant path" do
|
35
|
-
output = "some/nested/directory"
|
36
|
-
@yui_compressor.expects(:execute).with(%Q{#@cmd -o "#{output}/file.css" "#@input"})
|
37
|
-
FileUtils.expects(:mkdir_p).with(output)
|
38
|
-
@yui_compressor.save(@input, "#{output}/file.css")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "locating jar" do
|
43
|
-
setup do
|
44
|
-
# Avoid developer env settings
|
45
|
-
@yuic_home = ENV['YUIC_HOME']
|
46
|
-
ENV.delete('YUIC_HOME')
|
47
|
-
end
|
48
|
-
|
49
|
-
teardown do
|
50
|
-
ENV['YUIC_HOME'] = @yuic_home
|
51
|
-
File.delete('yuicompressor-2.3.4.jar') if File.exists?('yuicompressor-2.3.4.jar')
|
52
|
-
File.delete('yuicompressor-2.3.5.jar') if File.exists?('yuicompressor-2.3.5.jar')
|
53
|
-
File.delete('yuicompressor.jar') if File.exists?('yuicompressor.jar')
|
54
|
-
FileUtils.rm_rf("another") if File.exists?("another")
|
55
|
-
FileUtils.rm_rf("athird") if File.exists?("athird")
|
56
|
-
end
|
57
|
-
|
58
|
-
should "not find jar when no jars on path" do
|
59
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
60
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
61
|
-
|
62
|
-
assert_nil yui_compressor.locate_jar
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
should "find only jar in path" do
|
67
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
68
|
-
File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
|
69
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
70
|
-
|
71
|
-
assert_equal File.expand_path('yuicompressor-2.3.4.jar'), yui_compressor.locate_jar
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
should "find most recent of two jars on path" do
|
76
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
77
|
-
# Create files
|
78
|
-
File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
|
79
|
-
File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
|
80
|
-
|
81
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
82
|
-
|
83
|
-
# Test
|
84
|
-
assert_equal File.expand_path('yuicompressor-2.3.5.jar'), yui_compressor.locate_jar
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
should "find most recent of three jar files on path" do
|
89
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
90
|
-
# Create files
|
91
|
-
File.open('yuicompressor-2.3.4.jar', 'w') { |f| f.puts '' }
|
92
|
-
File.open('yuicompressor-2.3.5.jar', 'w') { |f| f.puts '' }
|
93
|
-
File.open('yuicompressor.jar', 'w') { |f| f.puts '' }
|
94
|
-
|
95
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
96
|
-
|
97
|
-
# Test
|
98
|
-
assert_equal File.expand_path('yuicompressor.jar'), yui_compressor.locate_jar
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
should "find jar in custom directory" do
|
103
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
104
|
-
# Prepare
|
105
|
-
Dir.mkdir('another')
|
106
|
-
File.open('another/yuicompressor-2.3.4.jar', 'w') { |f| f.puts "" }
|
107
|
-
|
108
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
109
|
-
|
110
|
-
# Test
|
111
|
-
assert_nil yui_compressor.locate_jar
|
112
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => 'another' })
|
113
|
-
assert_equal File.expand_path('another/yuicompressor-2.3.4.jar'), yui_compressor.locate_jar
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
should "find jar in one of several custom directories" do
|
118
|
-
Juicer::Minifyer::YuiCompressor.publicize_methods do
|
119
|
-
# Prepare
|
120
|
-
Dir.mkdir('another')
|
121
|
-
Dir.mkdir('athird')
|
122
|
-
File.open('athird/yuicompressor-2.3.4.jar', 'w') { |f| f.puts "" }
|
123
|
-
|
124
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new
|
125
|
-
|
126
|
-
# Test
|
127
|
-
assert_nil yui_compressor.locate_jar
|
128
|
-
yui_compressor = Juicer::Minifyer::YuiCompressor.new({ :bin_path => ['another', 'athird'] })
|
129
|
-
assert_equal File.expand_path('athird/yuicompressor-2.3.4.jar'), yui_compressor.locate_jar
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|