beautiful-css 0.0.10 → 0.1.01

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.
@@ -5,7 +5,6 @@ module BeautifulCss
5
5
 
6
6
  def initialize(str)
7
7
  @body = str
8
- @body = @body.gsub( /url\( *data:/ , '__url_data__')
9
8
  @body = @body.gsub( /;base64,/ , '__base64__')
10
9
  end
11
10
 
@@ -16,14 +15,16 @@ module BeautifulCss
16
15
  def props
17
16
  begin
18
17
  p = @body.match(/\{([^}]*)/)[1].split(';').select{|s| !s.strip.empty? }
19
- p.map{|s| s.strip.split(':') }
18
+ p.map do |s|
19
+ first, *rest = s.strip.split(':')
20
+ rest.class == Array ? [first, rest.join(':') ] : [first, rest ]
21
+ end
20
22
  rescue
21
23
  []
22
24
  end
23
25
  end
24
26
 
25
27
  def restore_special_strings str
26
- str = str.gsub( /__url_data__/, 'url(data:')
27
28
  str = str.gsub( /__base64__/, ';base64,')
28
29
  str
29
30
  end
@@ -1,3 +1,3 @@
1
1
  module BeautifulCss
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.01"
3
3
  end
@@ -163,6 +163,18 @@ CLEAN
163
163
  end
164
164
 
165
165
 
166
+ it 'should work with base64 encoded images 2' do
167
+ dirty = <<DIRTY
168
+ body
169
+ {background-image:url( "data:image/png;base64,%2F9j%2F4AAQSkZJR8QDn9Ltz%2F%2F2Q%3D%3D"); }
170
+ DIRTY
171
+ clean = <<CLEAN
172
+ body
173
+ { background-image:url("data:image/png;base64,%2F9j%2F4AAQSkZJR8QDn9Ltz%2F%2F2Q%3D%3D") }
174
+ CLEAN
175
+ assert_renders dirty, clean
176
+ end
177
+
166
178
 
167
179
 
168
180
 
@@ -183,6 +195,34 @@ CLEAN
183
195
 
184
196
 
185
197
 
198
+ # it 'should remove unneeded styles' do
199
+ # dirty = <<DIRTY
200
+ #td { color: green; }
201
+ #.unneeded_class { td{ color:green; } }
202
+ #DIRTY
203
+ # clean = <<CLEAN
204
+ #td
205
+ #{ color:green }
206
+ #CLEAN
207
+ # assert_renders dirty, clean
208
+ # end
209
+
210
+
211
+
212
+
213
+ it 'should handle IE filter tags' do
214
+ dirty = <<DIRTY
215
+ a
216
+ { filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f0b7a1', endColorstr='#bf6e4e',GradientType=0 ); }
217
+ DIRTY
218
+ clean = <<CLEAN
219
+ a
220
+ { filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f0b7a1', endColorstr='#bf6e4e',GradientType=0 ) }
221
+ CLEAN
222
+ assert_renders dirty, clean
223
+ end
224
+
225
+
186
226
 
187
227
 
188
228
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beautiful-css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.1.01
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A tool to help cleanup css
15
15
  email: