lib/css_parser/parser.rb in css_parser-1.2.6 vs lib/css_parser/parser.rb in css_parser-1.3.0

- old
+ new

@@ -71,11 +71,25 @@ end out end alias_method :[], :find_by_selector + # Finds the rule sets that match the given selectors + def find_rule_sets(selectors, media_types = :all) + rule_sets = [] + selectors.each do |selector| + each_rule_set(media_types) do |rule_set| + if !rule_sets.member?(rule_set) && rule_set.selectors.member?(selector) + rule_sets << rule_set + end + end + end + + rule_sets + end + # Add a raw block of CSS. # # In order to follow +@import+ rules you must supply either a # +:base_dir+ or +:base_uri+ option. # @@ -351,9 +365,14 @@ return unless circular_reference_check(file_name) src = IO.read(file_name) base_dir = File.dirname(file_name) + add_block!(src, {:media_types => media_types, :base_dir => base_dir}) + end + + # Load a local CSS string. + def load_string!(src, base_dir = nil, media_types = :all) add_block!(src, {:media_types => media_types, :base_dir => base_dir}) end