Sha256: afe564a8a85f055d70437ae0b5141337604e00ba3bdb05e4c9f1fcb19c9bc771

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

# Only allow this backend the json gem is already loaded
raise LoadError, "The json library isn't available. require 'json'" unless defined?(JSON)

module OEmbed
  module Formatter
    module JSON
      module Backends
        module JSONGem
          ParseError = ::JSON::ParserError
          extend self

          # Parses a JSON string or IO and convert it into an object.
          def decode(json)
            if json.respond_to?(:read)
              json = json.read
            end
            ::JSON.parse(json)
          end
        
        end
      end
    end
  end
end

# Only allow this backend if it parses JSON strings the way we expect it to
begin
  raise unless OEmbed::Formatter.test_backend(OEmbed::Formatter::JSON::Backends::JSONGem)
rescue
  raise LoadError, "The version of the json library you have installed isn't parsing JSON like ruby-oembed expected."
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-oembed-0.8.1 lib/oembed/formatter/json/backends/jsongem.rb