ruby-clean-css 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.
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,5 @@
1
+ .one{color:red}
2
+ .three{color:#0f0}
3
+ .four{color:#00f}
4
+ .two{color:#fff}
5
+ .imports{color:#000}
@@ -0,0 +1,4 @@
1
+ @import url('./partials/one.css');
2
+ @import url("./partials/two.css");
3
+
4
+ .imports { color: #000; }
@@ -0,0 +1,3 @@
1
+ @media only print{a,a:visited{text-decoration:underline}
2
+ a[href]:after{content:" (" attr(href) ")"}
3
+ abbr[title]:after{content:" (" attr(title) ")"}}
@@ -0,0 +1,19 @@
1
+ @media print, (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) {
2
+ /* Style adjustments for high resolution devices */
3
+ }
4
+ /**===================================================**\
5
+ /** PRINT STYLES
6
+ /**===================================================**/
7
+ @media only print {
8
+ a,
9
+ a:visited {
10
+ text-decoration: underline;
11
+ }
12
+ a[href]:after {
13
+ content: " (" attr(href) ")";
14
+ }
15
+ abbr[title]:after {
16
+ content: " (" attr(title) ")";
17
+ }
18
+ /** MANUALLY TRUNCATED FOR BREVITY **/
19
+ }
@@ -0,0 +1,7 @@
1
+ .zocial.acrobat:before{content:"\00E3";color:#FB0000}
2
+ .zocial.amazon:before{content:"a"}
3
+ .zocial.android:before{content:"&"}
4
+ .zocial.angellist:before{content:"\00D6"}
5
+ .zocial.aol:before{content:"\""}
6
+ .zocial.appnet:before{content:"\00E1"}
7
+ .zocial.appstore:before{content:"A"}
@@ -0,0 +1,7 @@
1
+ .zocial.acrobat:before {content: "\00E3"; color: #FB0000;}
2
+ .zocial.amazon:before {content: "a";}
3
+ .zocial.android:before {content: "&";}
4
+ .zocial.angellist:before {content: "\00D6";}
5
+ .zocial.aol:before {content: "\"";}
6
+ .zocial.appnet:before {content: "\00E1";}
7
+ .zocial.appstore:before {content: "A";}
@@ -0,0 +1 @@
1
+ .vrac{overflow:hidden;position:relative}
@@ -0,0 +1,8 @@
1
+ /*
2
+ @import url(//fonts.googleapis.com/css?family=PT+Sans+Caption:400italic,400,700italic,700);
3
+ @import url(//fonts.googleapis.com/css?family=Droid+Sans:400,700);
4
+ */
5
+ .vrac {
6
+ overflow: hidden;
7
+ position: relative
8
+ }
@@ -0,0 +1,3 @@
1
+ .one{color:red}
2
+ .three{background-image:url(partials/extra/down.gif)}
3
+ .imports-with-comment{color:#999}
@@ -0,0 +1,4 @@
1
+ @import url('./partials/one.css');
2
+ @import url('./partials/three.css');
3
+ /*some comment, you guys!*/
4
+ .imports-with-comment { color: #999; }
@@ -0,0 +1,2 @@
1
+ .bar{padding:0}
2
+ .bug-selector,.bug-selector1{background:url(images/b-toolbar.gif) #000;background:linear-gradient(#5e6081,#353340)}
@@ -0,0 +1,17 @@
1
+ .bug-selector,
2
+ .bug-selector1
3
+ {
4
+ background: red;
5
+ }
6
+
7
+ .bar
8
+ {
9
+ padding: 0;
10
+ }
11
+
12
+ .bug-selector,
13
+ .bug-selector1
14
+ {
15
+ background: black url('images/b-toolbar.gif');
16
+ background: linear-gradient(#5e6081, #353340);
17
+ }
@@ -0,0 +1,2 @@
1
+ .c4:not(.c1,.c2){width:1px}
2
+ @media (min-width:1px){.c3{width:1px}}
@@ -0,0 +1,2 @@
1
+ .c4:not(.c1, .c2){width: 1px;}
2
+ @media (min-width: 1px) { .c3{width: 1px;} }
@@ -0,0 +1 @@
1
+ .test{background:url(top.png) left 0 top -12px no-repeat,url(bottom.png) left 0 bottom -12px no-repeat,url(middle.png) left 0 top 0 no-repeat}
@@ -0,0 +1,4 @@
1
+ .test {
2
+ background: url(top.png) no-repeat, url(bottom.png) no-repeat, url(middle.png) no-repeat;
3
+ background-position: left 0px top -12px, left 0px bottom -12px, left 0px top 0px;
4
+ }
@@ -0,0 +1 @@
1
+ div{border-width:thin}
@@ -0,0 +1,3 @@
1
+ div {
2
+ border-width: thin;
3
+ }
@@ -0,0 +1 @@
1
+ p{background-image:url(/*)}
@@ -0,0 +1,5 @@
1
+ p {
2
+ background-image: url('/*');
3
+ }
4
+
5
+ /* */
@@ -0,0 +1 @@
1
+ .envelope{background:url(one.png) top center/35px 4px repeat-x,url(one.png) bottom center/35px 4px repeat-x,url(two.png) 110% 10px/101px 61px no-repeat #eee}
@@ -0,0 +1,7 @@
1
+ .envelope {
2
+ background: url(one.png), url(one.png), url(two.png);
3
+ background-color: #eee;
4
+ background-repeat: repeat-x, repeat-x, no-repeat;
5
+ background-size: 35px 4px, 35px 4px, 101px 61px;
6
+ background-position: top center, bottom center, 110% 10px;
7
+ }
@@ -0,0 +1 @@
1
+ div{background:#fff!important}
@@ -0,0 +1,4 @@
1
+ div {
2
+ background: #eeeeee !important;
3
+ background-color: #ffffff !important;
4
+ }
@@ -0,0 +1,2 @@
1
+ .test[title="my very long title"]{background-image:url(very/long/path)}
2
+ .test[title=my_very_long_title]{background-image:url(my/very/long/path)}
@@ -0,0 +1,8 @@
1
+ .test[title="my very long \
2
+ title"]{background-image:url("very/long/\
3
+ path")}
4
+ .test[title="my_very_long_\
5
+ title"] {
6
+ background-image: url("my/very/long/\
7
+ path")
8
+ }
@@ -0,0 +1,3 @@
1
+ @import url(./extra/sub.css);
2
+
3
+ .base { margin:0px }
@@ -0,0 +1 @@
1
+ .base2 { border-width:0px }
@@ -0,0 +1,3 @@
1
+ @import url(/partials-absolute/base2.css);
2
+
3
+ .sub { padding:0px }
@@ -0,0 +1,3 @@
1
+ a {
2
+ background:url(../partials/extra/down.gif) 0 0 no-repeat;
3
+ }
@@ -0,0 +1,2 @@
1
+ /* comment to be stripped */
2
+ a{display:block}
@@ -0,0 +1,3 @@
1
+ @import url('../two.css');
2
+
3
+ .four { color:#00f; }
@@ -0,0 +1 @@
1
+ .three { color:#0f0; }
@@ -0,0 +1 @@
1
+ .five{background:url(data:image/jpeg;base64,/9j/)}
@@ -0,0 +1 @@
1
+ .four {background-image: url(/partials/extra/down.gif);}
@@ -0,0 +1 @@
1
+ .one { color:#f00; }
@@ -0,0 +1 @@
1
+ .three {background-image: url(extra/down.gif);}
@@ -0,0 +1,5 @@
1
+ @import url('one.css');
2
+ @import url('extra/three.css');
3
+ @import url('./extra/four.css');
4
+
5
+ .two { color:#fff; }
@@ -0,0 +1,12 @@
1
+ a,abbr,acronym,address,applet,big,blockquote,body,caption,cite,code,dd,del,dfn,div,dl,dt,em,fieldset,font,form,h1,h2,h3,h4,h5,h6,html,iframe,img,ins,kbd,label,legend,li,object,ol,p,pre,q,s,samp,small,span,strike,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,tt,ul,var{margin:0;padding:0;border:0;outline:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline}
2
+ :focus{outline:0}
3
+ body{line-height:1;color:#000;background:#fff}
4
+ ol,ul{list-style:none}
5
+ table{border-collapse:separate;border-spacing:0}
6
+ caption,td,th{text-align:left;font-weight:400}
7
+ blockquote:after,blockquote:before,q:after,q:before{content:""}
8
+ blockquote,q{quotes:"" ""}
9
+ .clear{clear:both}
10
+ .clear:after,.container:after{content:".";display:block;height:0;clear:both;visibility:hidden}
11
+ * html .clear{height:1%}
12
+ .clear{display:block}
@@ -0,0 +1,64 @@
1
+ /*reset*/
2
+ html, body, div, span, applet, object, iframe,
3
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4
+ a, abbr, acronym, address, big, cite, code,
5
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
6
+ small, strike, strong, sub, sup, tt, var,
7
+ dl, dt, dd, ol, ul, li,
8
+ fieldset, form, label, legend,
9
+ table, caption, tbody, tfoot, thead, tr, th, td {
10
+ margin: 0;
11
+ padding: 0;
12
+ border: 0;
13
+ outline: 0;
14
+ font-weight: inherit;
15
+ font-style: inherit;
16
+ font-size: 100%;
17
+ font-family: inherit;
18
+ vertical-align: baseline;
19
+ }
20
+ /* remember to define focus styles! */
21
+ :focus {
22
+ outline: 0;
23
+ }
24
+ body {
25
+ line-height: 1;
26
+ color: black;
27
+ background: white;
28
+ }
29
+ ol, ul {
30
+ list-style: none;
31
+ }
32
+ /* tables still need 'cellspacing="0"' in the markup */
33
+ table {
34
+ border-collapse: separate;
35
+ border-spacing: 0;
36
+ }
37
+ caption, th, td {
38
+ text-align: left;
39
+ font-weight: normal;
40
+ }
41
+ blockquote:before, blockquote:after,
42
+ q:before, q:after {
43
+ content: "";
44
+ }
45
+ blockquote, q {
46
+ quotes: "" "";
47
+ }
48
+ .clear {
49
+ clear:both;
50
+ display: inline-block;
51
+ }
52
+ .clear:after, .container:after {
53
+ content: ".";
54
+ display: block;
55
+ height: 0;
56
+ clear: both;
57
+ visibility: hidden;
58
+ }
59
+ * html .clear {
60
+ height: 1%;
61
+ }
62
+ .clear {
63
+ display: block;
64
+ }
@@ -0,0 +1,4 @@
1
+ .field ::-webkit-input-placeholder{color:#bbb}
2
+ .field :-moz-placeholder{color:#bbb}
3
+ .field :-ms-input-placeholder{color:#bbb}
4
+ .field.enabled ::-webkit-input-placeholder{opacity:0}
@@ -0,0 +1,12 @@
1
+ .field ::-webkit-input-placeholder {
2
+ color:#bbb;
3
+ }
4
+ .field :-moz-placeholder {
5
+ color:#bbb;
6
+ }
7
+ .field :-ms-input-placeholder {
8
+ color:#bbb;
9
+ }
10
+ .field.enabled ::-webkit-input-placeholder {
11
+ opacity:0;
12
+ }
@@ -0,0 +1,20 @@
1
+ p:focus{top:0}
2
+ p:before{top:0}
3
+ p:after{top:0}
4
+ p:root{top:0}
5
+ p:nth-of-type(1){top:0}
6
+ p:nth-last-of-type(1){top:0}
7
+ p:first-of-type{top:0}
8
+ p:last-of-type{top:0}
9
+ p:only-of-type{top:0}
10
+ p:only-child{top:0}
11
+ p:last-child{top:0}
12
+ p:nth-child(1){top:0}
13
+ p:nth-last-child(1){top:0}
14
+ p:empty{top:0}
15
+ p:target{top:0}
16
+ p:checked{top:0}
17
+ p::selection{top:0}
18
+ input:enabled{top:0}
19
+ input:disabled{top:0}
20
+ p:not(.x){top:0}
@@ -0,0 +1,17 @@
1
+ p:root{top:0}
2
+ p:nth-of-type(1){top:0}
3
+ p:nth-last-of-type(1){top:0}
4
+ p:first-of-type{top:0}
5
+ p:last-of-type{top:0}
6
+ p:only-of-type{top:0}
7
+ p:only-child{top:0}
8
+ p:last-child{top:0}
9
+ p:nth-child(1){top:0}
10
+ p:nth-last-child(1){top:0}
11
+ p:empty{top:0}
12
+ p:target{top:0}
13
+ p:checked{top:0}
14
+ p::selection{top:0}
15
+ input:enabled{top:0}
16
+ input:disabled{top:0}
17
+ p:not(.x){top:0}
@@ -0,0 +1,185 @@
1
+ var vows = require('vows');
2
+ var assert = require('assert');
3
+ var CleanCSS = require('../index');
4
+
5
+ vows.describe('module tests').addBatch({
6
+ 'imported as a function': {
7
+ topic: function() {
8
+ var css = new CleanCSS();
9
+ return css.minify.bind(css);
10
+ },
11
+ 'should minify CSS correctly': function(minify) {
12
+ assert.equal(minify('a{ color: #f00; }'), 'a{color:red}');
13
+ }
14
+ },
15
+ 'initialization without new (back-compat)': {
16
+ topic: function() {
17
+ return CleanCSS();
18
+ },
19
+ 'should have stats, errors, etc.': function(css) {
20
+ assert.isObject(css.stats);
21
+ assert.isArray(css.errors);
22
+ assert.isArray(css.warnings);
23
+ assert.isString(css.lineBreak);
24
+ },
25
+ 'should minify CSS correctly': function(css) {
26
+ assert.equal(css.minify('a{ color: #f00; }'), 'a{color:red}');
27
+ }
28
+ },
29
+ 'extended via prototype': {
30
+ topic: function() {
31
+ CleanCSS.prototype.foo = function(data, callback) {
32
+ callback(null, this.minify(data));
33
+ };
34
+ new CleanCSS().foo('a{ color: #f00; }', this.callback);
35
+ },
36
+ 'should minify CSS correctly': function(error, minified) {
37
+ assert.equal(minified, 'a{color:red}');
38
+ },
39
+ teardown: function() {
40
+ delete CleanCSS.prototype.foo;
41
+ }
42
+ },
43
+ 'with callback passed and no errors': {
44
+ topic: function() {
45
+ new CleanCSS().minify('a{color:#f00}', this.callback);
46
+ },
47
+ 'should correctly set context': function() {
48
+ assert.equal(true, this instanceof CleanCSS);
49
+ },
50
+ 'should yield no error': function(errors, minified) {
51
+ /* jshint unused: false */
52
+ assert.equal(errors, null);
53
+ },
54
+ 'should yield minified data': function(errors, minified) {
55
+ assert.equal(minified, 'a{color:red}');
56
+ }
57
+ },
58
+ 'with callback passed and one error': {
59
+ topic: function() {
60
+ new CleanCSS().minify('@import "missing.css";', this.callback);
61
+ },
62
+ 'should yield no error and minify': function(errors, minified) {
63
+ /* jshint unused: false */
64
+ assert.equal(errors.length, 1);
65
+ }
66
+ },
67
+ 'no debug': {
68
+ topic: function() {
69
+ var minifier = new CleanCSS();
70
+ minifier.minify('a{ color: #f00 }');
71
+ return minifier;
72
+ },
73
+ 'should not populate stats hash': function(minifier) {
74
+ assert.deepEqual({}, minifier.stats);
75
+ }
76
+ },
77
+ 'debug': {
78
+ topic: function() {
79
+ var minifier = new CleanCSS({ debug: true });
80
+ minifier.minify('a{ color: #f00 }');
81
+ return minifier;
82
+ },
83
+ 'should give time taken': function(minifier) {
84
+ assert.isNumber(minifier.stats.timeSpent);
85
+ },
86
+ 'should give original size': function(minifier) {
87
+ assert.equal(minifier.stats.originalSize, 16);
88
+ },
89
+ 'should give minified size': function(minifier) {
90
+ assert.equal(minifier.stats.minifiedSize, 12);
91
+ },
92
+ 'should give efficiency': function(minifier) {
93
+ assert.equal(minifier.stats.efficiency, 0.25);
94
+ }
95
+ },
96
+ 'no warnings': {
97
+ topic: function() {
98
+ var minifier = new CleanCSS();
99
+ minifier.minify('a{color:red}');
100
+ return minifier;
101
+ },
102
+ 'if no reasons given': function(minifier) {
103
+ assert.deepEqual(minifier.warnings, []);
104
+ }
105
+ },
106
+ 'warnings': {
107
+ topic: function() {
108
+ var minifier = new CleanCSS({
109
+ root: 'test/data',
110
+ target: 'custom-warnings.css'
111
+ });
112
+ minifier.minify('a{color:red}');
113
+ return minifier;
114
+ },
115
+ 'if both root and output used reasons given': function(minifier) {
116
+ assert.equal(minifier.warnings.length, 1);
117
+ assert.match(minifier.warnings[0], /Both 'root' and output file given/);
118
+ }
119
+ },
120
+ 'warnings on extra closing brace': {
121
+ topic: function() {
122
+ var minifier = new CleanCSS();
123
+ var minified = minifier.minify('a{display:block}}');
124
+ this.callback(null, minified, minifier);
125
+ },
126
+ 'should minify correctly': function(error, minified) {
127
+ assert.equal(minified, 'a{display:block}');
128
+ },
129
+ 'should raise no errors': function(error, minified, minifier) {
130
+ assert.equal(minifier.errors.length, 0);
131
+ },
132
+ 'should raise one warning': function(error, minified, minifier) {
133
+ assert.equal(minifier.warnings.length, 1);
134
+ assert.equal(minifier.warnings[0], 'Unexpected \'}\' in \'a{display:block}}\'. Ignoring.');
135
+ }
136
+ },
137
+ 'warnings on unexpected body': {
138
+ topic: function() {
139
+ var minifier = new CleanCSS();
140
+ var minified = minifier.minify('a{display:block}color:#535353}p{color:red}');
141
+ this.callback(null, minified, minifier);
142
+ },
143
+ 'should minify correctly': function(error, minified) {
144
+ assert.equal(minified, 'a{display:block}p{color:red}');
145
+ },
146
+ 'should raise no errors': function(error, minified, minifier) {
147
+ assert.equal(minifier.errors.length, 0);
148
+ },
149
+ 'should raise one warning': function(error, minified, minifier) {
150
+ assert.equal(minifier.warnings.length, 1);
151
+ assert.equal(minifier.warnings[0], 'Unexpected content: \'color:#535353}\'. Ignoring.');
152
+ }
153
+ },
154
+ 'no errors': {
155
+ topic: function() {
156
+ var minifier = new CleanCSS();
157
+ minifier.minify('a{color:red}');
158
+ return minifier;
159
+ },
160
+ 'if no reasons given': function(minifier) {
161
+ assert.deepEqual(minifier.errors, []);
162
+ }
163
+ },
164
+ 'errors': {
165
+ topic: function() {
166
+ return new CleanCSS();
167
+ },
168
+ 'if both root and output used reasons given': function(minifier) {
169
+ assert.doesNotThrow(function() {
170
+ minifier.minify('@import url(/some/fake/file);', function(errors) {
171
+ assert.equal(errors.length, 1);
172
+ assert.equal(errors[0], 'Broken @import declaration of "/some/fake/file"');
173
+ });
174
+ });
175
+ }
176
+ },
177
+ 'buffer passed in': {
178
+ 'topic': function() {
179
+ return new CleanCSS().minify(new Buffer('@import url(test/data/partials/one.css);'));
180
+ },
181
+ 'should be processed correctly': function(minified) {
182
+ assert.equal('.one{color:red}', minified);
183
+ }
184
+ }
185
+ }).export(module);