airbrake_cleanup 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,26 @@
1
+ AirbrakeCleanup
2
+ ===========
3
+
4
+ Simple plugin to cleanup all hoptoad errors in an account
5
+
6
+ Example
7
+ =======
8
+
9
+ Easy cleanup of all errors on a airbrake account.
10
+
11
+ AirbrakeCleanup.account = 'your_account_name'
12
+ AirbrakeCleanup.auth_token = 'token_found_in_your_profile'
13
+ AirbrakeCleanup.process
14
+
15
+ Rails 3
16
+ =======
17
+
18
+ To include automatic cleanup on deployment in a Rails app, add the following line at the end of deploy.rb
19
+
20
+ require 'airbrake_cleanup/recipes'
21
+
22
+ and configure your credentials in an initialiser
23
+
24
+ AirbrakeCleanup.account = 'your_account_name'
25
+ AirbrakeCleanup.auth_token = 'token_found_in_your_profile'
26
+
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require 'airbrake_cleanup'
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'rest_client'
3
+ require 'airbrake_cleanup/railtie' if defined?(Rails::Railtie)
4
+
5
+ module AirbrakeCleanup
6
+ extend self
7
+ attr_accessor :account, :auth_token, :secure
8
+
9
+ def account_path
10
+ "#{protocol}://#{@account}.hoptoadapp.com"
11
+ end
12
+
13
+ def protocol
14
+ secure ? "https" : "http"
15
+ end
16
+
17
+ def process
18
+ nb = 0
19
+
20
+ # RestClient.log = 'stdout'
21
+ site = RestClient::Resource.new account_path, :payload => {:auth_token => @auth_token}, :auth_token => @auth_token
22
+ while true
23
+ res = site['errors'].get
24
+ list = (res.body.scan(/<id[^>]*>([0-9]+?)<\/id>/im) || []).flatten
25
+ break if list.size == 0
26
+
27
+ for item in list do
28
+ begin
29
+ site["errors/#{item}"].put :group => { :resolved => true}, :auth_token => @auth_token
30
+ puts "Flagged error #{item} as resolved"
31
+ nb += 1
32
+ rescue RestClient::ResourceNotFound
33
+ puts "Error #{item} not found"
34
+ end
35
+ end
36
+ end
37
+ puts "#{nb} errors resolved"
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require 'airbrake_cleanup'
3
+ require 'rails'
4
+
5
+ module AirbrakeCleanup
6
+ class Railtie < Rails::Railtie
7
+ rake_tasks do
8
+ require "airbrake_cleanup/tasks"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # Defines deploy:cleanup_hoptoad which will cleanup all errors.
2
+
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ after "deploy", "deploy:cleanup_hoptoad"
5
+
6
+ namespace :deploy do
7
+ desc "Cleanup all Hoptoad"
8
+ task :cleanup_hoptoad, :except => { :no_release => true } do
9
+ rails_env = fetch(:hoptoad_env, fetch(:rails_env, "production"))
10
+ executable = RUBY_PLATFORM.downcase.include?('mswin') ? fetch(:rake, 'rake.bat') : fetch(:rake, 'rake')
11
+ notify_command = "#{executable} hoptoad:cleanup"
12
+ notify_command << " DRY_RUN=true" if dry_run
13
+ notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
14
+ puts "Cleanup all unresolved errors (#{notify_command})"
15
+ `#{notify_command}`
16
+ puts "Hoptoad cleanup complete."
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ namespace :hoptoad do
2
+ desc "Cleanup up all hoptoad errors on deploy"
3
+ task :cleanup => :environment do
4
+ if AirbrakeCleanup.auth_token.blank? || AirbrakeCleanup.account.blank?
5
+ $stderr.puts "Missing authentication infos\nAdd the following in an initializer\AAirbrakeCleanup.account = 'account_name'\nAirbrakeCleanup.auth_token='XXXX'"
6
+ else
7
+ AirbrakeCleanup.process
8
+ end
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: airbrake_cleanup
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 7
10
+ version: 1.0.7
11
+ platform: ruby
12
+ authors:
13
+ - Olivier Ruffin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-14 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rest-client
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Allow to clean up all errors of an Airbrake account
36
+ email: olivier@muweb.fr
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README
45
+ - init.rb
46
+ - lib/airbrake_cleanup/railtie.rb
47
+ - lib/airbrake_cleanup/recipes.rb
48
+ - lib/airbrake_cleanup/tasks.rb
49
+ - lib/airbrake_cleanup.rb
50
+ has_rdoc: true
51
+ homepage: https://github.com/veilleperso/airbrake_cleanup
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.6.2
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Airbrake errors cleanup made easy
84
+ test_files: []
85
+