<?xml version="1.0" encoding="UTF-8"?>
<plugin-url>
  <approved type="boolean">false</approved>
  <author>David Grandinetti</author>
  <cached-tag-list>hoptoad, rails, exceptions</cached-tag-list>
  <canonical-name nil="true"></canonical-name>
  <code>require 'rubygems'
require 'activeresource'

class HoptoadStats &lt; Scout::Plugin
#  needs 'activeresource'

  def build_report

    Error.site = &quot;http://#{option('account')}.hoptoadapp.com&quot;
    Error.api_token = option('api_token')

    page = 1
    num_errors = 0
    num_notices = 0
    more_errors = true

    while more_errors do
      errors = Error.find :all, :params =&gt; { :page =&gt; page }

      if errors.size &gt; 0
        num_errors += errors.size
        errors.each do |e|
          num_notices += e.notices_count
        end
        page += 1
      else
          more_errors = false
      end
    end

    report(:errors =&gt; num_errors, :notices =&gt; num_notices)
  rescue
    error( :subject =&gt; &quot;Error talking to hoptoad or parsing xml&quot;, :body =&gt; $!.message)
  end

end

class Error&lt;ActiveResource::Base

  @api_token = &quot;&quot;

  def self.api_token=(api_token)
    @api_token = api_token
  end

  def self.find(*arguments)
      arguments = append_auth_token_to_params(*arguments)
      super(*arguments)
  end

  def self.append_auth_token_to_params(*arguments)
    opts = arguments.last.is_a?(Hash) ? arguments.pop : {}
    opts = opts.has_key?(:params) ? opts : opts.merge(:params =&gt; {}) 
    opts[:params] = opts[:params].merge(:auth_token =&gt; @api_token)
    arguments &lt;&lt; opts
    arguments
  end
end</code>
  <created-at type="datetime">2008-11-25T10:54:32-08:00</created-at>
  <default-triggers type="yaml" nil="true"></default-triggers>
  <description>Returns the total number of unresolved errors from a &lt;a href=&quot;http://hoptoadapp.com&quot;&gt;Hoptoad&lt;/a&gt; project.</description>
  <featured type="boolean">false</featured>
  <id type="integer">102</id>
  <metadata type="yaml">--- |
options:
  account:
    name: Hoptoad Account
    notes: Specify your hoptoad account name - e.g. myname.hoptoadapp.com
    default:
  api_token:
    name: Hoptoad API Token
    notes: You can find this on your hopoad profile page.
    default:

</metadata>
  <name>Hoptoad Unresolved Errors</name>
  <plugins-count type="integer">3</plugins-count>
  <rating-avg type="decimal">0.0</rating-avg>
  <rating-count type="integer">0</rating-count>
  <rating-total type="integer">0</rating-total>
  <readme>Hoptoad Unresolved Errors Plugin
=================================
Created by [David Grandinetti](http://github.com/dbgrandi)

Returns the total number of unresolved errors from a [Hoptoad](http://hoptoadapp.com) project.

Dependencies
------------
Requires ActiveResource

	sudo gem install activeresource

Compatibility 
-------------

Works on Linux and OSX. 

</readme>
  <schema type="yaml" nil="true"></schema>
  <scout-version type="integer">2</scout-version>
  <short-description>Returns the total number of unresolved errors from a Hoptoad project.</short-description>
  <tested-platforms>linux osx</tested-platforms>
  <total-usage-count type="integer">0</total-usage-count>
  <updated-at type="datetime">2010-02-23T12:26:38-08:00</updated-at>
  <url>http://github.com/highgroove/scout-plugins/raw/7d13f07023d2d284fefceca078a86718e928f4d0/hoptoad/hoptoad.rb</url>
</plugin-url>
