Sha256: 87daff084079f021f829f7b3255f6e4119dc9744f3ddd0f5aac04b71cfc9f6c9

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

# Only allow this backend the xml-simple gem is already loaded
raise ::LoadError, "The xml-simple library isn't available. require 'xmlsimple'" unless defined?(XmlSimple)

module OEmbed
  module Formatter
    module XML
      module Backends
        # Use the xml-simple gem to parse XML values.
        module XmlSimple
          extend self

          # Parses an XML string or IO and convert it into an object.
          def decode(xml)
            if !xml.respond_to?(:read)
              xml = StringIO.new(xml)
            end
            ::XmlSimple.xml_in(xml, 'ForceArray'=>false)
          rescue
            case $!
            when parse_error
              raise $!
            else
              raise parse_error, "Couldn't parse the given document."
            end  
          end
          
          def decode_fail_msg
            "The version of the xml-simple library you have installed isn't parsing XML like ruby-oembed expected."
          end
          
          def parse_error
            ::ArgumentError
          end
        
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
ruby-oembed-0.18.1 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.18.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/ruby-oembed-0.17.0/lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.17.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.16.1 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.16.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.15.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.14.1 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.14.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.13.1 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.13.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.12.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.11.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.10.1 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.10.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.9.0 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.8.14 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.8.13 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.8.12 lib/oembed/formatter/xml/backends/xmlsimple.rb
ruby-oembed-0.8.11 lib/oembed/formatter/xml/backends/xmlsimple.rb