Class: ErrorStalker::Plugin::LighthouseReporter
- Defined in:
- lib/error_stalker/plugin/lighthouse_reporter.rb
Overview
A simple plugin for reporting exceptions as new bugs in Lighthouse. When this plugin is enabled, a new link will show up on the exception detail page that pre-populates a form for sending the exception report to Lighthouse.
Defined Under Namespace
Modules: Actions
Instance Attribute Summary collapse
-
#project_id ⇒ Object
readonly
The lighthouse project id that this plugin will report bugs to.
Instance Method Summary collapse
-
#exception_links(exception_report) ⇒ Object
A list containing the link that will show up on the exception report’s detail page.
-
#initialize(app, params = {}) ⇒ LighthouseReporter
constructor
Creates a new instance of this plugin.
-
#new_ticket(request, exception) ⇒ Object
Create a new Lighthouse ticket object pre-populated with information about
exception. -
#post_ticket(params) ⇒ Object
Post a new ticket to lighthouse with the params specified in
params.
Methods inherited from Base
Constructor Details
#initialize(app, params = {}) ⇒ LighthouseReporter
Creates a new instance of this plugin. There are a few parameters that must be passed in in order for this plugin to work correctly:
23 24 25 26 27 28 29 30 |
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 23 def initialize(app, params = {}) super(app, params) app.class.send(:include, Actions) app.lighthouse = self Lighthouse.account = params['account'] Lighthouse.token = params['token'] @project_id = params['project_id'] end |
Instance Attribute Details
#project_id ⇒ Object (readonly)
The lighthouse project id that this plugin will report bugs to.
10 11 12 |
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 10 def project_id @project_id end |
Instance Method Details
#exception_links(exception_report) ⇒ Object
A list containing the link that will show up on the exception report’s detail page. This link hooks into one of the new actions defined by this plugin.
35 36 37 |
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 35 def exception_links(exception_report) super(exception_report) + [["Report to Lighthouse", "/lighthouse/report/#{exception_report.id}.html"]] end |
#new_ticket(request, exception) ⇒ Object
Create a new Lighthouse ticket object pre-populated with information about exception.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 41 def new_ticket(request, exception) ticket = Lighthouse::Ticket.new(:project_id => project_id) ticket.title = "Exception: #{exception.exception}" host_with_port = request.host host_with_port << ":#{request.port}" if request.port != 80 ticket_link = "#{request.scheme}://#{host_with_port}/exceptions/#{exception.id}.html" ticket.body = ticket_link ticket. = "exception" ticket end |
#post_ticket(params) ⇒ Object
Post a new ticket to lighthouse with the params specified in params.
54 55 56 57 58 59 60 |
# File 'lib/error_stalker/plugin/lighthouse_reporter.rb', line 54 def post_ticket(params) ticket = Lighthouse::Ticket.new(:project_id => project_id) ticket.title = params[:title] ticket.body = params[:body] ticket. = params[:tags] ticket.save end |