ruby-clean-css 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/.gitmodules +3 -0
  2. data/EXAMPLE.md +25 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +30 -0
  5. data/LICENSE +19 -0
  6. data/README.md +106 -0
  7. data/lib/javascript/clean-css/.gitignore +4 -0
  8. data/lib/javascript/clean-css/.jshintignore +3 -0
  9. data/lib/javascript/clean-css/.jshintrc +14 -0
  10. data/lib/javascript/clean-css/.travis.yml +11 -0
  11. data/lib/javascript/clean-css/History.md +556 -0
  12. data/lib/javascript/clean-css/LICENSE +19 -0
  13. data/lib/javascript/clean-css/README.md +218 -0
  14. data/lib/javascript/clean-css/bin/cleancss +157 -0
  15. data/lib/javascript/clean-css/index.js +1 -0
  16. data/lib/javascript/clean-css/lib/clean.js +426 -0
  17. data/lib/javascript/clean-css/lib/colors/hsl-to-hex.js +64 -0
  18. data/lib/javascript/clean-css/lib/colors/long-to-short-hex.js +12 -0
  19. data/lib/javascript/clean-css/lib/colors/rgb-to-hex.js +14 -0
  20. data/lib/javascript/clean-css/lib/colors/shortener.js +174 -0
  21. data/lib/javascript/clean-css/lib/images/url-rebase.js +32 -0
  22. data/lib/javascript/clean-css/lib/images/url-rewriter.js +60 -0
  23. data/lib/javascript/clean-css/lib/imports/inliner.js +319 -0
  24. data/lib/javascript/clean-css/lib/properties/optimizer.js +276 -0
  25. data/lib/javascript/clean-css/lib/properties/override-compactor.js +116 -0
  26. data/lib/javascript/clean-css/lib/properties/processable.js +859 -0
  27. data/lib/javascript/clean-css/lib/properties/scanner.js +20 -0
  28. data/lib/javascript/clean-css/lib/properties/shorthand-compactor.js +244 -0
  29. data/lib/javascript/clean-css/lib/properties/token.js +184 -0
  30. data/lib/javascript/clean-css/lib/properties/validator.js +140 -0
  31. data/lib/javascript/clean-css/lib/selectors/empty-removal.js +30 -0
  32. data/lib/javascript/clean-css/lib/selectors/optimizer.js +341 -0
  33. data/lib/javascript/clean-css/lib/selectors/tokenizer.js +168 -0
  34. data/lib/javascript/clean-css/lib/text/comments.js +83 -0
  35. data/lib/javascript/clean-css/lib/text/escape-store.js +32 -0
  36. data/lib/javascript/clean-css/lib/text/expressions.js +73 -0
  37. data/lib/javascript/clean-css/lib/text/free.js +26 -0
  38. data/lib/javascript/clean-css/lib/text/name-quotes.js +37 -0
  39. data/lib/javascript/clean-css/lib/text/quote-scanner.js +91 -0
  40. data/lib/javascript/clean-css/lib/text/splitter.js +35 -0
  41. data/lib/javascript/clean-css/lib/text/urls.js +41 -0
  42. data/lib/javascript/clean-css/package.json +50 -0
  43. data/lib/javascript/clean-css/test/batch-test.js +56 -0
  44. data/lib/javascript/clean-css/test/bench.js +11 -0
  45. data/lib/javascript/clean-css/test/binary-test.js +323 -0
  46. data/lib/javascript/clean-css/test/data-bench/_partial.css +1 -0
  47. data/lib/javascript/clean-css/test/data-bench/complex.css +4 -0
  48. data/lib/javascript/clean-css/test/data/129-assets/assets/ui.css +2 -0
  49. data/lib/javascript/clean-css/test/data/129-assets/components/bootstrap/css/bootstrap.css +3 -0
  50. data/lib/javascript/clean-css/test/data/129-assets/components/bootstrap/images/glyphs.gif +0 -0
  51. data/lib/javascript/clean-css/test/data/129-assets/components/jquery-ui/css/style.css +6 -0
  52. data/lib/javascript/clean-css/test/data/129-assets/components/jquery-ui/images/next.gif +0 -0
  53. data/lib/javascript/clean-css/test/data/129-assets/components/jquery-ui/images/prev.gif +0 -0
  54. data/lib/javascript/clean-css/test/data/960-min.css +125 -0
  55. data/lib/javascript/clean-css/test/data/960.css +602 -0
  56. data/lib/javascript/clean-css/test/data/big-min.css +2984 -0
  57. data/lib/javascript/clean-css/test/data/big.css +13794 -0
  58. data/lib/javascript/clean-css/test/data/blueprint-min.css +245 -0
  59. data/lib/javascript/clean-css/test/data/blueprint.css +556 -0
  60. data/lib/javascript/clean-css/test/data/charset-mixed-with-fonts-min.css +3 -0
  61. data/lib/javascript/clean-css/test/data/charset-mixed-with-fonts.css +14 -0
  62. data/lib/javascript/clean-css/test/data/font-awesome-ie7-min.css +392 -0
  63. data/lib/javascript/clean-css/test/data/font-awesome-ie7.css +1203 -0
  64. data/lib/javascript/clean-css/test/data/font-awesome-min.css +319 -0
  65. data/lib/javascript/clean-css/test/data/font-awesome.css +540 -0
  66. data/lib/javascript/clean-css/test/data/imports-min.css +5 -0
  67. data/lib/javascript/clean-css/test/data/imports.css +4 -0
  68. data/lib/javascript/clean-css/test/data/issue-117-snippet-min.css +3 -0
  69. data/lib/javascript/clean-css/test/data/issue-117-snippet.css +19 -0
  70. data/lib/javascript/clean-css/test/data/issue-159-snippet-min.css +7 -0
  71. data/lib/javascript/clean-css/test/data/issue-159-snippet.css +7 -0
  72. data/lib/javascript/clean-css/test/data/issue-192-min.css +1 -0
  73. data/lib/javascript/clean-css/test/data/issue-192.css +8 -0
  74. data/lib/javascript/clean-css/test/data/issue-198-min.css +3 -0
  75. data/lib/javascript/clean-css/test/data/issue-198.css +4 -0
  76. data/lib/javascript/clean-css/test/data/issue-232-min.css +2 -0
  77. data/lib/javascript/clean-css/test/data/issue-232.css +17 -0
  78. data/lib/javascript/clean-css/test/data/issue-241-min.css +2 -0
  79. data/lib/javascript/clean-css/test/data/issue-241.css +2 -0
  80. data/lib/javascript/clean-css/test/data/issue-304-min.css +1 -0
  81. data/lib/javascript/clean-css/test/data/issue-304.css +4 -0
  82. data/lib/javascript/clean-css/test/data/issue-305-min.css +1 -0
  83. data/lib/javascript/clean-css/test/data/issue-305.css +3 -0
  84. data/lib/javascript/clean-css/test/data/issue-308-min.css +1 -0
  85. data/lib/javascript/clean-css/test/data/issue-308.css +5 -0
  86. data/lib/javascript/clean-css/test/data/issue-312-min.css +1 -0
  87. data/lib/javascript/clean-css/test/data/issue-312.css +7 -0
  88. data/lib/javascript/clean-css/test/data/issue-337-min.css +1 -0
  89. data/lib/javascript/clean-css/test/data/issue-337.css +4 -0
  90. data/lib/javascript/clean-css/test/data/line-breaks-in-attributes-min.css +2 -0
  91. data/lib/javascript/clean-css/test/data/line-breaks-in-attributes.css +8 -0
  92. data/lib/javascript/clean-css/test/data/partials-absolute/base.css +3 -0
  93. data/lib/javascript/clean-css/test/data/partials-absolute/base2.css +1 -0
  94. data/lib/javascript/clean-css/test/data/partials-absolute/extra/sub.css +3 -0
  95. data/lib/javascript/clean-css/test/data/partials-relative/base.css +3 -0
  96. data/lib/javascript/clean-css/test/data/partials-relative/extra/included.css +1 -0
  97. data/lib/javascript/clean-css/test/data/partials/comment.css +2 -0
  98. data/lib/javascript/clean-css/test/data/partials/extra/down.gif +0 -0
  99. data/lib/javascript/clean-css/test/data/partials/extra/four.css +3 -0
  100. data/lib/javascript/clean-css/test/data/partials/extra/three.css +1 -0
  101. data/lib/javascript/clean-css/test/data/partials/five.css +1 -0
  102. data/lib/javascript/clean-css/test/data/partials/four.css +1 -0
  103. data/lib/javascript/clean-css/test/data/partials/one.css +1 -0
  104. data/lib/javascript/clean-css/test/data/partials/three.css +1 -0
  105. data/lib/javascript/clean-css/test/data/partials/two.css +5 -0
  106. data/lib/javascript/clean-css/test/data/reset-min.css +12 -0
  107. data/lib/javascript/clean-css/test/data/reset.css +64 -0
  108. data/lib/javascript/clean-css/test/data/sample1-min.css +4 -0
  109. data/lib/javascript/clean-css/test/data/sample1.css +12 -0
  110. data/lib/javascript/clean-css/test/data/unsupported/selectors-ie7.css +20 -0
  111. data/lib/javascript/clean-css/test/data/unsupported/selectors-ie8.css +17 -0
  112. data/lib/javascript/clean-css/test/module-test.js +185 -0
  113. data/lib/javascript/clean-css/test/protocol-imports-test.js +409 -0
  114. data/lib/javascript/clean-css/test/text/splitter-test.js +20 -0
  115. data/lib/javascript/clean-css/test/unit-test.js +2071 -0
  116. data/lib/ruby-clean-css.rb +6 -0
  117. data/lib/ruby-clean-css/compressor.rb +142 -0
  118. data/lib/ruby-clean-css/exports.rb +258 -0
  119. data/lib/ruby-clean-css/railtie.rb +27 -0
  120. data/lib/ruby-clean-css/sprockets.rb +19 -0
  121. data/lib/ruby-clean-css/version.rb +5 -0
  122. data/ruby-clean-css.gemspec +30 -0
  123. data/test/test_compressor.rb +84 -0
  124. metadata +203 -0
@@ -0,0 +1,56 @@
1
+ var vows = require('vows');
2
+ var path = require('path');
3
+ var fs = require('fs');
4
+ var assert = require('assert');
5
+ var CleanCSS = require('../index');
6
+
7
+ var lineBreak = process.platform == 'win32' ? /\r\n/g : /\n/g;
8
+
9
+ var batchContexts = function() {
10
+ var context = {};
11
+ var dir = path.join(__dirname, 'data');
12
+ fs.readdirSync(dir).forEach(function(filename) {
13
+ if (filename.indexOf('.css') == -1 || /min.css$/.exec(filename) || !fs.statSync(path.join(dir, filename)).isFile())
14
+ return;
15
+ var testName = filename.split('.')[0];
16
+
17
+ context[testName] = {
18
+ topic: function() {
19
+ var plainPath = path.join(__dirname, 'data', testName + '.css');
20
+ var minPath = path.join(__dirname, 'data', testName + '-min.css');
21
+
22
+ return {
23
+ plain: fs.readFileSync(plainPath, 'utf-8'),
24
+ preminified: fs.readFileSync(minPath, 'utf-8'),
25
+ root: path.dirname(plainPath)
26
+ };
27
+ },
28
+ minifying: {
29
+ topic: function(data) {
30
+ var self = this;
31
+
32
+ new CleanCSS({
33
+ keepBreaks: true,
34
+ root: data.root
35
+ }).minify(data.plain, function(errors, minified) {
36
+ self.callback(errors, minified, data);
37
+ });
38
+ },
39
+ 'should output right content': function(errors, minified, data) {
40
+ var minifiedTokens = minified.split(lineBreak);
41
+ var preminifiedTokens = data.preminified.split(lineBreak);
42
+
43
+ minifiedTokens.forEach(function(line, i) {
44
+ assert.equal(line, preminifiedTokens[i]);
45
+ });
46
+ }
47
+ }
48
+ };
49
+ });
50
+
51
+ return context;
52
+ };
53
+
54
+ vows.describe('clean-batch')
55
+ .addBatch(batchContexts())
56
+ .export(module);
@@ -0,0 +1,11 @@
1
+ var CleanCSS = require('../index');
2
+ var path = require('path');
3
+
4
+ var benchDir = path.join(__dirname, 'data-bench');
5
+ var cssData = require('fs').readFileSync(path.join(benchDir, 'complex.css'), 'utf8');
6
+
7
+ var start = process.hrtime();
8
+ new CleanCSS({ benchmark: true, root: benchDir }).minify(cssData, function() {
9
+ var itTook = process.hrtime(start);
10
+ console.log('complete minification: %d ms', 1000 * itTook[0] + itTook[1] / 1000000);
11
+ });
@@ -0,0 +1,323 @@
1
+ var vows = require('vows');
2
+ var assert = require('assert');
3
+ var exec = require('child_process').exec;
4
+ var fs = require('fs');
5
+ var http = require('http');
6
+ var path = require('path');
7
+
8
+ var isWindows = process.platform == 'win32';
9
+ var lineBreak = isWindows ? /\r\n/g : /\n/g;
10
+
11
+ var binaryContext = function(options, context) {
12
+ if (isWindows)
13
+ return {};
14
+
15
+ context.topic = function() {
16
+ // We add __DIRECT__=1 to force binary into 'non-piped' mode
17
+ exec('__DIRECT__=1 ./bin/cleancss ' + options, this.callback);
18
+ };
19
+ return context;
20
+ };
21
+
22
+ var pipedContext = function(css, options, context) {
23
+ if (isWindows)
24
+ return {};
25
+
26
+ context.topic = function() {
27
+ exec('echo "' + css + '" | ./bin/cleancss ' + options, this.callback);
28
+ };
29
+ return context;
30
+ };
31
+
32
+ var unixOnlyContext = function(context) {
33
+ return isWindows ? {} : context;
34
+ };
35
+
36
+ var readFile = function(filename) {
37
+ return fs.readFileSync(filename, 'utf-8').replace(lineBreak, '');
38
+ };
39
+
40
+ var deleteFile = function(filename) {
41
+ if (isWindows)
42
+ exec('del /q /f ' + filename);
43
+ else
44
+ exec('rm ' + filename);
45
+ };
46
+
47
+ exports.commandsSuite = vows.describe('binary commands').addBatch({
48
+ 'no options': binaryContext('', {
49
+ 'should output help': function(stdout) {
50
+ assert.equal(/Usage:/.test(stdout), true);
51
+ }
52
+ }),
53
+ 'help': binaryContext('-h', {
54
+ 'should output help': function(error, stdout) {
55
+ assert.equal(/Usage:/.test(stdout), true);
56
+ },
57
+ 'should output one file example': function(error, stdout) {
58
+ assert.equal(stdout.indexOf('cleancss -o one-min.css one.css') > -1, true);
59
+ },
60
+ 'should output multiple files example': function(error, stdout) {
61
+ assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss -o merged-and-minified.css') > -1, true);
62
+ },
63
+ 'should output gzipping multiple files example': function(error, stdout) {
64
+ assert.equal(stdout.indexOf('cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz') > -1, true);
65
+ }
66
+ }),
67
+ 'version': binaryContext('-v', {
68
+ 'should output help': function(error, stdout) {
69
+ var version = JSON.parse(fs.readFileSync('./package.json')).version;
70
+ assert.equal(stdout, version + '\n');
71
+ }
72
+ }),
73
+ 'stdin': pipedContext('a{color: #f00}', '', {
74
+ 'should output data': function(error, stdout) {
75
+ assert.equal(stdout, 'a{color:red}');
76
+ }
77
+ }),
78
+ 'strip all but first comment': pipedContext('/*!1st*//*! 2nd */a{display:block}', '--s1', {
79
+ 'should keep the 2nd comment': function(error, stdout) {
80
+ assert.equal(stdout, '/*!1st*/a{display:block}');
81
+ }
82
+ }),
83
+ 'strip all comments': pipedContext('/*!1st*//*! 2nd */a{display:block}', '--s0', {
84
+ 'should keep the 2nd comment': function(error, stdout) {
85
+ assert.equal(stdout, 'a{display:block}');
86
+ }
87
+ }),
88
+ 'piped with debug info': pipedContext('a{color: #f00;}', '-d', {
89
+ 'should output content to stdout and debug info to stderr': function(error, stdout, stderr) {
90
+ assert.equal(stdout, 'a{color:red}');
91
+ assert.notEqual(stderr, '');
92
+ assert.include(stderr, 'Time spent:');
93
+ assert.include(stderr, 'Original: 16 bytes');
94
+ assert.include(stderr, 'Minified: 12 bytes');
95
+ assert.include(stderr, 'Efficiency: 25%');
96
+ }
97
+ }),
98
+ 'piped with debug info on inlining': pipedContext('@import url(test/data/imports-min.css);', '-d', {
99
+ 'should output inlining info': function(error, stdout, stderr) {
100
+ assert.include(stderr, path.join(process.cwd(), 'test/data/imports-min.css'));
101
+ }
102
+ }),
103
+ 'piped with correct debug info on inlining': pipedContext('@import url(test/data/imports.css);', '-d', {
104
+ 'should output correct info': function(error, stdout, stderr) {
105
+ assert.include(stderr, 'Original: 120 bytes');
106
+ assert.include(stderr, 'Minified: 86 bytes');
107
+ assert.include(stderr, 'Efficiency: 28.33%');
108
+ }
109
+ }),
110
+ 'to output file with debug info': pipedContext('a{color: #f00;}', '-d -o debug.css', {
111
+ 'should output nothing to stdout and debug info to stderr': function(error, stdout, stderr) {
112
+ assert.equal(stdout, '');
113
+ assert.notEqual(stderr, '');
114
+ assert.include(stderr, 'Time spent:');
115
+ assert.include(stderr, 'Original: 16 bytes');
116
+ assert.include(stderr, 'Minified: 12 bytes');
117
+ assert.include(stderr, 'Efficiency: 25%');
118
+ },
119
+ 'should output content to file': function() {
120
+ var minimized = readFile('debug.css');
121
+ assert.equal(minimized, 'a{color:red}');
122
+ },
123
+ teardown: function() {
124
+ deleteFile('debug.css');
125
+ }
126
+ }),
127
+ 'skip advanced optimizations': pipedContext('a{color:red}p{color:red}', '--skip-advanced', {
128
+ 'should do basic optimizations only': function(error, stdout) {
129
+ assert.equal(stdout, 'a{color:red}p{color:red}');
130
+ }
131
+ }),
132
+ 'no relative to path': binaryContext('./test/data/partials-absolute/base.css', {
133
+ 'should not be able to resolve it fully': function(error, stdout, stderr) {
134
+ assert.equal(stdout, '');
135
+ assert.notEqual(error, null);
136
+ assert.notEqual(stderr, '');
137
+ }
138
+ }),
139
+ 'relative to path': binaryContext('-r ./test/data ./test/data/partials-absolute/base.css', {
140
+ 'should be able to resolve it': function(error, stdout) {
141
+ assert.equal(stdout, '.base2{border-width:0}.sub{padding:0}.base{margin:0}');
142
+ }
143
+ }),
144
+ 'from source': binaryContext('./test/data/reset.css', {
145
+ 'should minimize': function(error, stdout) {
146
+ var minimized = fs.readFileSync('./test/data/reset-min.css', 'utf-8').replace(lineBreak, '');
147
+ assert.equal(stdout, minimized);
148
+ }
149
+ }),
150
+ 'from multiple sources': binaryContext('./test/data/partials/one.css ./test/data/partials/five.css', {
151
+ 'should minimize all': function(error, stdout) {
152
+ assert.equal(stdout, '.one{color:red}.five{background:url(data:image/jpeg;base64,/9j/)}');
153
+ }
154
+ }),
155
+ 'to file': binaryContext('-o ./reset1-min.css ./test/data/reset.css', {
156
+ 'should give no output': function(error, stdout) {
157
+ assert.equal(stdout, '');
158
+ },
159
+ 'should minimize': function() {
160
+ var minimized = readFile('./test/data/reset-min.css');
161
+ var target = readFile('./reset1-min.css');
162
+ assert.equal(minimized, target);
163
+ },
164
+ teardown: function() {
165
+ deleteFile('./reset1-min.css');
166
+ }
167
+ }),
168
+ 'disable @import': binaryContext('-s ./test/data/imports.css', {
169
+ 'should disable the import processing': function(error, stdout) {
170
+ assert.equal(stdout, '@import url(./partials/one.css);@import url(./partials/two.css);.imports{color:#000}');
171
+ }
172
+ }),
173
+ 'relative image paths': {
174
+ 'no root & output': binaryContext('./test/data/partials-relative/base.css', {
175
+ 'should leave paths': function(error, stdout) {
176
+ assert.equal(stdout, 'a{background:url(../partials/extra/down.gif) no-repeat}');
177
+ }
178
+ }),
179
+ 'root but no output': binaryContext('-r ./test ./test/data/partials-relative/base.css', {
180
+ 'should rewrite path relative to ./test': function(error, stdout) {
181
+ assert.equal(stdout, 'a{background:url(/data/partials/extra/down.gif) no-repeat}');
182
+ }
183
+ }),
184
+ 'no root but output': binaryContext('-o ./base1-min.css ./test/data/partials-relative/base.css', {
185
+ 'should rewrite path relative to current path': function() {
186
+ var minimized = readFile('./base1-min.css');
187
+ assert.equal(minimized, 'a{background:url(test/data/partials/extra/down.gif) no-repeat}');
188
+ },
189
+ teardown: function() {
190
+ deleteFile('./base1-min.css');
191
+ }
192
+ }),
193
+ 'root and output': binaryContext('-r ./test/data -o ./base2-min.css ./test/data/partials-relative/base.css', {
194
+ 'should rewrite path relative to ./test/data/': function() {
195
+ var minimized = readFile('./base2-min.css');
196
+ assert.equal(minimized, 'a{background:url(/partials/extra/down.gif) no-repeat}');
197
+ },
198
+ teardown: function() {
199
+ deleteFile('./base2-min.css');
200
+ }
201
+ }),
202
+ 'piped with output': pipedContext('a{background:url(test/data/partials/extra/down.gif)}', '-o base3-min.css', {
203
+ 'should keep paths as they are': function() {
204
+ var minimized = readFile('base3-min.css');
205
+ assert.equal(minimized, 'a{background:url(test/data/partials/extra/down.gif)}');
206
+ },
207
+ teardown: function() {
208
+ deleteFile('base3-min.css');
209
+ }
210
+ })
211
+ },
212
+ 'complex import and url rebasing': {
213
+ absolute: binaryContext('-r ./test/data/129-assets ./test/data/129-assets/assets/ui.css', {
214
+ 'should rebase urls correctly': function(error, stdout) {
215
+ assert.equal(error, null);
216
+ assert.include(stdout, 'url(/components/bootstrap/images/glyphs.gif)');
217
+ assert.include(stdout, 'url(/components/jquery-ui/images/prev.gif)');
218
+ assert.include(stdout, 'url(/components/jquery-ui/images/next.gif)');
219
+ }
220
+ }),
221
+ relative: binaryContext('-o ./test/data/129-assets/assets/ui.bundled.css ./test/data/129-assets/assets/ui.css', {
222
+ 'should rebase urls correctly': function() {
223
+ var minimized = readFile('./test/data/129-assets/assets/ui.bundled.css');
224
+ assert.include(minimized, 'url(../components/bootstrap/images/glyphs.gif)');
225
+ assert.include(minimized, 'url(../components/jquery-ui/images/prev.gif)');
226
+ assert.include(minimized, 'url(../components/jquery-ui/images/next.gif)');
227
+ },
228
+ teardown: function() {
229
+ deleteFile('./test/data/129-assets/assets/ui.bundled.css');
230
+ }
231
+ })
232
+ },
233
+ 'complex import and skipped url rebasing': {
234
+ absolute: binaryContext('-r ./test/data/129-assets --skip-rebase ./test/data/129-assets/assets/ui.css', {
235
+ 'should rebase urls correctly': function(error, stdout) {
236
+ assert.equal(error, null);
237
+ assert.include(stdout, 'url(../components/bootstrap/images/glyphs.gif)');
238
+ assert.include(stdout, 'url(../components/jquery-ui/images/prev.gif)');
239
+ assert.include(stdout, 'url(../components/jquery-ui/images/next.gif)');
240
+ }
241
+ })
242
+ },
243
+ 'remote import': {
244
+ topic: function() {
245
+ this.server = http.createServer(function (req, res) {
246
+ res.writeHead(200);
247
+ res.end('p{font-size:13px}');
248
+ }).listen(31991, '127.0.0.1');
249
+
250
+ this.callback(null);
251
+ },
252
+ 'of a file': binaryContext('http://127.0.0.1:31991/present.css', {
253
+ succeeds: function(error, stdout) {
254
+ assert.equal(error, null);
255
+ assert.equal(stdout, 'p{font-size:13px}');
256
+ }
257
+ }),
258
+ teardown: function() {
259
+ this.server.close();
260
+ }
261
+ },
262
+ 'timeout': unixOnlyContext({
263
+ topic: function() {
264
+ var self = this;
265
+ var source = '@import url(http://localhost:24682/timeout.css);';
266
+
267
+ this.server = http.createServer(function() {
268
+ setTimeout(function() {}, 1000);
269
+ });
270
+ this.server.listen('24682', function() {
271
+ exec('echo "' + source + '" | ./bin/cleancss --timeout 0.01', self.callback);
272
+ });
273
+ },
274
+ 'should raise warning': function(error, stdout, stderr) {
275
+ assert.include(stderr, 'Broken @import declaration of "http://localhost:24682/timeout.css" - timeout');
276
+ },
277
+ 'should output empty response': function(error, stdout) {
278
+ assert.equal(stdout, '');
279
+ },
280
+ teardown: function() {
281
+ this.server.close();
282
+ }
283
+ }),
284
+ 'ie7 compatibility': binaryContext('--compatibility ie7 ./test/data/unsupported/selectors-ie7.css', {
285
+ 'should not transform source': function(error, stdout) {
286
+ assert.equal(stdout, readFile('./test/data/unsupported/selectors-ie7.css'));
287
+ }
288
+ }),
289
+ 'ie8 compatibility': binaryContext('--compatibility ie8 ./test/data/unsupported/selectors-ie8.css', {
290
+ 'should not transform source': function(error, stdout) {
291
+ assert.equal(stdout, readFile('./test/data/unsupported/selectors-ie8.css'));
292
+ }
293
+ }),
294
+ 'rounding precision': {
295
+ defaults: pipedContext('div{width:0.10051px}', '', {
296
+ 'should keep 2 decimal places': function(error, stdout) {
297
+ assert.equal(stdout, 'div{width:.1px}');
298
+ }
299
+ }),
300
+ custom: pipedContext('div{width:0.00051px}', '--rounding-precision 4', {
301
+ 'should keep 4 decimal places': function(error, stdout) {
302
+ assert.equal(stdout, 'div{width:.0005px}');
303
+ }
304
+ }),
305
+ zero: pipedContext('div{width:1.5051px}', '--rounding-precision 0', {
306
+ 'should keep 0 decimal places': function(error, stdout) {
307
+ assert.equal(stdout, 'div{width:1px}');
308
+ }
309
+ })
310
+ },
311
+ 'neighbour merging': {
312
+ 'of (yet) unmergeable properties': pipedContext('a{display:inline-block;color:red;display:-moz-block}', '--skip-aggressive-merging', {
313
+ 'gets right result': function(error, stdout) {
314
+ assert.equal(stdout, 'a{display:inline-block;color:red;display:-moz-block}');
315
+ }
316
+ }),
317
+ 'of mergeable properties': pipedContext('a{background:red;display:block;background:white}', '--skip-aggressive-merging', {
318
+ 'gets right result': function(error, stdout) {
319
+ assert.equal(stdout, 'a{display:block;background:#fff}');
320
+ }
321
+ })
322
+ }
323
+ });
@@ -0,0 +1 @@
1
+ @import '../data/blueprint.css';
@@ -0,0 +1,4 @@
1
+ @import '../data/reset.css';
2
+ @import '_partial.css';
3
+ @import '../data/960.css';
4
+ @import '../data/big.css';
@@ -0,0 +1,2 @@
1
+ @import url(../components/bootstrap/css/bootstrap.css);
2
+ @import url(../components/jquery-ui/css/style.css);
@@ -0,0 +1,3 @@
1
+ .icon {
2
+ background:url(../images/glyphs.gif) 0 0 no-repeat;
3
+ }
@@ -0,0 +1,6 @@
1
+ .prev {
2
+ background:url(../images/prev.gif) 0 0 no-repeat;
3
+ }
4
+ .next {
5
+ background:url(../images/next.gif) 0 0 no-repeat;
6
+ }
@@ -0,0 +1,125 @@
1
+ .container_24{margin-right:auto;margin-left:auto;width:960px}
2
+ .grid_1,.grid_10,.grid_11,.grid_12,.grid_13,.grid_14,.grid_15,.grid_16,.grid_17,.grid_18,.grid_19,.grid_2,.grid_20,.grid_21,.grid_22,.grid_23,.grid_24,.grid_3,.grid_4,.grid_5,.grid_6,.grid_7,.grid_8,.grid_9{display:inline;float:right;margin-right:5px;margin-left:5px}
3
+ .pull_1,.pull_10,.pull_11,.pull_12,.pull_13,.pull_14,.pull_15,.pull_16,.pull_17,.pull_18,.pull_19,.pull_2,.pull_20,.pull_21,.pull_22,.pull_23,.pull_3,.pull_4,.pull_5,.pull_6,.pull_7,.pull_8,.pull_9,.push_1,.push_10,.push_11,.push_12,.push_13,.push_14,.push_15,.push_16,.push_17,.push_18,.push_19,.push_2,.push_20,.push_21,.push_22,.push_23,.push_3,.push_4,.push_5,.push_6,.push_7,.push_8,.push_9{position:relative}
4
+ .alpha{margin-right:0}
5
+ .omega{margin-left:0}
6
+ .container_24 .grid_1{width:30px}
7
+ .container_24 .grid_2{width:70px}
8
+ .container_24 .grid_3{width:110px}
9
+ .container_24 .grid_4{width:150px}
10
+ .container_24 .grid_5{width:190px}
11
+ .container_24 .grid_6{width:230px}
12
+ .container_24 .grid_7{width:270px}
13
+ .container_24 .grid_8{width:310px}
14
+ .container_24 .grid_9{width:350px}
15
+ .container_24 .grid_10{width:390px}
16
+ .container_24 .grid_11{width:430px}
17
+ .container_24 .grid_12{width:470px}
18
+ .container_24 .grid_13{width:510px}
19
+ .container_24 .grid_14{width:550px}
20
+ .container_24 .grid_15{width:590px}
21
+ .container_24 .grid_16{width:630px}
22
+ .container_24 .grid_17{width:670px}
23
+ .container_24 .grid_18{width:710px}
24
+ .container_24 .grid_19{width:750px}
25
+ .container_24 .grid_20{width:790px}
26
+ .container_24 .grid_21{width:830px}
27
+ .container_24 .grid_22{width:870px}
28
+ .container_24 .grid_23{width:910px}
29
+ .container_24 .grid_24{width:950px}
30
+ .container_24 .prefix_1{padding-right:40px}
31
+ .container_24 .prefix_2{padding-right:80px}
32
+ .container_24 .prefix_3{padding-right:120px}
33
+ .container_24 .prefix_4{padding-right:160px}
34
+ .container_24 .prefix_5{padding-right:200px}
35
+ .container_24 .prefix_6{padding-right:240px}
36
+ .container_24 .prefix_7{padding-right:280px}
37
+ .container_24 .prefix_8{padding-right:320px}
38
+ .container_24 .prefix_9{padding-right:360px}
39
+ .container_24 .prefix_10{padding-right:400px}
40
+ .container_24 .prefix_11{padding-right:440px}
41
+ .container_24 .prefix_12{padding-right:480px}
42
+ .container_24 .prefix_13{padding-right:520px}
43
+ .container_24 .prefix_14{padding-right:560px}
44
+ .container_24 .prefix_15{padding-right:600px}
45
+ .container_24 .prefix_16{padding-right:640px}
46
+ .container_24 .prefix_17{padding-right:680px}
47
+ .container_24 .prefix_18{padding-right:720px}
48
+ .container_24 .prefix_19{padding-right:760px}
49
+ .container_24 .prefix_20{padding-right:800px}
50
+ .container_24 .prefix_21{padding-right:840px}
51
+ .container_24 .prefix_22{padding-right:880px}
52
+ .container_24 .prefix_23{padding-right:920px}
53
+ .container_24 .suffix_1{padding-left:40px}
54
+ .container_24 .suffix_2{padding-left:80px}
55
+ .container_24 .suffix_3{padding-left:120px}
56
+ .container_24 .suffix_4{padding-left:160px}
57
+ .container_24 .suffix_5{padding-left:200px}
58
+ .container_24 .suffix_6{padding-left:240px}
59
+ .container_24 .suffix_7{padding-left:280px}
60
+ .container_24 .suffix_8{padding-left:320px}
61
+ .container_24 .suffix_9{padding-left:360px}
62
+ .container_24 .suffix_10{padding-left:400px}
63
+ .container_24 .suffix_11{padding-left:440px}
64
+ .container_24 .suffix_12{padding-left:480px}
65
+ .container_24 .suffix_13{padding-left:520px}
66
+ .container_24 .suffix_14{padding-left:560px}
67
+ .container_24 .suffix_15{padding-left:600px}
68
+ .container_24 .suffix_16{padding-left:640px}
69
+ .container_24 .suffix_17{padding-left:680px}
70
+ .container_24 .suffix_18{padding-left:720px}
71
+ .container_24 .suffix_19{padding-left:760px}
72
+ .container_24 .suffix_20{padding-left:800px}
73
+ .container_24 .suffix_21{padding-left:840px}
74
+ .container_24 .suffix_22{padding-left:880px}
75
+ .container_24 .suffix_23{padding-left:920px}
76
+ .container_24 .push_1{right:40px}
77
+ .container_24 .push_2{right:80px}
78
+ .container_24 .push_3{right:120px}
79
+ .container_24 .push_4{right:160px}
80
+ .container_24 .push_5{right:200px}
81
+ .container_24 .push_6{right:240px}
82
+ .container_24 .push_7{right:280px}
83
+ .container_24 .push_8{right:320px}
84
+ .container_24 .push_9{right:360px}
85
+ .container_24 .push_10{right:400px}
86
+ .container_24 .push_11{right:440px}
87
+ .container_24 .push_12{right:480px}
88
+ .container_24 .push_13{right:520px}
89
+ .container_24 .push_14{right:560px}
90
+ .container_24 .push_15{right:600px}
91
+ .container_24 .push_16{right:640px}
92
+ .container_24 .push_17{right:680px}
93
+ .container_24 .push_18{right:720px}
94
+ .container_24 .push_19{right:760px}
95
+ .container_24 .push_20{right:800px}
96
+ .container_24 .push_21{right:840px}
97
+ .container_24 .push_22{right:880px}
98
+ .container_24 .push_23{right:920px}
99
+ .container_24 .pull_1{right:-40px}
100
+ .container_24 .pull_2{right:-80px}
101
+ .container_24 .pull_3{right:-120px}
102
+ .container_24 .pull_4{right:-160px}
103
+ .container_24 .pull_5{right:-200px}
104
+ .container_24 .pull_6{right:-240px}
105
+ .container_24 .pull_7{right:-280px}
106
+ .container_24 .pull_8{right:-320px}
107
+ .container_24 .pull_9{right:-360px}
108
+ .container_24 .pull_10{right:-400px}
109
+ .container_24 .pull_11{right:-440px}
110
+ .container_24 .pull_12{right:-480px}
111
+ .container_24 .pull_13{right:-520px}
112
+ .container_24 .pull_14{right:-560px}
113
+ .container_24 .pull_15{right:-600px}
114
+ .container_24 .pull_16{right:-640px}
115
+ .container_24 .pull_17{right:-680px}
116
+ .container_24 .pull_18{right:-720px}
117
+ .container_24 .pull_19{right:-760px}
118
+ .container_24 .pull_20{right:-800px}
119
+ .container_24 .pull_21{right:-840px}
120
+ .container_24 .pull_22{right:-880px}
121
+ .container_24 .pull_23{right:-920px}
122
+ .clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}
123
+ .clearfix:after,.clearfix:before{content:'\0020';display:block;overflow:hidden;visibility:hidden;width:0;height:0}
124
+ .clearfix:after{clear:both}
125
+ .clearfix{zoom:1}