lib/prawn/svg/parser.rb in prawn-svg-0.17.0 vs lib/prawn/svg/parser.rb in prawn-svg-0.18.0

- old
+ new

@@ -11,10 +11,11 @@ # prawn specifically - this might be useful if you want to take this code and use it to convert # SVG to another format. # class Prawn::Svg::Parser CONTAINER_TAGS = %w(g svg symbol defs clipPath) + COMMA_WSP_REGEXP = /(?:\s+,?\s*|,\s*)/ # # Construct a Parser object. # # The +data+ argument is SVG data. @@ -130,19 +131,19 @@ else element.add_call "circle_at", xy, :radius => r end when 'ellipse' - xy, rx, ry = [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['rx']), distance(attrs['ry']) + xy, rx, ry = [x(attrs['cx'] || "0"), y(attrs['cy'] || "0")], distance(attrs['rx'], :x), distance(attrs['ry'], :y) return if zero_argument?(rx, ry) element.add_call USE_NEW_ELLIPSE_CALL ? "ellipse" : "ellipse_at", xy, rx, ry when 'rect' xy = [x(attrs['x'] || '0'), y(attrs['y'] || '0')] - width, height = distance(attrs['width']), distance(attrs['height']) + width, height = distance(attrs['width'], :x), distance(attrs['height'], :y) radius = distance(attrs['rx'] || attrs['ry']) return if zero_argument?(width, height) if radius @@ -209,11 +210,11 @@ id = href[1..-1] if definition_element = @document.elements_by_id[id] x = element.attributes['x'] y = element.attributes['y'] if x || y - element.add_call_and_enter "translate", distance(x || 0), -distance(y || 0) + element.add_call_and_enter "translate", distance(x || 0, :x), -distance(y || 0, :y) end element.add_calls_from_element definition_element else @document.warnings << "no tag with ID '#{id}' was found, referenced by use tag" end @@ -258,10 +259,10 @@ def parse_points(points_string) points_string. to_s. strip. gsub(/(\d)-(\d)/, '\1 -\2'). - split(/(?:\s+,?\s*|,\s*)/). + split(COMMA_WSP_REGEXP). each_slice(2). to_a end end