Class: GemMonitor::Service
- Inherits:
-
Object
- Object
- GemMonitor::Service
- Defined in:
- lib/gem_monitor/service.rb
Constant Summary collapse
- BASE_URL =
"https://rubygems.org"- VERSIONS_ENDPOINT =
"/api/v1/versions/"
Class Method Summary collapse
-
.get_latest_version_for(gem_name) ⇒ Object
TODO: create an oject to handle this response.
Class Method Details
.get_latest_version_for(gem_name) ⇒ Object
TODO: create an oject to handle this response
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gem_monitor/service.rb', line 12 def self.get_latest_version_for gem_name begin response = RestClient.get("#{BASE_URL}#{VERSIONS_ENDPOINT}#{gem_name}/latest.json") JSON.parse(response.body).fetch("version") rescue RestClient::Exception => e "unknown" rescue JSON::ParserError => e raise GemMonitor::Error.new("Error parsing response please submit an issue on #{GemMonitor.issues_url} along the response #{response.body}") end end |