Sha256: 01250334ee9e1bf51c335bc2f254fe370e94741b9f4095f69743b3944684be00

Contents?: true

Size: 791 Bytes

Versions: 11

Compression:

Stored size: 791 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
          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
          
          def decode_fail_msg
            "The version of the json library you have installed isn't parsing JSON like ruby-oembed expected."
          end
          
          def parse_error
            ::JSON::ParserError
          end
        
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby-oembed-0.9.0 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.14 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.13 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.12 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.11 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.10 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.9 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.8 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.7 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.5 lib/oembed/formatter/json/backends/jsongem.rb
ruby-oembed-0.8.3 lib/oembed/formatter/json/backends/jsongem.rb