lib/prawn/svg/document.rb in prawn-svg-0.23.0 vs lib/prawn/svg/document.rb in prawn-svg-0.23.1
- old
+ new
@@ -1,16 +1,9 @@
class Prawn::SVG::Document
Error = Class.new(StandardError)
InvalidSVGData = Class.new(Error)
- begin
- require 'css_parser'
- CSS_PARSER_LOADED = true
- rescue LoadError
- CSS_PARSER_LOADED = false
- end
-
DEFAULT_FALLBACK_FONT_NAME = "Times-Roman"
# An +Array+ of warnings that occurred while parsing the SVG data.
attr_reader :warnings
@@ -20,12 +13,10 @@
:font_registry,
:url_loader,
:css_parser, :elements_by_id, :gradients
def initialize(data, bounds, options, font_registry: nil)
- @css_parser = CssParser::Parser.new if CSS_PARSER_LOADED
-
@root = REXML::Document.new(data).root
if @root.nil?
if data.respond_to?(:end_with?) && data.end_with?(".svg")
raise InvalidSVGData, "The data supplied is not a valid SVG document. It looks like you've supplied a filename instead; use IO.read(filename) to get the data before you pass it to prawn-svg."
@@ -51,9 +42,11 @@
sizing.requested_width = options[:width]
sizing.requested_height = options[:height]
sizing.calculate
@axis_to_size = {:x => sizing.viewport_width, :y => sizing.viewport_height}
+
+ @css_parser = CssParser::Parser.new
yield self if block_given?
end
def x(value)