Sha256: ed8df888f96f4bd83095c28e7f30ae56966096e7619bf96e324d7ce08798521a
Contents?: true
Size: 719 Bytes
Versions: 13
Compression:
Stored size: 719 Bytes
Contents
# Module to allow mixing in the ability to retrieve JSON via http. # Uses curb if available; otherwise falls back on Net::HTTP module Djatoka::Net # Used to get the JSON response from Djatoka for Djatoka::Metadata and ping requests. # Uses curb if the gem is installed; otherwise it falls back on Net::HTTP. def get_json(url) if Djatoka.use_curb? c = Curl::Easy.new(url) data = nil c.on_success{|curl| data = JSON.parse(curl.body_str) } c.perform else uri = URI.parse(url) response = Net::HTTP.get_response(uri) case response when Net::HTTPSuccess data = JSON.parse(response.body) else data = nil end end data end end
Version data entries
13 entries across 13 versions & 1 rubygems