compressible 0.0.2
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/MIT-LICENSE +20 -0
- data/README.markdown +125 -0
- data/Rakefile +80 -0
- data/init.rb +1 -0
- data/lib/compressible.rake +27 -0
- data/lib/compressible.rb +225 -0
- data/lib/compressible/view_helpers.rb +17 -0
- data/lib/ext.rb +25 -0
- data/rails/init.rb +1 -0
- data/test/config.yml +20 -0
- data/test/initializer.rb +2 -0
- data/test/result.css +3 -0
- data/test/result.js +3 -0
- data/test/result_test.css +3 -0
- data/test/test-a.css +450 -0
- data/test/test-a.js +205 -0
- data/test/test-b.css +48 -0
- data/test/test-b.js +124 -0
- data/test/test_compressible.rb +125 -0
- data/test/test_helper.rb +8 -0
- metadata +106 -0
data/test/test-a.js
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3
|
+
*
|
4
|
+
* Uses the built in easing capabilities added In jQuery 1.1
|
5
|
+
* to offer multiple easing options
|
6
|
+
*
|
7
|
+
* TERMS OF USE - jQuery Easing
|
8
|
+
*
|
9
|
+
* Open source under the BSD License.
|
10
|
+
*
|
11
|
+
* Copyright © 2008 George McGinley Smith
|
12
|
+
* All rights reserved.
|
13
|
+
*
|
14
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
15
|
+
* are permitted provided that the following conditions are met:
|
16
|
+
*
|
17
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
18
|
+
* conditions and the following disclaimer.
|
19
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
20
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
21
|
+
* provided with the distribution.
|
22
|
+
*
|
23
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
24
|
+
* or promote products derived from this software without specific prior written permission.
|
25
|
+
*
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
|
38
|
+
// t: current time, b: begInnIng value, c: change In value, d: duration
|
39
|
+
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
40
|
+
|
41
|
+
jQuery.extend( jQuery.easing,
|
42
|
+
{
|
43
|
+
def: 'easeOutQuad',
|
44
|
+
swing: function (x, t, b, c, d) {
|
45
|
+
//alert(jQuery.easing.default);
|
46
|
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
47
|
+
},
|
48
|
+
easeInQuad: function (x, t, b, c, d) {
|
49
|
+
return c*(t/=d)*t + b;
|
50
|
+
},
|
51
|
+
easeOutQuad: function (x, t, b, c, d) {
|
52
|
+
return -c *(t/=d)*(t-2) + b;
|
53
|
+
},
|
54
|
+
easeInOutQuad: function (x, t, b, c, d) {
|
55
|
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
56
|
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
57
|
+
},
|
58
|
+
easeInCubic: function (x, t, b, c, d) {
|
59
|
+
return c*(t/=d)*t*t + b;
|
60
|
+
},
|
61
|
+
easeOutCubic: function (x, t, b, c, d) {
|
62
|
+
return c*((t=t/d-1)*t*t + 1) + b;
|
63
|
+
},
|
64
|
+
easeInOutCubic: function (x, t, b, c, d) {
|
65
|
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
66
|
+
return c/2*((t-=2)*t*t + 2) + b;
|
67
|
+
},
|
68
|
+
easeInQuart: function (x, t, b, c, d) {
|
69
|
+
return c*(t/=d)*t*t*t + b;
|
70
|
+
},
|
71
|
+
easeOutQuart: function (x, t, b, c, d) {
|
72
|
+
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
73
|
+
},
|
74
|
+
easeInOutQuart: function (x, t, b, c, d) {
|
75
|
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
76
|
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
77
|
+
},
|
78
|
+
easeInQuint: function (x, t, b, c, d) {
|
79
|
+
return c*(t/=d)*t*t*t*t + b;
|
80
|
+
},
|
81
|
+
easeOutQuint: function (x, t, b, c, d) {
|
82
|
+
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
83
|
+
},
|
84
|
+
easeInOutQuint: function (x, t, b, c, d) {
|
85
|
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
86
|
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
87
|
+
},
|
88
|
+
easeInSine: function (x, t, b, c, d) {
|
89
|
+
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
90
|
+
},
|
91
|
+
easeOutSine: function (x, t, b, c, d) {
|
92
|
+
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
93
|
+
},
|
94
|
+
easeInOutSine: function (x, t, b, c, d) {
|
95
|
+
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
96
|
+
},
|
97
|
+
easeInExpo: function (x, t, b, c, d) {
|
98
|
+
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
99
|
+
},
|
100
|
+
easeOutExpo: function (x, t, b, c, d) {
|
101
|
+
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
102
|
+
},
|
103
|
+
easeInOutExpo: function (x, t, b, c, d) {
|
104
|
+
if (t==0) return b;
|
105
|
+
if (t==d) return b+c;
|
106
|
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
107
|
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
108
|
+
},
|
109
|
+
easeInCirc: function (x, t, b, c, d) {
|
110
|
+
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
111
|
+
},
|
112
|
+
easeOutCirc: function (x, t, b, c, d) {
|
113
|
+
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
114
|
+
},
|
115
|
+
easeInOutCirc: function (x, t, b, c, d) {
|
116
|
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
117
|
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
118
|
+
},
|
119
|
+
easeInElastic: function (x, t, b, c, d) {
|
120
|
+
var s=1.70158;var p=0;var a=c;
|
121
|
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
122
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
123
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
124
|
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
125
|
+
},
|
126
|
+
easeOutElastic: function (x, t, b, c, d) {
|
127
|
+
var s=1.70158;var p=0;var a=c;
|
128
|
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
129
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
130
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
131
|
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
132
|
+
},
|
133
|
+
easeInOutElastic: function (x, t, b, c, d) {
|
134
|
+
var s=1.70158;var p=0;var a=c;
|
135
|
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
136
|
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
137
|
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
138
|
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
139
|
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
140
|
+
},
|
141
|
+
easeInBack: function (x, t, b, c, d, s) {
|
142
|
+
if (s == undefined) s = 1.70158;
|
143
|
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
144
|
+
},
|
145
|
+
easeOutBack: function (x, t, b, c, d, s) {
|
146
|
+
if (s == undefined) s = 1.70158;
|
147
|
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
148
|
+
},
|
149
|
+
easeInOutBack: function (x, t, b, c, d, s) {
|
150
|
+
if (s == undefined) s = 1.70158;
|
151
|
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
152
|
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
153
|
+
},
|
154
|
+
easeInBounce: function (x, t, b, c, d) {
|
155
|
+
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
156
|
+
},
|
157
|
+
easeOutBounce: function (x, t, b, c, d) {
|
158
|
+
if ((t/=d) < (1/2.75)) {
|
159
|
+
return c*(7.5625*t*t) + b;
|
160
|
+
} else if (t < (2/2.75)) {
|
161
|
+
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
162
|
+
} else if (t < (2.5/2.75)) {
|
163
|
+
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
164
|
+
} else {
|
165
|
+
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
166
|
+
}
|
167
|
+
},
|
168
|
+
easeInOutBounce: function (x, t, b, c, d) {
|
169
|
+
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
170
|
+
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
171
|
+
}
|
172
|
+
});
|
173
|
+
|
174
|
+
/*
|
175
|
+
*
|
176
|
+
* TERMS OF USE - EASING EQUATIONS
|
177
|
+
*
|
178
|
+
* Open source under the BSD License.
|
179
|
+
*
|
180
|
+
* Copyright © 2001 Robert Penner
|
181
|
+
* All rights reserved.
|
182
|
+
*
|
183
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
184
|
+
* are permitted provided that the following conditions are met:
|
185
|
+
*
|
186
|
+
* Redistributions of source code must retain the above copyright notice, this list of
|
187
|
+
* conditions and the following disclaimer.
|
188
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
189
|
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
190
|
+
* provided with the distribution.
|
191
|
+
*
|
192
|
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
193
|
+
* or promote products derived from this software without specific prior written permission.
|
194
|
+
*
|
195
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
196
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
197
|
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
198
|
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
199
|
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
200
|
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
201
|
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
202
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
203
|
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
204
|
+
*
|
205
|
+
*/
|
data/test/test-b.css
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
.ac_results {
|
2
|
+
padding: 0px;
|
3
|
+
border: 1px solid black;
|
4
|
+
background-color: white;
|
5
|
+
overflow: hidden;
|
6
|
+
z-index: 99999;
|
7
|
+
}
|
8
|
+
|
9
|
+
.ac_results ul {
|
10
|
+
width: 100%;
|
11
|
+
list-style-position: outside;
|
12
|
+
list-style: none;
|
13
|
+
padding: 0;
|
14
|
+
margin: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.ac_results li {
|
18
|
+
margin: 0px;
|
19
|
+
padding: 2px 5px;
|
20
|
+
cursor: default;
|
21
|
+
display: block;
|
22
|
+
/*
|
23
|
+
if width will be 100% horizontal scrollbar will apear
|
24
|
+
when scroll mode will be used
|
25
|
+
*/
|
26
|
+
/*width: 100%;*/
|
27
|
+
font: menu;
|
28
|
+
font-size: 12px;
|
29
|
+
/*
|
30
|
+
it is very important, if line-height not setted or setted
|
31
|
+
in relative units scroll will be broken in firefox
|
32
|
+
*/
|
33
|
+
line-height: 16px;
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
36
|
+
|
37
|
+
.ac_loading {
|
38
|
+
background: white url('indicator.gif') right center no-repeat;
|
39
|
+
}
|
40
|
+
|
41
|
+
.ac_odd {
|
42
|
+
background-color: #eee;
|
43
|
+
}
|
44
|
+
|
45
|
+
.ac_over {
|
46
|
+
background-color: #0A246A;
|
47
|
+
color: white;
|
48
|
+
}
|
data/test/test-b.js
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
/*
|
2
|
+
* AutoScroll Plugin for jQuery
|
3
|
+
*
|
4
|
+
* Copyright (c) 2006 Jonathan Sharp (jdsharp.us)
|
5
|
+
* Licensed under the GPL license.
|
6
|
+
*
|
7
|
+
* http://jdsharp.us/code/AutoScroll/
|
8
|
+
*
|
9
|
+
* Date: 2006-09-19
|
10
|
+
* Rev: 001
|
11
|
+
*/
|
12
|
+
|
13
|
+
$.autoscroll = {
|
14
|
+
settings: {},
|
15
|
+
interval: 0,
|
16
|
+
event: null,
|
17
|
+
|
18
|
+
init: function(opts) {
|
19
|
+
$.autoscroll.settings = {
|
20
|
+
step: 80,
|
21
|
+
trigger: 75,
|
22
|
+
interval: 80,
|
23
|
+
mod_key: 17
|
24
|
+
};
|
25
|
+
|
26
|
+
if (opts) {
|
27
|
+
for (o in opts) {
|
28
|
+
$.autoscroll.settings[o] = opts[o];
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
document.onmousemove= $.autoscroll.setMouseEvent;
|
33
|
+
document.onkeydown = $.autoscroll.setKeyEvent;
|
34
|
+
document.onkeyup = function(){ clearInterval($.autoscroll.interval); $.autoscroll.interval = 0; };
|
35
|
+
},
|
36
|
+
|
37
|
+
setKeyEvent: function(e) {
|
38
|
+
var e = e || window.event;
|
39
|
+
var k = e.charCode ? e.charCode : e.keyCode ? e.keyCode : e.which;
|
40
|
+
if ($.autoscroll.interval == 0 && ($.autoscroll.settings.mod_key == k)) {
|
41
|
+
$.autoscroll.interval = setInterval($.autoscroll.step, $.autoscroll.settings.interval);
|
42
|
+
}
|
43
|
+
},
|
44
|
+
|
45
|
+
setMouseEvent: function(e) {
|
46
|
+
var e = e || window.event;
|
47
|
+
var de = document.documentElement;
|
48
|
+
var b = document.body;
|
49
|
+
$.autoscroll.event = {
|
50
|
+
cursor: {
|
51
|
+
x: e.pageX || (e.clientX + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0)),
|
52
|
+
y: e.pageY || (e.clientY + (de.scrollTop || b.scrollTop) - (de.clientTop || 0))
|
53
|
+
},
|
54
|
+
|
55
|
+
win: {
|
56
|
+
w: window.innerWidth || (de.clientWidth && de.clientWidth != 0 ? de.clientWidth : b.offsetWidth),
|
57
|
+
h: window.innerHeight || (de.clientHeight && de.clientWidth != 0 ? de.clientHeight : b.offsetHeight)
|
58
|
+
},
|
59
|
+
|
60
|
+
scroll: {
|
61
|
+
x: (document.all ?
|
62
|
+
(!de.scrollLeft ? b.scrollLeft : de.scrollLeft)
|
63
|
+
:
|
64
|
+
(window.pageXOffset ? window.pageXOffset : window.scrollX)
|
65
|
+
),
|
66
|
+
y: (document.all ?
|
67
|
+
(!de.scrollTop ? b.scrollTop : de.scrollTop)
|
68
|
+
:
|
69
|
+
(window.pageYOffset ? window.pageYOffset : window.scrollY)
|
70
|
+
)
|
71
|
+
}
|
72
|
+
};
|
73
|
+
},
|
74
|
+
|
75
|
+
step: function() {
|
76
|
+
var e = $.autoscroll.event;
|
77
|
+
if (!e) {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
|
81
|
+
var hot_l = e.scroll.x;
|
82
|
+
var hot_r = e.scroll.x + e.win.w;
|
83
|
+
var x = e.cursor.x;
|
84
|
+
|
85
|
+
var hot_t = e.scroll.y;
|
86
|
+
var hot_b = e.scroll.y + e.win.h;
|
87
|
+
var y = e.cursor.y;
|
88
|
+
|
89
|
+
if (hot_l <= x && x <= (hot_l + $.autoscroll.settings.trigger)) {
|
90
|
+
var ratio = (1 - ((x - hot_l) / $.autoscroll.settings.trigger));
|
91
|
+
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
|
92
|
+
e.scroll.x += -step;
|
93
|
+
e.cursor.x += -step;
|
94
|
+
} else if ((hot_r - $.autoscroll.settings.trigger) <= x && x <= hot_r) {
|
95
|
+
var ratio = (1 - ((hot_r - x) / $.autoscroll.settings.trigger));
|
96
|
+
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
|
97
|
+
e.scroll.x += step;
|
98
|
+
e.cursor.x += step;
|
99
|
+
}
|
100
|
+
|
101
|
+
if (hot_t <= y && y <= (hot_t + $.autoscroll.settings.trigger)) {
|
102
|
+
var ratio = (1 - ((y - hot_t) / $.autoscroll.settings.trigger));
|
103
|
+
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
|
104
|
+
e.scroll.y += -step;
|
105
|
+
e.cursor.y += -step;
|
106
|
+
} else if ((hot_b - $.autoscroll.settings.trigger) <= y && y <= hot_b) {
|
107
|
+
var ratio = (1 - ((hot_b - y) / $.autoscroll.settings.trigger));
|
108
|
+
var step = Math.round(ratio * $.autoscroll.settings.step, 0);
|
109
|
+
e.scroll.y += step;
|
110
|
+
e.cursor.y += step;
|
111
|
+
}
|
112
|
+
|
113
|
+
if (e.scroll.x < 0) {
|
114
|
+
e.scroll.x = 0;
|
115
|
+
e.cursor.x = 0;
|
116
|
+
}
|
117
|
+
if (e.scroll.y < 0) {
|
118
|
+
e.scroll.y = 0;
|
119
|
+
e.cursor.y = 0;
|
120
|
+
}
|
121
|
+
|
122
|
+
window.scrollTo(e.scroll.x, e.scroll.y);
|
123
|
+
}
|
124
|
+
};
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper")
|
2
|
+
|
3
|
+
class CompressibleTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Compressible" do
|
6
|
+
|
7
|
+
context "configuration" do
|
8
|
+
|
9
|
+
should "load configuration file and result should be a hash" do
|
10
|
+
assert_kind_of Hash, Compressible.configure("test/config.yml")
|
11
|
+
end
|
12
|
+
|
13
|
+
should "raise an RuntimeError if pass junk to config" do
|
14
|
+
assert_raise(RuntimeError) { Compressible.configure([]) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with correct configuration" do
|
18
|
+
|
19
|
+
setup { Compressible.configure("test/config.yml") }
|
20
|
+
|
21
|
+
should "have symbols for keys, not strings (symbolize keys, been a problem in the past)" do
|
22
|
+
Compressible.config.each_key do |k|
|
23
|
+
assert_kind_of Symbol, k
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
teardown { Compressible.reset }
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context "javascript compression" do
|
34
|
+
|
35
|
+
setup do
|
36
|
+
@js = <<-eos
|
37
|
+
function (x, t, b, c, d) {
|
38
|
+
//alert(jQuery.easing.default);
|
39
|
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
40
|
+
}
|
41
|
+
eos
|
42
|
+
end
|
43
|
+
|
44
|
+
should "compress javascript" do
|
45
|
+
assert Compressible.js("test/test-a.js", "test/test-b.js", :to => "test/result.js")
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
context "css compression" do
|
51
|
+
|
52
|
+
setup do
|
53
|
+
@css = <<-eos
|
54
|
+
a.pp_contract {
|
55
|
+
cursor: pointer;
|
56
|
+
display: none;
|
57
|
+
height: 20px;
|
58
|
+
position: absolute;
|
59
|
+
right: 30px;
|
60
|
+
text-indent: -10000px;
|
61
|
+
top: 10px;
|
62
|
+
width: 20px;
|
63
|
+
z-index: 20000;
|
64
|
+
}
|
65
|
+
eos
|
66
|
+
end
|
67
|
+
|
68
|
+
should "compress stylesheets" do
|
69
|
+
assert Compressible.css("test/test-a.css", "test/test-b.css", :to => "test/result.css")
|
70
|
+
end
|
71
|
+
|
72
|
+
should "compress stylesheets without file extension" do
|
73
|
+
assert Compressible.css("test/test-a", "test/test-b", :to => "test/result")
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
context "compress all" do
|
79
|
+
|
80
|
+
setup { Compressible.configure("test/config.yml") }
|
81
|
+
|
82
|
+
should "run dynamic compression methods from config" do
|
83
|
+
assert Compressible.compress
|
84
|
+
end
|
85
|
+
|
86
|
+
context "view tags" do
|
87
|
+
|
88
|
+
should "find uncached version of a stylesheet from a key" do
|
89
|
+
assert_equal ["test/test-a", "test/test-b"], Compressible.uncached_stylesheet_paths("test/result")
|
90
|
+
end
|
91
|
+
|
92
|
+
should "use cached tags if we're in a 'production' environment (default)" do
|
93
|
+
assets = Compressible.assets_for(:stylesheet, 'test/result', :environments => "production")
|
94
|
+
assert_equal ["test/result"], assets
|
95
|
+
end
|
96
|
+
|
97
|
+
should "use uncached tags if we're not in a 'production' environment (development)" do
|
98
|
+
assets = Compressible.assets_for(:stylesheet, 'test/result', :environments => "production", :current => "development")
|
99
|
+
assert_equal ["test/test-a", "test/test-b"], assets
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
teardown { Compressible.reset }
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
context "without yaml config" do
|
109
|
+
|
110
|
+
setup { Compressible.reset }
|
111
|
+
|
112
|
+
should "add javascript to the config hash" do
|
113
|
+
assert_equal [], Compressible.config[:js]
|
114
|
+
Compressible.js("test/test-a", "test/test-b", :to => "test/result")
|
115
|
+
assert_equal ["test/test-a", "test/test-b"], Compressible.config[:js][0][:paths]
|
116
|
+
end
|
117
|
+
|
118
|
+
teardown { Compressible.reset }
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|