Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update css_parser

  • Loading branch information...
commit f8857357e85aafddf60a421dd17bf907e157d7d7 1 parent 97c630c
@aanand authored
Showing with 31 additions and 118 deletions.
  1. +0 −13 vendor/gems/css_parser-0.9.1/CHANGELOG
  2. +0 −21 vendor/gems/css_parser-0.9.1/LICENSE
  3. +0 −58 vendor/gems/css_parser-0.9.1/README
  4. +1 −1  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/lib/css_parser.rb
  5. +1 −1  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/lib/css_parser/parser.rb
  6. +4 −4 vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/lib/css_parser/regexps.rb
  7. +11 −8 vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/lib/css_parser/rule_set.rb
  8. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/fixtures/import-circular-reference.css
  9. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/fixtures/import-with-media-types.css
  10. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/fixtures/import1.css
  11. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/fixtures/simple.css
  12. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/fixtures/subdir/import2.css
  13. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_css_parser_basic.rb
  14. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_css_parser_downloading.rb
  15. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_css_parser_media_types.rb
  16. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_css_parser_misc.rb
  17. +1 −0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_css_parser_regexps.rb
  18. +8 −8 vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_helper.rb
  19. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_merging.rb
  20. +5 −4 vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_rule_set.rb
  21. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_rule_set_creating_shorthand.rb
  22. 0  vendor/gems/{css_parser-0.9.1 → css_parser-1.0.0}/test/test_rule_set_expanding_shorthand.rb
View
13 vendor/gems/css_parser-0.9.1/CHANGELOG
@@ -1,13 +0,0 @@
-=== Ruby CSS Parser CHANGELOG
-
-==== Version 0.9.1
- * Fixed RuleSet#declaration_to_s so it would respect <tt>!important</tt>
- rules (thanks to Dana - http://github.com/DanaDanger)
-
-==== Version 0.9
- * Initial version forked from Premailer project
-
-==== TODO: Future
- * border shorthand/folding support
- * re-implement caching on CssParser.merge
- * correctly parse http://www.webstandards.org/files/acid2/test.html
View
21 vendor/gems/css_parser-0.9.1/LICENSE
@@ -1,21 +0,0 @@
-=== Ruby CSS Parser License
-
-Copyright (c) 2007 Alex Dunae
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
View
58 vendor/gems/css_parser-0.9.1/README
@@ -1,58 +0,0 @@
-=== Ruby CSS Parser
-
-Load, parse and cascade CSS rule sets in Ruby.
-
-==== Setup
-
-Install the gem from RubyGems.
-
- gem install css_parser
-
-Done.
-
-==== An example
- require 'css_parser'
- include CssParser
-
- parser = CssParser::Parser.new
- parser.load_file!('http://example.com/styles/style.css')
-
- # lookup a rule by a selector
- parser.find('#content')
- #=> 'font-size: 13px; line-height: 1.2;'
-
- # lookup a rule by a selector and media type
- parser.find('#content', [:screen, :handheld])
-
- # iterate through selectors by media type
- parser.each_selector(:screen) do |selector, declarations, specificity|
- ...
- end
-
- # add a block of CSS
- css = <<-EOT
- body { margin: 0 1em; }
- EOT
-
- parser.add_block!(css)
-
- # output all CSS rules in a single stylesheet
- parser.to_s
- => #content { font-size: 13px; line-height: 1.2; }
- body { margin: 0 1em; }
-
-==== Testing
-
-You can run the suite of unit tests using <tt>rake test</tt>.
-
-The download/import tests require that WEBrick is installed. The tests set up
-a temporary server on port 12000 and pull down files from the <tt>test/fixtures/</tt>
-directory.
-
-==== Credits and code
-
-By Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-08.
-
-Thanks to Dana (http://github.com/DanaDanger) for the 0.9.1 update.
-
-Made on Vancouver Island.
View
2  ...r/gems/css_parser-0.9.1/lib/css_parser.rb → ...r/gems/css_parser-1.0.0/lib/css_parser.rb
@@ -1,6 +1,6 @@
$:.unshift File.dirname(__FILE__)
require 'uri'
-require 'md5'
+require 'digest/md5'
require 'zlib'
require 'iconv'
require 'css_parser/rule_set'
View
2  ...css_parser-0.9.1/lib/css_parser/parser.rb → ...css_parser-1.0.0/lib/css_parser/parser.rb
@@ -15,7 +15,7 @@ class CircularReferenceError < StandardError; end
# [<tt>import</tt>] Follow <tt>@import</tt> rules. Boolean, default is <tt>true</tt>.
# [<tt>io_exceptions</tt>] Throw an exception if a link can not be found. Boolean, default is <tt>true</tt>.
class Parser
- USER_AGENT = "Ruby CSS Parser/#{VERSION} (http://code.dunae.ca/css_parser/)"
+ USER_AGENT = "Ruby CSS Parser/#{RUBY_VERSION} (http://code.dunae.ca/css_parser/)"
STRIP_CSS_COMMENTS_RX = /\/\*.*?\*\//m
STRIP_HTML_COMMENTS_RX = /\<\!\-\-|\-\-\>/m
View
8 ...ss_parser-0.9.1/lib/css_parser/regexps.rb → ...ss_parser-1.0.0/lib/css_parser/regexps.rb
@@ -2,17 +2,17 @@ module CssParser
# :stopdoc:
# Base types
RE_NL = Regexp.new('(\n|\r\n|\r|\f)')
- RE_NON_ASCII = Regexp.new('([\x00-\xFF])', Regexp::IGNORECASE) #[^\0-\177]
- RE_UNICODE = Regexp.new('(\\\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])*)', Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE)
+ RE_NON_ASCII = Regexp.new('([\x00-\xFF])', Regexp::IGNORECASE, 'n') #[^\0-\177]
+ RE_UNICODE = Regexp.new('(\\\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])*)', Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE, 'n')
RE_ESCAPE = Regexp.union(RE_UNICODE, '|(\\\\[^\n\r\f0-9a-f])')
- RE_IDENT = Regexp.new("[\-]?([_a-z]|#{RE_NON_ASCII}|#{RE_ESCAPE})([_a-z0-9\-]|#{RE_NON_ASCII}|#{RE_ESCAPE})*", Regexp::IGNORECASE)
+ RE_IDENT = Regexp.new("[\-]?([_a-z]|#{RE_NON_ASCII}|#{RE_ESCAPE})([_a-z0-9\-]|#{RE_NON_ASCII}|#{RE_ESCAPE})*", Regexp::IGNORECASE, 'n')
# General strings
RE_STRING1 = Regexp.new('(\"(.[^\n\r\f\\"]*|\\\\' + RE_NL.to_s + '|' + RE_ESCAPE.to_s + ')*\")')
RE_STRING2 = Regexp.new('(\'(.[^\n\r\f\\\']*|\\\\' + RE_NL.to_s + '|' + RE_ESCAPE.to_s + ')*\')')
RE_STRING = Regexp.union(RE_STRING1, RE_STRING2)
- RE_URI = Regexp.new('(url\([\s]*([\s]*' + RE_STRING.to_s + '[\s]*)[\s]*\))|(url\([\s]*([!#$%&*\-~]|' + RE_NON_ASCII.to_s + '|' + RE_ESCAPE.to_s + ')*[\s]*)\)', Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE)
+ RE_URI = Regexp.new('(url\([\s]*([\s]*' + RE_STRING.to_s + '[\s]*)[\s]*\))|(url\([\s]*([!#$%&*\-~]|' + RE_NON_ASCII.to_s + '|' + RE_ESCAPE.to_s + ')*[\s]*)\)', Regexp::IGNORECASE | Regexp::EXTENDED | Regexp::MULTILINE, 'n')
URI_RX = /url\(("([^"]*)"|'([^']*)'|([^)]*))\)/im
# Initial parsing
View
19 ...s_parser-0.9.1/lib/css_parser/rule_set.rb → ...s_parser-1.0.0/lib/css_parser/rule_set.rb
@@ -48,6 +48,11 @@ def get_value(property)
#
# If the property already exists its value will be over-written.
def add_declaration!(property, value)
+ if value.nil? or value.empty?
+ @declarations.delete(property)
+ return
+ end
+
value.gsub!(/;\Z/, '')
is_important = !value.gsub!(CssParser::IMPORTANT_IN_PROPERTY_RX, '').nil?
property = property.downcase.strip
@@ -84,13 +89,14 @@ def each_declaration # :yields: property, value, is_important
end
# Return all declarations as a string.
+ #--
+ # TODO: Clean-up regexp doesn't seem to work
+ #++
def declarations_to_s(options = {})
options = {:force_important => false}.merge(options)
str = ''
- each_declaration do |prop, val, is_important|
- importance = (options[:force_important] || is_important) ? ' !important' : ''
- str += "#{prop}: #{val}#{importance}; "
- end
+ importance = options[:force_important] ? ' !important' : ''
+ each_declaration { |prop, val| str += "#{prop}: #{val}#{importance}; " }
str.gsub(/^[\s]+|[\n\r\f\t]*|[\s]+$/mx, '').strip
end
@@ -138,6 +144,7 @@ def parse_selectors!(selectors) # :nodoc:
@selectors = selectors.split(',')
end
+public
# Split shorthand dimensional declarations (e.g. <tt>margin: 0px auto;</tt>)
# into their constituent parts.
def expand_dimensions_shorthand! # :nodoc:
@@ -372,9 +379,5 @@ def create_font_shorthand! # :nodoc:
end
end
-
-
-
-
end
end
View
0  ...st/fixtures/import-circular-reference.css → ...st/fixtures/import-circular-reference.css
File renamed without changes
View
0  ...test/fixtures/import-with-media-types.css → ...test/fixtures/import-with-media-types.css
File renamed without changes
View
0  ...ss_parser-0.9.1/test/fixtures/import1.css → ...ss_parser-1.0.0/test/fixtures/import1.css
File renamed without changes
View
0  ...css_parser-0.9.1/test/fixtures/simple.css → ...css_parser-1.0.0/test/fixtures/simple.css
File renamed without changes
View
0  ...er-0.9.1/test/fixtures/subdir/import2.css → ...er-1.0.0/test/fixtures/subdir/import2.css
File renamed without changes
View
0  ...arser-0.9.1/test/test_css_parser_basic.rb → ...arser-1.0.0/test/test_css_parser_basic.rb
File renamed without changes
View
0  ...0.9.1/test/test_css_parser_downloading.rb → ...1.0.0/test/test_css_parser_downloading.rb
File renamed without changes
View
0  ...0.9.1/test/test_css_parser_media_types.rb → ...1.0.0/test/test_css_parser_media_types.rb
File renamed without changes
View
0  ...parser-0.9.1/test/test_css_parser_misc.rb → ...parser-1.0.0/test/test_css_parser_misc.rb
File renamed without changes
View
1  ...ser-0.9.1/test/test_css_parser_regexps.rb → ...ser-1.0.0/test/test_css_parser_regexps.rb
@@ -1,3 +1,4 @@
+# coding: iso-8859-1
require File.dirname(__FILE__) + '/test_helper'
# Test cases for CSS regular expressions
View
16 ...gems/css_parser-0.9.1/test/test_helper.rb → ...gems/css_parser-1.0.0/test/test_helper.rb
@@ -1,8 +1,8 @@
-$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../'))
-$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../lib/'))
-require 'rubygems'
-require 'test/unit'
-require 'css_parser'
-require 'net/http'
-require 'open-uri'
-require 'WEBrick'
+$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../'))
+$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../lib/'))
+require 'rubygems'
+require 'test/unit'
+require 'css_parser'
+require 'net/http'
+require 'open-uri'
+require 'WEBrick'
View
0  ...ems/css_parser-0.9.1/test/test_merging.rb → ...ems/css_parser-1.0.0/test/test_merging.rb
File renamed without changes
View
9 ...ms/css_parser-0.9.1/test/test_rule_set.rb → ...ms/css_parser-1.0.0/test/test_rule_set.rb
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/test_helper'
+require "set"
# Test cases for parsing CSS blocks
class RuleSetTests < Test::Unit::TestCase
@@ -32,7 +33,7 @@ def test_each_selector
expected = [
{:selector => "#content p", :declarations => "color: #fff;", :specificity => 101},
{:selector => "a", :declarations => "color: #fff;", :specificity => 1}
- ]
+ ]
actual = []
rs = RuleSet.new('#content p, a', 'color: #fff;')
@@ -44,13 +45,13 @@ def test_each_selector
end
def test_each_declaration
- expected = [
+ expected = Set.new([
{:property => 'margin', :value => '1px -0.25em', :is_important => false},
{:property => 'background', :value => 'white none no-repeat', :is_important => true},
{:property => 'color', :value => '#fff', :is_important => false}
- ]
+ ])
- actual = []
+ actual = Set.new
rs = RuleSet.new(nil, 'color: #fff; Background: white none no-repeat !important; margin: 1px -0.25em;')
rs.each_declaration do |prop, val, imp|
actual << {:property => prop, :value => val, :is_important => imp}
View
0  .../test/test_rule_set_creating_shorthand.rb → .../test/test_rule_set_creating_shorthand.rb
File renamed without changes
View
0  ...test/test_rule_set_expanding_shorthand.rb → ...test/test_rule_set_expanding_shorthand.rb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.