css_parser 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,10 +5,10 @@ require 'open-uri'
5
5
  require 'digest/md5'
6
6
  require 'zlib'
7
7
  require 'stringio'
8
- require 'iconv'
8
+ require 'iconv' unless String.method_defined?(:encode)
9
9
 
10
10
  module CssParser
11
- VERSION = '1.2.5'
11
+ VERSION = '1.2.6'
12
12
 
13
13
  # Merge multiple CSS RuleSets by cascading according to the CSS 2.1 cascading rules
14
14
  # (http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order).
@@ -119,7 +119,7 @@ module CssParser
119
119
  next unless options[:only_media_types].include?(:all) or media_types.length < 1 or (media_types & options[:only_media_types]).length > 0
120
120
 
121
121
  import_path = import_rule[0].to_s.gsub(/['"]*/, '').strip
122
-
122
+
123
123
  if options[:base_uri]
124
124
  import_uri = Addressable::URI.parse(options[:base_uri].to_s) + Addressable::URI.parse(import_path)
125
125
  load_uri!(import_uri, options[:base_uri], media_types)
@@ -330,8 +330,7 @@ module CssParser
330
330
  opts[:base_uri] = options if options.is_a? String
331
331
  opts[:media_types] = deprecated if deprecated
332
332
  end
333
-
334
-
333
+
335
334
  if uri.scheme == 'file' or uri.scheme.nil?
336
335
  uri.path = File.expand_path(uri.path)
337
336
  uri.scheme = 'file'
@@ -340,7 +339,6 @@ module CssParser
340
339
  opts[:base_uri] = uri if opts[:base_uri].nil?
341
340
 
342
341
  src, charset = read_remote_file(uri)
343
-
344
342
  if src
345
343
  add_block!(src, opts)
346
344
  end
@@ -423,7 +421,8 @@ module CssParser
423
421
  http = Net::HTTP.new(uri.host, uri.port)
424
422
  end
425
423
 
426
- res, src = http.get(uri.path, {'User-Agent' => USER_AGENT, 'Accept-Encoding' => 'gzip'})
424
+ res = http.get(uri.path, {'User-Agent' => USER_AGENT, 'Accept-Encoding' => 'gzip'})
425
+ src = res.body
427
426
  charset = fh.respond_to?(:charset) ? fh.charset : 'utf-8'
428
427
 
429
428
  if res.code.to_i >= 400
@@ -442,8 +441,12 @@ module CssParser
442
441
  end
443
442
 
444
443
  if charset
445
- ic = Iconv.new('UTF-8//IGNORE', charset)
446
- src = ic.iconv(src)
444
+ if String.method_defined?(:encode)
445
+ src.encode!('UTF-8', charset)
446
+ else
447
+ ic = Iconv.new('UTF-8//IGNORE', charset)
448
+ src = ic.iconv(src)
449
+ end
447
450
  end
448
451
  rescue
449
452
  raise RemoteFileError if @options[:io_exceptions]
@@ -2,5 +2,5 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'net/http'
4
4
  require 'open-uri'
5
- require 'WEBrick'
5
+ require 'webrick'
6
6
  require File.dirname(__FILE__) + '/../lib/css_parser'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: css_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-07 00:00:00.000000000Z
12
+ date: 2011-09-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &2153617080 !ruby/object:Gem::Requirement
16
+ requirement: &2160264060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,29 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153617080
24
+ version_requirements: *2160264060
25
+ - !ruby/object:Gem::Dependency
26
+ name: rdoc
27
+ requirement: &2160263460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2160263460
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &2160258520 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2160258520
25
47
  description: A set of classes for parsing CSS in Ruby.
26
48
  email: code@dunae.ca
27
49
  executables: []