multi_css 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/vendor/cssminify/.gitignore +9 -0
  2. data/vendor/cssminify/.travis.yml +7 -0
  3. data/vendor/cssminify/CHANGES.md +12 -0
  4. data/vendor/cssminify/Gemfile +4 -0
  5. data/vendor/cssminify/LICENSE.md +22 -0
  6. data/vendor/cssminify/README.md +64 -0
  7. data/vendor/cssminify/cssminify.gemspec +30 -0
  8. data/vendor/cssminify/lib/cssminify.rb +34 -0
  9. data/vendor/cssminify/lib/cssminify/cssmin.rb +383 -0
  10. data/vendor/cssminify/lib/cssminify/version.rb +5 -0
  11. data/vendor/cssminify/spec/cssminify_spec.rb +257 -0
  12. data/vendor/cssminify/spec/sample.css +100 -0
  13. data/vendor/cssminify/spec/spec_helper.rb +4 -0
  14. data/vendor/cssminify/spec/tests/background-position.css +2 -0
  15. data/vendor/cssminify/spec/tests/background-position.css.min +1 -0
  16. data/vendor/cssminify/spec/tests/border-none.css +5 -0
  17. data/vendor/cssminify/spec/tests/border-none.css.min +1 -0
  18. data/vendor/cssminify/spec/tests/box-model-hack.css +9 -0
  19. data/vendor/cssminify/spec/tests/box-model-hack.css.min +1 -0
  20. data/vendor/cssminify/spec/tests/bug2527974.css +10 -0
  21. data/vendor/cssminify/spec/tests/bug2527974.css.min +1 -0
  22. data/vendor/cssminify/spec/tests/bug2527991.css +19 -0
  23. data/vendor/cssminify/spec/tests/bug2527991.css.min +1 -0
  24. data/vendor/cssminify/spec/tests/bug2527998.css +4 -0
  25. data/vendor/cssminify/spec/tests/bug2527998.css.min +1 -0
  26. data/vendor/cssminify/spec/tests/bug2528034.css +5 -0
  27. data/vendor/cssminify/spec/tests/bug2528034.css.min +1 -0
  28. data/vendor/cssminify/spec/tests/bug2528093.css +3 -0
  29. data/vendor/cssminify/spec/tests/bug2528093.css.min +1 -0
  30. data/vendor/cssminify/spec/tests/charset-media.css +9 -0
  31. data/vendor/cssminify/spec/tests/charset-media.css.min +1 -0
  32. data/vendor/cssminify/spec/tests/color-simple.css +8 -0
  33. data/vendor/cssminify/spec/tests/color-simple.css.min +1 -0
  34. data/vendor/cssminify/spec/tests/color.css +46 -0
  35. data/vendor/cssminify/spec/tests/color.css.min +1 -0
  36. data/vendor/cssminify/spec/tests/comment.css +3 -0
  37. data/vendor/cssminify/spec/tests/comment.css.min +1 -0
  38. data/vendor/cssminify/spec/tests/concat-charset.css +15 -0
  39. data/vendor/cssminify/spec/tests/concat-charset.css.min +1 -0
  40. data/vendor/cssminify/spec/tests/dataurl-base64-doublequotes.css +23 -0
  41. data/vendor/cssminify/spec/tests/dataurl-base64-doublequotes.css.min +1 -0
  42. data/vendor/cssminify/spec/tests/dataurl-base64-eof.css +10 -0
  43. data/vendor/cssminify/spec/tests/dataurl-base64-eof.css.min +1 -0
  44. data/vendor/cssminify/spec/tests/dataurl-base64-linebreakindata.css +34 -0
  45. data/vendor/cssminify/spec/tests/dataurl-base64-linebreakindata.css.min +1 -0
  46. data/vendor/cssminify/spec/tests/dataurl-base64-noquotes.css +26 -0
  47. data/vendor/cssminify/spec/tests/dataurl-base64-noquotes.css.min +1 -0
  48. data/vendor/cssminify/spec/tests/dataurl-base64-singlequotes.css +23 -0
  49. data/vendor/cssminify/spec/tests/dataurl-base64-singlequotes.css.min +1 -0
  50. data/vendor/cssminify/spec/tests/dataurl-base64-twourls.css +27 -0
  51. data/vendor/cssminify/spec/tests/dataurl-base64-twourls.css.min +1 -0
  52. data/vendor/cssminify/spec/tests/dataurl-dbquote-font.css +30 -0
  53. data/vendor/cssminify/spec/tests/dataurl-dbquote-font.css.min +5 -0
  54. data/vendor/cssminify/spec/tests/dataurl-nonbase64-doublequotes.css +13 -0
  55. data/vendor/cssminify/spec/tests/dataurl-nonbase64-doublequotes.css.min +1 -0
  56. data/vendor/cssminify/spec/tests/dataurl-nonbase64-noquotes.css +11 -0
  57. data/vendor/cssminify/spec/tests/dataurl-nonbase64-noquotes.css.min +1 -0
  58. data/vendor/cssminify/spec/tests/dataurl-nonbase64-singlequotes.css +15 -0
  59. data/vendor/cssminify/spec/tests/dataurl-nonbase64-singlequotes.css.min +2 -0
  60. data/vendor/cssminify/spec/tests/dataurl-noquote-multiline-font.css +31 -0
  61. data/vendor/cssminify/spec/tests/dataurl-noquote-multiline-font.css.min +3 -0
  62. data/vendor/cssminify/spec/tests/dataurl-realdata-doublequotes.css +90 -0
  63. data/vendor/cssminify/spec/tests/dataurl-realdata-doublequotes.css.min +1 -0
  64. data/vendor/cssminify/spec/tests/dataurl-realdata-noquotes.css +90 -0
  65. data/vendor/cssminify/spec/tests/dataurl-realdata-noquotes.css.min +1 -0
  66. data/vendor/cssminify/spec/tests/dataurl-realdata-singlequotes.css +90 -0
  67. data/vendor/cssminify/spec/tests/dataurl-realdata-singlequotes.css.min +1 -0
  68. data/vendor/cssminify/spec/tests/dataurl-realdata-yuiapp.css +106 -0
  69. data/vendor/cssminify/spec/tests/dataurl-realdata-yuiapp.css.min +1 -0
  70. data/vendor/cssminify/spec/tests/dataurl-singlequote-font.css +30 -0
  71. data/vendor/cssminify/spec/tests/dataurl-singlequote-font.css.min +3 -0
  72. data/vendor/cssminify/spec/tests/decimals.css +3 -0
  73. data/vendor/cssminify/spec/tests/decimals.css.min +1 -0
  74. data/vendor/cssminify/spec/tests/dollar-header.css +7 -0
  75. data/vendor/cssminify/spec/tests/dollar-header.css.min +3 -0
  76. data/vendor/cssminify/spec/tests/font-face.css +6 -0
  77. data/vendor/cssminify/spec/tests/font-face.css.min +1 -0
  78. data/vendor/cssminify/spec/tests/ie5mac.css +5 -0
  79. data/vendor/cssminify/spec/tests/ie5mac.css.min +1 -0
  80. data/vendor/cssminify/spec/tests/media-empty-class.css +16 -0
  81. data/vendor/cssminify/spec/tests/media-empty-class.css.min +1 -0
  82. data/vendor/cssminify/spec/tests/media-multi.css +3 -0
  83. data/vendor/cssminify/spec/tests/media-multi.css.min +1 -0
  84. data/vendor/cssminify/spec/tests/media-test.css +3 -0
  85. data/vendor/cssminify/spec/tests/media-test.css.min +1 -0
  86. data/vendor/cssminify/spec/tests/opacity-filter.css +14 -0
  87. data/vendor/cssminify/spec/tests/opacity-filter.css.min +1 -0
  88. data/vendor/cssminify/spec/tests/preserve-case.css +15 -0
  89. data/vendor/cssminify/spec/tests/preserve-case.css.min +1 -0
  90. data/vendor/cssminify/spec/tests/preserve-new-line.css +6 -0
  91. data/vendor/cssminify/spec/tests/preserve-new-line.css.min +3 -0
  92. data/vendor/cssminify/spec/tests/preserve-strings.css +7 -0
  93. data/vendor/cssminify/spec/tests/preserve-strings.css.min +1 -0
  94. data/vendor/cssminify/spec/tests/pseudo-first.css +16 -0
  95. data/vendor/cssminify/spec/tests/pseudo-first.css.min +1 -0
  96. data/vendor/cssminify/spec/tests/pseudo.css +4 -0
  97. data/vendor/cssminify/spec/tests/pseudo.css.min +1 -0
  98. data/vendor/cssminify/spec/tests/special-comments.css +13 -0
  99. data/vendor/cssminify/spec/tests/special-comments.css.min +9 -0
  100. data/vendor/cssminify/spec/tests/star-underscore-hacks.css +5 -0
  101. data/vendor/cssminify/spec/tests/star-underscore-hacks.css.min +1 -0
  102. data/vendor/cssminify/spec/tests/string-in-comment.css +8 -0
  103. data/vendor/cssminify/spec/tests/string-in-comment.css.min +1 -0
  104. data/vendor/cssminify/spec/tests/webkit-transform.css +2 -0
  105. data/vendor/cssminify/spec/tests/webkit-transform.css.min +1 -0
  106. data/vendor/cssminify/spec/tests/zeros.css +12 -0
  107. data/vendor/cssminify/spec/tests/zeros.css.min +1 -0
  108. metadata +223 -0
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+
3
+ class CSSminify
4
+ VERSION = "1.0.2"
5
+ end
@@ -0,0 +1,257 @@
1
+ # coding: utf-8
2
+
3
+ require "spec_helper"
4
+
5
+
6
+ describe "CSSminify" do
7
+
8
+ context "application" do
9
+
10
+ it "minifies CSS" do
11
+ source = File.open(File.expand_path("../sample.css", __FILE__), "r:UTF-8").read
12
+ minified = CSSminify.compress(source)
13
+ minified.length.should < source.length
14
+ lambda {
15
+ CSSminify.compress(minified)
16
+ }.should_not raise_error
17
+ end
18
+
19
+ it "honors the specified maximum line length" do
20
+ source = <<-EOS
21
+ .classname1 {
22
+ border: none;
23
+ background: none;
24
+ outline: none;
25
+ }
26
+ .classname2 {
27
+ border: none;
28
+ background: none;
29
+ outline: none;
30
+ }
31
+ EOS
32
+ minified = CSSminify.compress(source, 30)
33
+ minified.split("\n").length.should eq(2)
34
+ minified.should eq(".classname1{border:0;background:0;outline:0}\n.classname2{border:0;background:0;outline:0}")
35
+ end
36
+
37
+ it "handles strings as input format" do
38
+ lambda {
39
+ CSSminify.compress(File.open(File.expand_path("../sample.css", __FILE__), "r:UTF-8").read).should_not be_empty
40
+ }.should_not raise_error
41
+ end
42
+
43
+ it "handles files as input format" do
44
+ lambda {
45
+ CSSminify.compress(File.open(File.expand_path("../sample.css", __FILE__), "r:UTF-8")).should_not be_empty
46
+ }.should_not raise_error
47
+ end
48
+
49
+ it "works as both class and class instance" do
50
+ lambda {
51
+ CSSminify.compress(File.open(File.expand_path("../sample.css", __FILE__), "r:UTF-8").read).should_not be_empty
52
+ CSSminify.new.compress(File.open(File.expand_path("../sample.css", __FILE__), "r:UTF-8").read).should_not be_empty
53
+ }.should_not raise_error
54
+ end
55
+
56
+ end
57
+
58
+
59
+ context "compression" do
60
+
61
+ it "removes comments and white space" do
62
+ source = <<-EOS
63
+ /*****
64
+ Multi-line comment
65
+ before a new class name
66
+ *****/
67
+ .classname {
68
+ /* comment in declaration block */
69
+ font-weight: normal;
70
+ }
71
+ EOS
72
+ CSSminify.compress(source).should eq('.classname{font-weight:normal}')
73
+ end
74
+
75
+ it "preserves special comments" do
76
+ source = <<-EOS
77
+ /*!
78
+ (c) Very Important Comment
79
+ */
80
+ .classname {
81
+ /* comment in declaration block */
82
+ font-weight: normal;
83
+ }
84
+ EOS
85
+ result = <<-EOS
86
+ /*!
87
+ (c) Very Important Comment
88
+ */.classname{font-weight:normal}
89
+ EOS
90
+ (CSSminify.compress(source) + "\n").should eq(result)
91
+ end
92
+
93
+ it "removes last semi-colon in a block" do
94
+ source = <<-EOS
95
+ .classname {
96
+ border-top: 1px;
97
+ border-bottom: 2px;
98
+ }
99
+ EOS
100
+ CSSminify.compress(source).should eq('.classname{border-top:1px;border-bottom:2px}')
101
+ end
102
+
103
+ it "removes extra semi-colons" do
104
+ source = <<-EOS
105
+ .classname {
106
+ border-top: 1px; ;
107
+ border-bottom: 2px;;;
108
+ }
109
+ EOS
110
+ CSSminify.compress(source).should eq('.classname{border-top:1px;border-bottom:2px}')
111
+ end
112
+
113
+ it "removes empty declarations" do
114
+ source = <<-EOS
115
+ .empty { ;}
116
+ .nonempty {border: 0;}
117
+ EOS
118
+ CSSminify.compress(source).should eq('.nonempty{border:0}')
119
+ end
120
+
121
+ it "simplifies zero values" do
122
+ source = <<-EOS
123
+ a {
124
+ margin: 0px 0pt 0em 0%;
125
+ background-position: 0 0ex;
126
+ padding: 0in 0cm 0mm 0pc
127
+ }
128
+ EOS
129
+ CSSminify.compress(source).should eq('a{margin:0;background-position:0 0;padding:0}')
130
+ end
131
+
132
+ it "removes leading zeros from floats" do
133
+ source = <<-EOS
134
+ .classname {
135
+ margin: 0.6px 0.333pt 1.2em 8.8cm;
136
+ }
137
+ EOS
138
+ CSSminify.compress(source).should eq('.classname{margin:.6px .333pt 1.2em 8.8cm}')
139
+ end
140
+
141
+ it "simplifies color values but preserves filter properties, RGBa values and ID strings" do
142
+ source = <<-EOS
143
+ .color-me {
144
+ color: rgb(123, 123, 123);
145
+ border-color: #ffeedd;
146
+ background: none repeat scroll 0 0 rgb(255, 0,0);
147
+ }
148
+ EOS
149
+ CSSminify.compress(source).should eq('.color-me{color:#7b7b7b;border-color:#fed;background:none repeat scroll 0 0 #f00}')
150
+
151
+ source = <<-EOS
152
+ #AABBCC {
153
+ color: rgba(1, 2, 3, 4);
154
+ filter: chroma(color="#FFFFFF");
155
+ }
156
+ EOS
157
+ CSSminify.compress(source).should eq('#AABBCC{color:rgba(1,2,3,4);filter:chroma(color="#FFFFFF")}')
158
+ end
159
+
160
+ it "only keeps the first charset declaration" do
161
+ source = <<-EOS
162
+ @charset "utf-8";
163
+ #foo {
164
+ border-width: 1px;
165
+ }
166
+
167
+ /* second css, merged */
168
+ @charset "another one";
169
+ #bar {
170
+ border-width: 10px;
171
+ }
172
+ EOS
173
+ CSSminify.compress(source).should eq('@charset "utf-8";#foo{border-width:1px}#bar{border-width:10px}')
174
+ end
175
+
176
+ it "simplifies the IE opacity filter syntax" do
177
+ source = <<-EOS
178
+ .classname {
179
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
180
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE < 8 */
181
+ }
182
+ EOS
183
+ CSSminify.compress(source).should eq('.classname{-ms-filter:"alpha(opacity=80)";filter:alpha(opacity=80)}')
184
+ end
185
+
186
+ it "replaces 'none' values with 0 where allowed" do
187
+ source = <<-EOS
188
+ .classname {
189
+ border: none;
190
+ background: none;
191
+ outline: none;
192
+ }
193
+ EOS
194
+ CSSminify.compress(source).should eq('.classname{border:0;background:0;outline:0}')
195
+ end
196
+
197
+ it "tolerates underscore/star hacks" do
198
+ source = <<-EOS
199
+ #element {
200
+ width: 1px;
201
+ *width: 2px;
202
+ _width: 3px;
203
+ }
204
+ EOS
205
+ CSSminify.compress(source).should eq('#element{width:1px;*width:2px;_width:3px}')
206
+ end
207
+
208
+ it "tolerates child selector hacks" do
209
+ source = <<-EOS
210
+ html >/**/ body p {
211
+ color: blue;
212
+ }
213
+ EOS
214
+ CSSminify.compress(source).should eq('html>/**/body p{color:blue}')
215
+ end
216
+
217
+ it "tolerates IE5/Mac hacks" do
218
+ source = <<-EOS
219
+ /* Ignore the next rule in IE mac \\*/
220
+ .selector {
221
+ color: khaki;
222
+ }
223
+ /* Stop ignoring in IE mac */
224
+ EOS
225
+ CSSminify.compress(source).should eq('/*\*/.selector{color:khaki}/**/')
226
+ end
227
+
228
+ it "tolerates box model hacks" do
229
+ source = <<-EOS
230
+ #elem {
231
+ width: 100px; /* IE */
232
+ voice-family: "\\"}\\"";
233
+ voice-family:inherit;
234
+ width: 200px; /* others */
235
+ }
236
+ html>body #elem {
237
+ width: 200px; /* others */
238
+ }
239
+ EOS
240
+ CSSminify.compress(source).should eq('#elem{width:100px;voice-family:"\"}\"";voice-family:inherit;width:200px}html>body #elem{width:200px}')
241
+ end
242
+
243
+ it "should pass all the original tests included in the YUI compressor package" do
244
+ puts "Now running original YUI compressor test files:"
245
+
246
+ files = Dir.glob(File.join(File.dirname(__FILE__), 'tests', '*.css'))
247
+
248
+ for file in files do
249
+ print " -- testing #{file} ..."
250
+ CSSminify.compress(File.read(file)).chomp.strip.should eq(File.read(file + '.min').chomp.strip)
251
+ print "successful\n"
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end
@@ -0,0 +1,100 @@
1
+ /* Source http://developer.yahoo.com/yui/compressor/css.html */
2
+
3
+ /*****
4
+ Multi-line comment
5
+ before a new class name
6
+ *****/
7
+ .classname {
8
+ /* comment in declaration block */
9
+ font-weight: normal;
10
+ }
11
+
12
+ /*!
13
+ (c) Very Important Comment
14
+ */
15
+ .classname {
16
+ /* comment in declaration block */
17
+ font-weight: normal;
18
+ }
19
+
20
+ .classname {
21
+ border-top: 1px;
22
+ border-bottom: 2px;
23
+ }
24
+
25
+ .classname {
26
+ border-top: 1px; ;
27
+ border-bottom: 2px;;;
28
+ }
29
+
30
+ .empty { ;}
31
+ .nonempty {border: 0;}
32
+
33
+ a {
34
+ margin: 0px 0pt 0em 0%;
35
+ background-position: 0 0ex;
36
+ padding: 0in 0cm 0mm 0pc
37
+ }
38
+
39
+ .classname {
40
+ margin: 0.6px 0.333pt 1.2em 8.8cm;
41
+ }
42
+
43
+ .color-me {
44
+ color: rgb(123, 123, 123);
45
+ border-color: #ffeedd;
46
+ background: none repeat scroll 0 0 rgb(255, 0,0);
47
+ }
48
+
49
+ .cantouch {
50
+ color: rgba(1, 2, 3, 4);
51
+ filter: chroma(color="#FFFFFF");
52
+ }
53
+
54
+ @charset "utf-8";
55
+ #foo {
56
+ border-width: 1px;
57
+ }
58
+
59
+ /* second css, merged */
60
+ @charset "another one";
61
+ #bar {
62
+ border-width: 10px;
63
+ }
64
+
65
+ .classname {
66
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; /* IE 8 */
67
+ filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=80); /* IE < 8 */
68
+ }
69
+
70
+ .classname {
71
+ border: none;
72
+ background: none;
73
+ outline: none;
74
+ }
75
+
76
+ #element {
77
+ width: 1px;
78
+ *width: 2px;
79
+ _width: 3px;
80
+ }
81
+
82
+ html >/**/ body p {
83
+ color: blue;
84
+ }
85
+
86
+ /* Ignore the next rule in IE mac \*/
87
+ .selector {
88
+ color: khaki;
89
+ }
90
+ /* Stop ignoring in IE mac */
91
+
92
+ #elem {
93
+ width: 100px; /* IE */
94
+ voice-family: "\"}\"";
95
+ voice-family:inherit;
96
+ width: 200px; /* others */
97
+ }
98
+ html>body #elem {
99
+ width: 200px; /* others */
100
+ }
@@ -0,0 +1,4 @@
1
+ # coding: utf-8
2
+
3
+ require 'cssminify'
4
+ require 'rspec'
@@ -0,0 +1,2 @@
1
+ a {background-position: 0 0 0 0;}
2
+ b {BACKGROUND-POSITION: 0 0;}
@@ -0,0 +1 @@
1
+ a{background-position:0 0}b{background-position:0 0}
@@ -0,0 +1,5 @@
1
+ a {
2
+ border: none;
3
+ }
4
+ b {BACKGROUND:none}
5
+ s {border-top: none;}
@@ -0,0 +1 @@
1
+ a{border:0}b{background:0}s{border-top:0}
@@ -0,0 +1,9 @@
1
+ #elem {
2
+ width: 100px;
3
+ voice-family: "\"}\"";
4
+ voice-family:inherit;
5
+ width: 200px;
6
+ }
7
+ html>body #elem {
8
+ width: 200px;
9
+ }
@@ -0,0 +1 @@
1
+ #elem{width:100px;voice-family:"\"}\"";voice-family:inherit;width:200px}html>body #elem{width:200px}
@@ -0,0 +1,10 @@
1
+ /* this file contains no css, it exists purely to put the revision number into the
2
+ combined css before uploading it to SiteManager. The exclaimation at the start
3
+ of the comment informs yuicompressor not to strip the comment out */
4
+
5
+ /*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */
6
+
7
+ body {
8
+ yo: cats;
9
+ }
10
+ ul[id$=foo] label:hover {yo: yo;}
@@ -0,0 +1 @@
1
+ /*! $LastChangedRevision: 81 $ $LastChangedDate: 2009-05-27 17:41:02 +0100 (Wed, 27 May 2009) $ */body{yo:cats}ul[id$=foo] label:hover{yo:yo}
@@ -0,0 +1,19 @@
1
+ @media screen and/*!YUI-Compresser */(-webkit-min-device-pixel-ratio:0) {
2
+ a{
3
+ b: 1;
4
+ }
5
+ }
6
+
7
+
8
+ @media screen and/*! */ /*! */(-webkit-min-device-pixel-ratio:0) {
9
+ a{
10
+ b: 1;
11
+ }
12
+ }
13
+
14
+
15
+ @media -webkit-min-device-pixel-ratio:0 {
16
+ a{
17
+ b: 1;
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ @media screen and/*!YUI-Compresser */(-webkit-min-device-pixel-ratio:0){a{b:1}}@media screen and/*! *//*! */(-webkit-min-device-pixel-ratio:0){a{b:1}}@media -webkit-min-device-pixel-ratio:0{a{b:1}}
@@ -0,0 +1,4 @@
1
+ /*! special */
2
+ body {
3
+
4
+ }
@@ -0,0 +1 @@
1
+ /*! special */
@@ -0,0 +1,5 @@
1
+ a[href$="/test/"] span:first-child { b:1; }
2
+ a[href$="/test/"] span:first-child { }
3
+
4
+
5
+