Sha256: d6d2c8499d1676bfe9827d6cb5544df532cdeb02a0abd17b1242f913e0290d4c

Contents?: true

Size: 479 Bytes

Versions: 3

Compression:

Stored size: 479 Bytes

Contents

require 'nokogiri'

module DragonflySvg
  module Processors
    class SetNamespace

      def call content, namespace="http://www.w3.org/2000/svg"
        doc = Nokogiri::XML(content.data)

        if svg_node = doc.xpath("//*[name()='svg']").first
          unless svg_node.namespace.href == namespace
            doc.remove_namespaces!
            svg_node.add_namespace(nil, namespace)
          end
        end

        content.update(doc.to_xml)
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragonfly_svg-0.0.3 lib/dragonfly_svg/processors/set_namespace.rb
dragonfly_svg-0.0.2 lib/dragonfly_svg/processors/set_namespace.rb
dragonfly_svg-0.0.1 lib/dragonfly_svg/processors/set_namespace.rb