Permalink
Browse files

replacing JSON dependency with Heroku::API::OkJson

  • Loading branch information...
1 parent 6932182 commit 631d3a3a097a5286400cbd3699e0bc0df989f866 Mike Foley committed Aug 15, 2012
Showing with 5 additions and 11 deletions.
  1. +5 −11 init.rb
View
16 init.rb
@@ -1,9 +1,3 @@
-begin
- require 'json'
-rescue LoadError
- raise "json gem is missing. Please install json: gem install json"
-end
-
module Heroku::Command
class Ranger < BaseWithApp
def initialize(*args)
@@ -172,9 +166,9 @@ def get_status
resource = authenticated_resource("/status/#{@ranger_app_id}?api_key=#{@ranger_api_key}")
begin
- @current_status = JSON.parse(resource.get)
+ @current_status = Heroku::API::OkJson.decode(resource.get)
true
- rescue RestClient::ResourceNotFound => e
+ rescue Heroku::API::OkJson::Error => e
false
end
end
@@ -199,7 +193,7 @@ def remove_url(url)
end
def delete_dependency_from_url(url)
- dependencies = JSON.parse(get_dependencies)
+ dependencies = Heroku::API::OkJson.decode(get_dependencies)
dependency_id = nil
dependencies.each do |record|
@@ -223,7 +217,7 @@ def delete_dependency(id)
end
def clear_all_dependencies
- dependencies = JSON.parse(get_dependencies)
+ dependencies = Heroku::API::OkJson.decode(get_dependencies)
dependencies.each do |record|
delete_dependency(record["dependency"]["id"])
@@ -266,7 +260,7 @@ def domain_list
def get_watchers
resource = authenticated_resource("/apps/#{@ranger_app_id}/watchers.json?api_key=#{@ranger_api_key}")
- @current_watchers = JSON.parse(resource.get)
+ @current_watchers = Heroku::API::OkJson.decode(resource.get)
end
def watchers_list

0 comments on commit 631d3a3

Please sign in to comment.