css_parser 1.1.5 → 1.1.6

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.
@@ -115,7 +115,7 @@ module CssParser
115
115
  media_types << t.to_sym unless t.empty?
116
116
  end
117
117
  end
118
-
118
+
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
@@ -282,18 +282,35 @@ module CssParser
282
282
  # Load a remote CSS file.
283
283
  #
284
284
  # You can also pass in file://test.css
285
- def load_uri!(uri, base_uri = nil, media_types = :all)
285
+ #
286
+ # See add_block! for options.
287
+ #
288
+ # Deprecated: originally accepted three params: `uri`, `base_uri` and `media_types`
289
+ def load_uri!(uri, options = {}, deprecated = nil)
286
290
  uri = URI.parse(uri) unless uri.respond_to? :scheme
291
+ #base_uri = nil, media_types = :all, options = {}
292
+
293
+ opts = {:base_uri => nil, :media_types => :all}
294
+
295
+ if options.is_a? Hash
296
+ opts.merge!(options)
297
+ else
298
+ opts[:base_uri] = options if options.is_a? String
299
+ opts[:media_types] = deprecated if deprecated
300
+ end
301
+
302
+
287
303
  if uri.scheme == 'file' or uri.scheme.nil?
288
304
  uri.path = File.expand_path(uri.path)
289
305
  uri.scheme = 'file'
290
306
  end
291
- base_uri = uri if base_uri.nil?
307
+
308
+ opts[:base_uri] = uri if opts[:base_uri].nil?
292
309
 
293
310
  src, charset = read_remote_file(uri)
294
311
 
295
312
  if src
296
- add_block!(src, {:media_types => media_types, :base_uri => base_uri})
313
+ add_block!(src, opts)
297
314
  end
298
315
  end
299
316
 
data/lib/css_parser.rb CHANGED
@@ -7,7 +7,7 @@ require 'stringio'
7
7
  require 'iconv'
8
8
 
9
9
  module CssParser
10
- VERSION = '1.1.5'
10
+ VERSION = '1.1.6'
11
11
 
12
12
  # Merge multiple CSS RuleSets by cascading according to the CSS 2.1 cascading rules
13
13
  # (http://www.w3.org/TR/REC-CSS2/cascade.html#cascading-order).
@@ -97,7 +97,7 @@ class CssParserMediaTypesTests < Test::Unit::TestCase
97
97
  assert_equal 'color: black;', @cp.find_by_selector('body', :handheld).join(' ')
98
98
  end
99
99
 
100
- def test_selecting_with_all_meda_type
100
+ def test_selecting_with_all_media_types
101
101
  @cp.add_rule!('body', 'color: black;', [:handheld,:tty])
102
102
  assert_equal 'color: black;', @cp.find_by_selector('body', :all).join(' ')
103
103
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 5
9
- version: 1.1.5
8
+ - 6
9
+ version: 1.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Dunae
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-21 00:00:00 -08:00
17
+ date: 2011-03-25 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20