Permalink
Browse files

s/Hoptoad/Airbrake/gi

  • Loading branch information...
1 parent 99a2ab6 commit e9abeefb8b5cd573c6bd0902e4775a32cab2c8b8 @bgreenlee bgreenlee committed Sep 4, 2011
View
@@ -1,57 +1,57 @@
-Hoptoad API
+Airbrake API
===========
-A ruby wrapper for the [Hoptoad API](http://hoptoadapp.com/pages/api)
+A ruby wrapper for the [Airbrake API](http://airbrakeapp.com/pages/api)
Usage
-----
The first thing you need to set is the account name. This is the same as the web address for your account.
- Hoptoad.account = 'myaccount'
+ Airbrake.account = 'myaccount'
Then, you should set the authentication token.
- Hoptoad.auth_token = 'abcdefg'
+ Airbrake.auth_token = 'abcdefg'
If your account uses ssl then turn it on:
- Hoptoad.secure = true
+ Airbrake.secure = true
Optionally, you can configure through a single method:
- Hoptoad.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)
+ Airbrake.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)
-Once you've configured authentication, you can make calls against the API. If no token or authentication is given, a HoptoadError exception will be raised.
+Once you've configured authentication, you can make calls against the API. If no token or authentication is given, a AirbrakeError exception will be raised.
Finding Errors
--------------
Errors are paginated, the API responds with 25 at a time, pass an optional params hash for additional pages:
- Hoptoad::Error.find(:all)
- Hoptoad::Error.find(:all, :page => 2)
+ Airbrake::Error.find(:all)
+ Airbrake::Error.find(:all, :page => 2)
To find an individual error, you can find by ID:
- Hoptoad::Error.find(error_id)
+ Airbrake::Error.find(error_id)
Find *all* notices of an error:
- Hoptoad::Notice.find_all_by_error_id(error_id)
+ Airbrake::Notice.find_all_by_error_id(error_id)
Find an individual notice:
- Hoptoad::Notice.find(notice_id, error_id)
+ Airbrake::Notice.find(notice_id, error_id)
To resolve an error via the API:
- Hoptoad::Error.update(1696170, :group => { :resolved => true})
+ Airbrake::Error.update(1696170, :group => { :resolved => true})
Recreate an error:
STDOUT.sync = true
- Hoptoad::Notice.find_all_by_error_id(error_id) do |batch|
+ Airbrake::Notice.find_all_by_error_id(error_id) do |batch|
batch.each do |notice|
result = system "curl --silent '#{notice.request.url}' > /dev/null"
print (result ? '.' : 'F')
@@ -63,12 +63,12 @@ Projects
To retrieve a list of projects:
- Hoptoad::Project.find(:all)
+ Airbrake::Project.find(:all)
Responses
---------
-If an error is returned from the API. A HoptoadError will be raised. Successful responses will return a Hashie::Mash object based on the data from the response.
+If an error is returned from the API. A AirbrakeError will be raised. Successful responses will return a Hashie::Mash object based on the data from the response.
Contributors
@@ -1,18 +1,18 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
-require "hoptoad-api/version"
+require "airbrake-api/version"
Gem::Specification.new do |s|
- s.name = 'hoptoad-api'
- s.version = Hoptoad::VERSION
+ s.name = 'airbrake-api'
+ s.version = Airbrake::VERSION
s.platform = Gem::Platform::RUBY
- s.summary = "A ruby wrapper for the Hoptoad API"
- s.description = "A ruby wrapper for the Hoptoad API"
+ s.summary = "A ruby wrapper for the Airbrake API"
+ s.description = "A ruby wrapper for the Airbrake API"
s.authors = ['Steve Agalloco']
s.email = ['steve.agalloco@gmail.com']
- s.homepage = 'http://github.com/spagalloco/hoptoad-api'
+ s.homepage = 'http://github.com/spagalloco/hoptoad-api' # FIXME: change to airbrake-api when repo has been renamed
s.add_dependency(%q<httparty>, [">= 0.5.2"])
s.add_dependency(%q<hashie>, [">= 0.2.0"])
@@ -1,11 +1,11 @@
require 'hashie'
require 'httparty'
-module Hoptoad
+module Airbrake
extend self
attr_accessor :account, :auth_token, :secure
- class HoptoadError < StandardError; end
+ class AirbrakeError < StandardError; end
def configure(options={})
@account = options[:account] if options.has_key?(:account)
@@ -14,7 +14,7 @@ def configure(options={})
end
def account_path
- "#{protocol}://#{@account}.hoptoadapp.com"
+ "#{protocol}://#{@account}.airbrakeapp.com"
end
def protocol
@@ -23,8 +23,8 @@ def protocol
end
-require 'hoptoad-api/core_extensions'
-require 'hoptoad-api/client'
-require 'hoptoad-api/error'
-require 'hoptoad-api/notice'
-require 'hoptoad-api/project'
+require 'airbrake-api/core_extensions'
+require 'airbrake-api/client'
+require 'airbrake-api/error'
+require 'airbrake-api/notice'
+require 'airbrake-api/project'
@@ -0,0 +1,41 @@
+module Airbrake
+ class Base
+ include HTTParty
+ format :xml
+
+ private
+
+ def self.setup
+ base_uri Airbrake.account_path
+ default_params :auth_token => Airbrake.auth_token
+
+ check_configuration
+ end
+
+ def self.check_configuration
+ raise AirbrakeError.new('API Token cannot be nil') if default_options.nil? || default_options[:default_params].nil? || !default_options[:default_params].has_key?(:auth_token)
+ raise AirbrakeError.new('Account cannot be nil') unless default_options.has_key?(:base_uri)
+ end
+
+ def self.fetch(path, options)
+ response = get(path, { :query => options })
+ if response.code == 403
+ raise AirbrakeError.new('SSL should be enabled - use Airbrake.secure = true in configuration')
+ end
+
+ Hashie::Mash.new(response)
+ end
+
+ end
+end
+
+# airbrake sometimes returns broken xml with strange utmz stuff
+# so we remove this
+require 'httparty/parser'
+class HTTParty::Parser
+ alias utmz_unaware_xml xml
+ def xml
+ body.gsub!(/<__utmz>.*?<\/__utmz>/m,'')
+ utmz_unaware_xml
+ end
+end
@@ -1,5 +1,5 @@
-module Hoptoad
- class Error < Hoptoad::Base
+module Airbrake
+ class Error < Airbrake::Base
def self.find(*args)
setup
@@ -10,11 +10,11 @@ def self.find(*args)
when :all
find_all(args)
else
- raise HoptoadError.new('Invalid argument')
+ raise AirbrakeError.new('Invalid argument')
end
- raise HoptoadError.new('No results found.') if results.nil?
- raise HoptoadError.new(results.errors.error) if results.errors
+ raise AirbrakeError.new('No results found.') if results.nil?
+ raise AirbrakeError.new(results.errors.error) if results.errors
results.group || results.groups
end
@@ -24,11 +24,11 @@ def self.update(error, options)
response = put(error_path(error), { :query => options })
if response.code == 403
- raise HoptoadError.new('SSL should be enabled - use Hoptoad.secure = true in configuration')
+ raise AirbrakeError.new('SSL should be enabled - use Airbrake.secure = true in configuration')
end
results = Hashie::Mash.new(response)
- raise HoptoadError.new(results.errors.error) if results.errors
+ raise AirbrakeError.new(results.errors.error) if results.errors
results.group
end
@@ -1,7 +1,7 @@
require 'parallel'
-module Hoptoad
- class Notice < Hoptoad::Base
+module Airbrake
+ class Notice < Airbrake::Base
PER_PAGE = 30
PARALLEL_WORKERS = 10
@@ -11,7 +11,7 @@ def self.find(id, error_id, options={})
hash = fetch(find_path(id, error_id), options)
if hash.errors
- raise HoptoadError.new(results.errors.error)
+ raise AirbrakeError.new(results.errors.error)
end
hash.notice
@@ -27,7 +27,7 @@ def self.find_all_by_error_id(error_id, notice_options = {})
options[:page] = page
hash = fetch(all_path(error_id), options)
if hash.errors
- raise HoptoadError.new(results.errors.error)
+ raise AirbrakeError.new(results.errors.error)
end
batch = Parallel.map(hash.notices, :in_threads => PARALLEL_WORKERS) do |notice_stub|
@@ -47,7 +47,7 @@ def self.find_by_error_id(error_id, options={ 'page' => 1})
hash = fetch(all_path(error_id), options)
if hash.errors
- raise HoptoadError.new(results.errors.error)
+ raise AirbrakeError.new(results.errors.error)
end
hash.notices
@@ -1,13 +1,13 @@
-module Hoptoad
- class Project < Hoptoad::Base
+module Airbrake
+ class Project < Airbrake::Base
def self.find(*args)
setup
options = args.extract_options!
results = fetch(collection_path, options)
- raise HoptoadError.new(results.errors.error) if results.errors
+ raise AirbrakeError.new(results.errors.error) if results.errors
results.projects.project
end
@@ -1,3 +1,3 @@
-module Hoptoad
+module Airbrake
VERSION = '2.5.0'
end
@@ -1,41 +0,0 @@
-module Hoptoad
- class Base
- include HTTParty
- format :xml
-
- private
-
- def self.setup
- base_uri Hoptoad.account_path
- default_params :auth_token => Hoptoad.auth_token
-
- check_configuration
- end
-
- def self.check_configuration
- raise HoptoadError.new('API Token cannot be nil') if default_options.nil? || default_options[:default_params].nil? || !default_options[:default_params].has_key?(:auth_token)
- raise HoptoadError.new('Account cannot be nil') unless default_options.has_key?(:base_uri)
- end
-
- def self.fetch(path, options)
- response = get(path, { :query => options })
- if response.code == 403
- raise HoptoadError.new('SSL should be enabled - use Hoptoad.secure = true in configuration')
- end
-
- Hashie::Mash.new(response)
- end
-
- end
-end
-
-# hoptoad sometimes returns broken xml with strange utmz stuff
-# so we remove this
-require 'httparty/parser'
-class HTTParty::Parser
- alias utmz_unaware_xml xml
- def xml
- body.gsub!(/<__utmz>.*?<\/__utmz>/m,'')
- utmz_unaware_xml
- end
-end
@@ -1,51 +1,51 @@
require 'spec_helper'
-describe Hoptoad::Error do
+describe Airbrake::Error do
before(:all) do
- Hoptoad.account = 'myapp'
- Hoptoad.auth_token = 'abcdefg123456'
- Hoptoad.secure = false
+ Airbrake.account = 'myapp'
+ Airbrake.auth_token = 'abcdefg123456'
+ Airbrake.secure = false
end
it "should have correct collection path" do
- Hoptoad::Error.collection_path.should == "/errors.xml"
+ Airbrake::Error.collection_path.should == "/errors.xml"
end
it "should generate correct error path given an id" do
- Hoptoad::Error.error_path(1234).should == "/errors/1234.xml"
+ Airbrake::Error.error_path(1234).should == "/errors/1234.xml"
end
describe '.find' do
it "should find a page of the 30 most recent errors" do
- errors = Hoptoad::Error.find(:all)
+ errors = Airbrake::Error.find(:all)
ordered = errors.sort_by(&:most_recent_notice_at).reverse
ordered.should == errors
errors.size.should == 30
end
it "should paginate errors" do
- errors = Hoptoad::Error.find(:all, :page => 2)
+ errors = Airbrake::Error.find(:all, :page => 2)
ordered = errors.sort_by(&:most_recent_notice_at).reverse
ordered.should == errors
errors.size.should == 2
end
it "should find an individual error" do
- error = Hoptoad::Error.find(1696170)
+ error = Airbrake::Error.find(1696170)
error.action.should == 'index'
error.id.should == 1696170
end
it "should raise an error when not passed an id" do
lambda do
- Hoptoad::Error.find
- end.should raise_error(Hoptoad::HoptoadError)
+ Airbrake::Error.find
+ end.should raise_error(Airbrake::AirbrakeError)
end
end
describe '.update' do
it 'should update the status of an error' do
- error = Hoptoad::Error.update(1696170, :group => { :resolved => true})
+ error = Airbrake::Error.update(1696170, :group => { :resolved => true})
error.resolved.should be_true
end
end
Oops, something went wrong. Retry.

0 comments on commit e9abeef

Please sign in to comment.