juicer 0.2.0
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/History.txt +10 -0
- data/Manifest.txt +58 -0
- data/Rakefile +44 -0
- data/Readme.rdoc +143 -0
- data/bin/juicer +8 -0
- data/lib/juicer.rb +70 -0
- data/lib/juicer/binary.rb +173 -0
- data/lib/juicer/cache_buster.rb +45 -0
- data/lib/juicer/chainable.rb +106 -0
- data/lib/juicer/cli.rb +56 -0
- data/lib/juicer/command/install.rb +59 -0
- data/lib/juicer/command/list.rb +50 -0
- data/lib/juicer/command/merge.rb +185 -0
- data/lib/juicer/command/util.rb +32 -0
- data/lib/juicer/command/verify.rb +60 -0
- data/lib/juicer/core.rb +59 -0
- data/lib/juicer/css_cache_buster.rb +99 -0
- data/lib/juicer/install/base.rb +186 -0
- data/lib/juicer/install/jslint_installer.rb +51 -0
- data/lib/juicer/install/rhino_installer.rb +52 -0
- data/lib/juicer/install/yui_compressor_installer.rb +66 -0
- data/lib/juicer/jslint.rb +90 -0
- data/lib/juicer/merger/base.rb +74 -0
- data/lib/juicer/merger/css_dependency_resolver.rb +25 -0
- data/lib/juicer/merger/dependency_resolver.rb +82 -0
- data/lib/juicer/merger/javascript_dependency_resolver.rb +21 -0
- data/lib/juicer/merger/javascript_merger.rb +30 -0
- data/lib/juicer/merger/stylesheet_merger.rb +112 -0
- data/lib/juicer/minifyer/yui_compressor.rb +129 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +300 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/test/setup.rake +35 -0
- data/test/bin/jslint.js +474 -0
- data/test/bin/rhino1_7R1.zip +0 -0
- data/test/bin/rhino1_7R2-RC1.zip +0 -0
- data/test/bin/yuicompressor +238 -0
- data/test/bin/yuicompressor-2.3.5.zip +0 -0
- data/test/bin/yuicompressor-2.4.2.zip +0 -0
- data/test/juicer/command/test_install.rb +53 -0
- data/test/juicer/command/test_list.rb +69 -0
- data/test/juicer/command/test_merge.rb +155 -0
- data/test/juicer/command/test_util.rb +54 -0
- data/test/juicer/command/test_verify.rb +33 -0
- data/test/juicer/install/test_installer_base.rb +195 -0
- data/test/juicer/install/test_jslint_installer.rb +54 -0
- data/test/juicer/install/test_rhino_installer.rb +57 -0
- data/test/juicer/install/test_yui_compressor_installer.rb +56 -0
- data/test/juicer/merger/test_base.rb +122 -0
- data/test/juicer/merger/test_css_dependency_resolver.rb +36 -0
- data/test/juicer/merger/test_javascript_dependency_resolver.rb +39 -0
- data/test/juicer/merger/test_javascript_merger.rb +74 -0
- data/test/juicer/merger/test_stylesheet_merger.rb +178 -0
- data/test/juicer/minifyer/test_yui_compressor.rb +159 -0
- data/test/juicer/test_cache_buster.rb +58 -0
- data/test/juicer/test_chainable.rb +94 -0
- data/test/juicer/test_core.rb +47 -0
- data/test/juicer/test_css_cache_buster.rb +72 -0
- data/test/juicer/test_jslint.rb +33 -0
- data/test/test_helper.rb +146 -0
- data/test/test_juicer.rb +4 -0
- metadata +194 -0
Binary file
|
Binary file
|
@@ -0,0 +1,238 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Download the YUI Compressor</title>
|
5
|
+
<style>
|
6
|
+
|
7
|
+
/* reset.css */
|
8
|
+
|
9
|
+
body {color:#000;background:#FFF;}
|
10
|
+
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}
|
11
|
+
table{border-collapse:collapse;border-spacing:0;}
|
12
|
+
fieldset,img{border:0;}
|
13
|
+
address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}
|
14
|
+
li {list-style:none;}
|
15
|
+
caption,th {text-align:left;}
|
16
|
+
h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}
|
17
|
+
q:before,q:after{content:'';}
|
18
|
+
abbr,acronym {border:0;font-variant:normal;}
|
19
|
+
sup,sub {line-height:-1px;vertical-align: text-top;}
|
20
|
+
sub {vertical-align:text-bottom;}
|
21
|
+
input, textarea, select{font-family:inherit;font-size:inherit;font-weight:inherit;}
|
22
|
+
|
23
|
+
/* fonts.css */
|
24
|
+
|
25
|
+
body {font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
|
26
|
+
table {font-size:inherit;font:100%;}
|
27
|
+
pre,code,kbd,samp,tt {font-family:monospace;*font-size:108%;line-height:99%;}
|
28
|
+
|
29
|
+
/* button.css */
|
30
|
+
|
31
|
+
.yui-button{display:-moz-inline-box;display:inline-block;border-width:1px 0;border-style:solid;border-color:#999;background:#ecece3 url(background.png)left center;margin:auto .25em;}
|
32
|
+
.yui-button.ie6{background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../build/button/assets/background.png',sizingMethod = 'scale');}
|
33
|
+
.yui-button .first-child{display:block;*display:inline-block;border-width:0 1px;border-style:solid;border-color:#999;margin:0 -1px;*position:relative;*left:-1px;}
|
34
|
+
.yui-button button,.yui-button a{display:block;*display:inline-block;padding:.25em .5em;border:1px solid #ccc;}
|
35
|
+
.yui-button button{*overflow:visible;font-size:100%;background-color:transparent;cursor:pointer;cursor:hand;}
|
36
|
+
.yui-button a{text-decoration:none;color:#000;}
|
37
|
+
.yui-split-button button,.yui-menu-button button{padding-right:20px;background-position:right center;background-repeat:no-repeat;}
|
38
|
+
.yui-menu-button button{background-image:url(menuarrow.gif);}
|
39
|
+
.yui-split-button button{background-image:url(splitarrow.gif);}
|
40
|
+
.yui-button-focus{border-color:#5e5c95;}
|
41
|
+
.yui-button-focus .first-child{border-color:#5e5c95;}
|
42
|
+
.yui-button-focus button,.yui-button-focus a{border-color:#cec1fc;}
|
43
|
+
.yui-button-hover{border-color:#406fac;background-color:#98d5fc;}
|
44
|
+
.yui-button-hover .first-child{border-color:#406fac;}
|
45
|
+
.yui-button-hover button,.yui-button-hover a{border-color:#7099ce;}
|
46
|
+
.yui-button-active{border-color:#7a8180;background-color:#333;}
|
47
|
+
.yui-button-active .first-child{border-color:#7a8180;}
|
48
|
+
.yui-button-active button,.yui-button-active a{border-color:#98a09f;}
|
49
|
+
.yui-split-button-activeoption button{background-color:transparent;background-image:url(splitarrow_active.gif);}
|
50
|
+
.yui-radio-button-checked,.yui-checkbox-button-checked{border-color:#7a8180;background-color:#333;}
|
51
|
+
.yui-radio-button-checked .first-child,.yui-checkbox-button-checked .first-child{border-color:#7a8180;}
|
52
|
+
.yui-radio-button-checked button,.yui-checkbox-button-checked button{border-color:#98a09f;}
|
53
|
+
.yui-button-disabled{border-color:#cbcdc5;background:#ecece3;filter:none;}
|
54
|
+
.yui-button-disabled .first-child{border-color:#cbcdc5;}
|
55
|
+
.yui-button-disabled button,.yui-button-disabled a{border-color:transparent;color:#b9b9b9;cursor:default;}
|
56
|
+
|
57
|
+
/* custom css */
|
58
|
+
|
59
|
+
body { padding:1em; }
|
60
|
+
|
61
|
+
#downloadbutton a {
|
62
|
+
padding:.8em; padding-left:3em;
|
63
|
+
background:#deecf7 url(download.png) 4% 50% no-repeat;
|
64
|
+
font-size:1.5em;
|
65
|
+
font-weight:bold;
|
66
|
+
}
|
67
|
+
|
68
|
+
h3 {
|
69
|
+
margin:1em 0;
|
70
|
+
font-size:1.5em;
|
71
|
+
font-weight:bold;
|
72
|
+
}
|
73
|
+
|
74
|
+
ul {
|
75
|
+
margin-left:1em;
|
76
|
+
}
|
77
|
+
|
78
|
+
ul li {
|
79
|
+
list-style-type:disc;
|
80
|
+
}
|
81
|
+
</style>
|
82
|
+
</head>
|
83
|
+
<body>
|
84
|
+
|
85
|
+
<div id="doc">
|
86
|
+
|
87
|
+
<span id="downloadbutton" class="yui-button yui-link-button" style="margin-bottom:1em;">
|
88
|
+
<em class="first-child">
|
89
|
+
<a href="yuicompressor-2.4.2.zip">Download YUI Compressor version 2.4.2</a>
|
90
|
+
</em>
|
91
|
+
</span>
|
92
|
+
|
93
|
+
<h3>Documentation</h3>
|
94
|
+
|
95
|
+
<pre>==============================================================================
|
96
|
+
YUI Compressor
|
97
|
+
==============================================================================
|
98
|
+
|
99
|
+
NAME
|
100
|
+
|
101
|
+
YUI Compressor - The Yahoo! JavaScript and CSS Compressor
|
102
|
+
|
103
|
+
SYNOPSIS
|
104
|
+
|
105
|
+
Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]
|
106
|
+
|
107
|
+
Global Options
|
108
|
+
-h, --help Displays this information
|
109
|
+
--type <js|css> Specifies the type of the input file
|
110
|
+
--charset <charset> Read the input file using <charset>
|
111
|
+
--line-break <column> Insert a line break after the specified column number
|
112
|
+
-v, --verbose Display informational messages and warnings
|
113
|
+
-o <file> Place the output into <file>. Defaults to stdout.
|
114
|
+
|
115
|
+
JavaScript Options
|
116
|
+
--nomunge Minify only, do not obfuscate
|
117
|
+
--preserve-semi Preserve all semicolons
|
118
|
+
--disable-optimizations Disable all micro optimizations
|
119
|
+
|
120
|
+
DESCRIPTION
|
121
|
+
|
122
|
+
The YUI Compressor is a JavaScript compressor which, in addition to removing
|
123
|
+
comments and white-spaces, obfuscates local variables using the smallest
|
124
|
+
possible variable name. This obfuscation is safe, even when using constructs
|
125
|
+
such as 'eval' or 'with' (although the compression is not optimal is those
|
126
|
+
cases) Compared to jsmin, the average savings is around 20%.
|
127
|
+
|
128
|
+
The YUI Compressor is also able to safely compress CSS files. The decision
|
129
|
+
on which compressor is being used is made on the file extension (js or css)
|
130
|
+
|
131
|
+
GLOBAL OPTIONS
|
132
|
+
|
133
|
+
-h, --help
|
134
|
+
Prints help on how to use the YUI Compressor
|
135
|
+
|
136
|
+
--line-break
|
137
|
+
Some source control tools don't like files containing lines longer than,
|
138
|
+
say 8000 characters. The linebreak option is used in that case to split
|
139
|
+
long lines after a specific column. It can also be used to make the code
|
140
|
+
more readable, easier to debug (especially with the MS Script Debugger)
|
141
|
+
Specify 0 to get a line break after each semi-colon in JavaScript, and
|
142
|
+
after each rule in CSS.
|
143
|
+
|
144
|
+
--type js|css
|
145
|
+
The type of compressor (JavaScript or CSS) is chosen based on the
|
146
|
+
extension of the input file name (.js or .css) This option is required
|
147
|
+
if no input file has been specified. Otherwise, this option is only
|
148
|
+
required if the input file extension is neither 'js' nor 'css'.
|
149
|
+
|
150
|
+
--charset character-set
|
151
|
+
If a supported character set is specified, the YUI Compressor will use it
|
152
|
+
to read the input file. Otherwise, it will assume that the platform's
|
153
|
+
default character set is being used. The output file is encoded using
|
154
|
+
the same character set.
|
155
|
+
|
156
|
+
-o outfile
|
157
|
+
Place output in file outfile. If not specified, the YUI Compressor will
|
158
|
+
default to the standard output, which you can redirect to a file.
|
159
|
+
|
160
|
+
-v, --verbose
|
161
|
+
Display informational messages and warnings.
|
162
|
+
|
163
|
+
JAVASCRIPT ONLY OPTIONS
|
164
|
+
|
165
|
+
--nomunge
|
166
|
+
Minify only. Do not obfuscate local symbols.
|
167
|
+
|
168
|
+
--preserve-semi
|
169
|
+
Preserve unnecessary semicolons (such as right before a '}') This option
|
170
|
+
is useful when compressed code has to be run through JSLint (which is the
|
171
|
+
case of YUI for example)
|
172
|
+
|
173
|
+
--disable-optimizations
|
174
|
+
Disable all the built-in micro optimizations.
|
175
|
+
|
176
|
+
NOTES
|
177
|
+
|
178
|
+
+ If no input file is specified, it defaults to stdin.
|
179
|
+
|
180
|
+
+ The YUI Compressor requires Java version >= 1.4.
|
181
|
+
|
182
|
+
+ It is possible to prevent a local variable, nested function or function
|
183
|
+
argument from being obfuscated by using "hints". A hint is a string that
|
184
|
+
is located at the very beginning of a function body like so:
|
185
|
+
|
186
|
+
function fn (arg1, arg2, arg3) {
|
187
|
+
"arg2:nomunge, localVar:nomunge, nestedFn:nomunge";
|
188
|
+
|
189
|
+
...
|
190
|
+
var localVar;
|
191
|
+
...
|
192
|
+
|
193
|
+
function nestedFn () {
|
194
|
+
....
|
195
|
+
}
|
196
|
+
|
197
|
+
...
|
198
|
+
}
|
199
|
+
|
200
|
+
The hint itself disappears from the compressed file.
|
201
|
+
|
202
|
+
+ C-style comments starting with /*! are preserved. This is useful with
|
203
|
+
comments containing copyright/license information. For example:
|
204
|
+
|
205
|
+
/*!
|
206
|
+
* TERMS OF USE - EASING EQUATIONS
|
207
|
+
* Open source under the BSD License.
|
208
|
+
* Copyright 2001 Robert Penner All rights reserved.
|
209
|
+
*/
|
210
|
+
|
211
|
+
becomes:
|
212
|
+
|
213
|
+
/*
|
214
|
+
* TERMS OF USE - EASING EQUATIONS
|
215
|
+
* Open source under the BSD License.
|
216
|
+
* Copyright 2001 Robert Penner All rights reserved.
|
217
|
+
*/
|
218
|
+
|
219
|
+
AUTHOR
|
220
|
+
|
221
|
+
The YUI Compressor was written and is maintained by:
|
222
|
+
Julien Lecomte <jlecomte@yahoo-inc.com>
|
223
|
+
The CSS portion is a port of Isaac Schlueter's cssmin utility.
|
224
|
+
|
225
|
+
COPYRIGHT
|
226
|
+
|
227
|
+
Copyright (c) 2007-2009, Yahoo! Inc. All rights reserved.
|
228
|
+
|
229
|
+
LICENSE
|
230
|
+
|
231
|
+
All code specific to YUI Compressor is issued under a BSD license.
|
232
|
+
YUI Compressor extends and implements code from Mozilla's Rhino project.
|
233
|
+
Rhino is issued under the Mozilla Public License (MPL), and MPL applies
|
234
|
+
to the Rhino source and binaries that are distributed with YUI Compressor.</pre>
|
235
|
+
|
236
|
+
</div>
|
237
|
+
</body>
|
238
|
+
</html>
|
Binary file
|
Binary file
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestInstallCommand < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@io = StringIO.new
|
7
|
+
@command = Juicer::Command::Install.new(Logger.new(@io))
|
8
|
+
FileUtils.rm_rf(path(".juicer/lib")) if File.exists?(path(".juicer/lib"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_default_version_should_bring_up_latest_from_installer
|
12
|
+
assert_equal "1.0", @command.version(Juicer::Install::JSLintInstaller.new)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_explicit_version_should_not_be_overridden
|
16
|
+
@command.instance_eval { @version = "1.0.1" }
|
17
|
+
assert_equal "1.0.1", @command.version(Juicer::Install::JSLintInstaller.new)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_execute_should_require_atleast_one_argument
|
21
|
+
assert_raise ArgumentError do
|
22
|
+
@command.execute
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_install_single_lib
|
27
|
+
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
28
|
+
assert !installer.installed?
|
29
|
+
|
30
|
+
@command.instance_eval { @path = path(".juicer") }
|
31
|
+
@command.execute("jslint")
|
32
|
+
assert installer.installed?
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_install_already_installed_lib
|
36
|
+
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
37
|
+
installer.install
|
38
|
+
assert installer.installed?
|
39
|
+
|
40
|
+
@command.execute("jslint")
|
41
|
+
assert_match(/is already installed in/, @io.string)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_install_specific_version
|
45
|
+
installer = Juicer::Install::JSLintInstaller.new(path(".juicer"))
|
46
|
+
assert !installer.installed?("0.9")
|
47
|
+
|
48
|
+
@command.instance_eval { @path = path(".juicer") }
|
49
|
+
@command.instance_eval { @version = "0.9" }
|
50
|
+
@command.execute("jslint")
|
51
|
+
assert installer.installed?("0.9")
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestListCommand < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@io = StringIO.new
|
7
|
+
@command = Juicer::Command::List.new(@io)
|
8
|
+
Juicer::Test::FileSetup.new.create
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_nothing
|
12
|
+
assert_raise ArgumentError do
|
13
|
+
@command.execute
|
14
|
+
end
|
15
|
+
|
16
|
+
assert_raise ArgumentError do
|
17
|
+
@command.execute []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_list_css_file
|
22
|
+
@command.execute "test/data/a.css"
|
23
|
+
|
24
|
+
msg = <<-STDOUT
|
25
|
+
Dependency chain for test/data/a.css:
|
26
|
+
test/data/b.css
|
27
|
+
test/data/a.css
|
28
|
+
|
29
|
+
STDOUT
|
30
|
+
|
31
|
+
assert_equal msg, @io.string
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_list_js_file
|
35
|
+
@command.execute "test/data/a.js"
|
36
|
+
|
37
|
+
msg = <<-STDOUT
|
38
|
+
Dependency chain for test/data/a.js:
|
39
|
+
test/data/b.js
|
40
|
+
test/data/a.js
|
41
|
+
|
42
|
+
STDOUT
|
43
|
+
|
44
|
+
assert_equal msg, @io.string
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_list_several_files
|
48
|
+
@command.execute ["test/data/a.js", "test/data/b.js"]
|
49
|
+
|
50
|
+
msg = <<-STDOUT
|
51
|
+
Dependency chain for test/data/a.js:
|
52
|
+
test/data/b.js
|
53
|
+
test/data/a.js
|
54
|
+
|
55
|
+
Dependency chain for test/data/b.js:
|
56
|
+
test/data/a.js
|
57
|
+
test/data/b.js
|
58
|
+
|
59
|
+
STDOUT
|
60
|
+
|
61
|
+
assert_equal msg, @io.string
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_list_files_unable_to_guess_type
|
65
|
+
assert_raise FileNotFoundError do
|
66
|
+
@command.execute("test/data/*.txt")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), %w[.. .. test_helper])) unless defined?(Juicer)
|
2
|
+
|
3
|
+
class TestMergeCommand < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@io = StringIO.new
|
7
|
+
@merge = Juicer::Command::Merge.new(Logger.new(@io))
|
8
|
+
|
9
|
+
Juicer::Test::FileSetup.new.create
|
10
|
+
|
11
|
+
["a.min.css", "not-ok.min.js"].each { |f| File.delete(path(f)) if File.exists?(path(f)) }
|
12
|
+
|
13
|
+
Juicer.home = path(".juicer")
|
14
|
+
installer = Juicer::Install::YuiCompressorInstaller.new(Juicer.home)
|
15
|
+
installer.install("2.4.2") unless installer.installed?("2.4.2")
|
16
|
+
|
17
|
+
installer = Juicer::Install::JSLintInstaller.new(Juicer.home)
|
18
|
+
installer.install unless installer.installed?
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_minifier_from_nil_minifyer
|
22
|
+
@merge.instance_eval { @minifyer = nil }
|
23
|
+
|
24
|
+
Juicer::Command::Merge.publicize_methods do
|
25
|
+
assert_nil @merge.minifyer
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_get_minifier_from_empty_minifyer
|
30
|
+
@merge.instance_eval { @minifyer = "" }
|
31
|
+
|
32
|
+
Juicer::Command::Merge.publicize_methods do
|
33
|
+
assert_nil @merge.minifyer
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_get_minifier_from_none_minifyer
|
38
|
+
Juicer::Command::Merge.publicize_methods do
|
39
|
+
@merge.instance_eval { @minifyer = "none" }
|
40
|
+
assert_nil @merge.minifyer
|
41
|
+
|
42
|
+
@merge.instance_eval { @minifyer = "None" }
|
43
|
+
assert_nil @merge.minifyer
|
44
|
+
|
45
|
+
@merge.instance_eval { @minifyer = "NONE" }
|
46
|
+
assert_nil @merge.minifyer
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_get_minifyer
|
51
|
+
Juicer::Command::Merge.publicize_methods do
|
52
|
+
assert @merge.minifyer.class == Juicer::Minifyer::YuiCompressor
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_output_name_from_file_should_have_suffix_prepended_with_min
|
57
|
+
Juicer::Command::Merge.publicize_methods do
|
58
|
+
assert_equal "test.min.js", @merge.output("test.js")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_output_name_from_nothing_should_be_timestamp
|
63
|
+
Juicer::Command::Merge.publicize_methods do
|
64
|
+
assert_match(/\d{10}\.min\.tmp/, @merge.output)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_output_name_instance_value
|
69
|
+
Juicer::Command::Merge.publicize_methods do
|
70
|
+
@merge.instance_eval { @output = "output.css" }
|
71
|
+
assert_equal "output.css", @merge.output
|
72
|
+
assert_equal "output.css", @merge.output("bleh.css")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_merger_from_valid_type
|
77
|
+
Juicer::Command::Merge.publicize_methods do
|
78
|
+
assert_equal Juicer::Merger::JavaScriptMerger, @merge.merger("bleh.js")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_merger_from_invalid_type
|
83
|
+
Juicer::Command::Merge.publicize_methods do
|
84
|
+
assert_equal Juicer::Merger::JavaScriptMerger, @merge.merger("bleh.txt")
|
85
|
+
assert_match(/Unknown type 'txt', defaulting to 'js'/, @io.string)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_merger_from_preset_type
|
90
|
+
Juicer::Command::Merge.publicize_methods do
|
91
|
+
@merge.instance_eval { @type = "css" }
|
92
|
+
assert_equal Juicer::Merger::StylesheetMerger, @merge.merger
|
93
|
+
assert_equal Juicer::Merger::StylesheetMerger, @merge.merger("bleh.txt")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_merge_without_input
|
98
|
+
assert_raise SystemExit do
|
99
|
+
@merge.execute([])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_merge_with_bogus_input
|
104
|
+
assert_raise SystemExit do
|
105
|
+
@merge.execute(["*.css", "bleh/*.js"])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_unable_to_merge_on_existing_file
|
110
|
+
assert_raise SystemExit do
|
111
|
+
@merge.instance_eval { @output = path("a.css") }
|
112
|
+
@merge.execute(path("a.css"))
|
113
|
+
assert_match(/Run again with --force to overwrite/, @io.string)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_update_output_when_force
|
118
|
+
assert_nothing_raised do
|
119
|
+
@merge.instance_eval { @force = true }
|
120
|
+
@merge.execute(path("a.css"))
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_merge_successful
|
125
|
+
begin
|
126
|
+
@merge.instance_eval { @output = path("a.min.css") }
|
127
|
+
assert @merge.execute(path("a1.css"))
|
128
|
+
assert_equal "h2{font-size:10px;}html{background:red;}h1{font-size:12px;}body{width:800px;}", IO.read(path("a.min.css"))
|
129
|
+
rescue Test::Unit::AssertionFailedError => err
|
130
|
+
raise err
|
131
|
+
rescue Exception => err
|
132
|
+
puts err.message
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_fail_when_syntax_no_good
|
137
|
+
assert_raise SystemExit do
|
138
|
+
@merge.execute(path("not-ok.js"))
|
139
|
+
assert_match(/Problems were detected during verification/, @io.string)
|
140
|
+
assert_no_match(/Ignoring detected problems/, @io.string)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_ignore_problems
|
145
|
+
@merge.instance_eval { @ignore = true }
|
146
|
+
|
147
|
+
assert_nothing_raised do
|
148
|
+
@merge.execute(path("not-ok.js"))
|
149
|
+
assert_match(/Problems were detected during verification/, @io.string)
|
150
|
+
assert_match(/Ignoring detected problems/, @io.string)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
end
|