Sha256: f913aa95123e8cbc1f765cb4ebdc4ae4e009d4a90a664b425bbfb759107ba317
Contents?: true
Size: 720 Bytes
Versions: 1
Compression:
Stored size: 720 Bytes
Contents
require "uri" require "net/https" require "json" module Latest class Gem attr_reader :attributes def initialize(name) @attributes = fetch(name) if @attributes.nil? raise ::Latest::GemNotFoundError, "`#{name}` could not be found on rubygems.org!" end self end private def fetch(name) uri = URI("https://rubygems.org/api/v1/gems/#{name}.json") Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| request = Net::HTTP::Get.new uri.request_uri response = http.request request if response.is_a?(Net::HTTPSuccess) return JSON.parse(response.body) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
latest-0.1.0 | lib/latest/gem.rb |