class ErrbitLighthousePlugin::IssueTracker
Constants
- FIELDS
- LABEL
- NOTE
Public Class Methods
body_template()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 92 def self.body_template @body_template ||= ERB.new(File.read( File.join( ErrbitLighthousePlugin.root, 'views', 'lighthouseapp_body.txt.erb' ) )) end
fields()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 33 def self.fields FIELDS end
label()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 25 def self.label LABEL end
note()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 29 def self.note NOTE end
Public Instance Methods
comments_allowed?()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 45 def comments_allowed? false end
configured?()
click to toggle source
configured properly if all the fields are filled in
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 50 def configured? non_empty_params = params.reject { |k,v| v.empty? }.keys.map(&:intern) required_fields = FIELDS.map { |f| f[0].intern } (required_fields - non_empty_params).empty? end
create_issue(problem, reported_by = nil)
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 65 def create_issue(problem, reported_by = nil) Lighthouse.account = params['account'] Lighthouse.token = params['api_token'] # updating lighthouse account Lighthouse::Ticket.site Lighthouse::Ticket.format = :xml ticket = Lighthouse::Ticket.new(:project_id => params['project_id']) ticket.title = "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}" ticket.body = self.class.body_template.result(binding) ticket.tags << "errbit" ticket.save! problem.update_attributes( :issue_link => ticket_link(ticket), :issue_type => self.class.label ) end
errors()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 57 def errors errors = [] if FIELDS.detect {|f| params[f[0]].blank? } errors << [:base, 'You must specify your Lighthouseapp Subdomain, API token and Project ID'] end errors end
ticket_link(ticket)
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 84 def ticket_link(ticket) Lighthouse::Ticket.site.to_s .sub(/#{Lighthouse::Ticket.site.path}$/, '') << Lighthouse::Ticket.element_path( ticket.id, :project_id => params['project_id']) .sub(/\.xml$/, '') end
url()
click to toggle source
# File lib/errbit_lighthouse_plugin/issue_tracker.rb, line 37 def url sprintf( "http://%s.lighthouseapp.com/projects/%s", params[:subdomain], params[:project_id] ) end