Module: AirbrakeCleanup

Extended by:
AirbrakeCleanup
Included in:
AirbrakeCleanup
Defined in:
lib/airbrake_cleanup.rb,
lib/airbrake_cleanup/railtie.rb

Defined Under Namespace

Classes: Railtie

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject

Returns the value of attribute account.



7
8
9
# File 'lib/airbrake_cleanup.rb', line 7

def 
  @account
end

#auth_tokenObject

Returns the value of attribute auth_token.



7
8
9
# File 'lib/airbrake_cleanup.rb', line 7

def auth_token
  @auth_token
end

#secureObject

Returns the value of attribute secure.



7
8
9
# File 'lib/airbrake_cleanup.rb', line 7

def secure
  @secure
end

Instance Method Details

#account_pathObject



9
10
11
# File 'lib/airbrake_cleanup.rb', line 9

def 
  "#{protocol}://#{@account}.airbrake.io"
end

#processObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/airbrake_cleanup.rb', line 17

def process
  nb = 0

  RestClient.log = 'stdout' if Rails.env.development?
  while true
    res = RestClient.get "#{}/errors.xml?auth_token=#{self.auth_token}"
    list = (res.body.scan(/<id[^>]*>([0-9]+?)<\/id>/im) || []).flatten
    break if list.size == 0
    
    for item in list do
      begin
        RestClient.put "#{}/errors/#{item}.xml?auth_token=#{self.auth_token}", :group => { :resolved => true}
        puts "Flagged error #{item} as resolved"
        nb += 1
      rescue RestClient::ResourceNotFound
        puts "Error #{item} not found"
      end
    end
  end
  puts "#{nb} errors resolved"
end

#protocolObject



13
14
15
# File 'lib/airbrake_cleanup.rb', line 13

def protocol
  secure ? "https" : "http"
end