Class: ErrbitLighthousePlugin::IssueTracker
- Inherits:
-
ErrbitPlugin::IssueTracker
- Object
- ErrbitPlugin::IssueTracker
- ErrbitLighthousePlugin::IssueTracker
- Defined in:
- lib/errbit_lighthouse_plugin/issue_tracker.rb
Constant Summary collapse
- LABEL =
"lighthouseapp"
- FIELDS =
[ [:account, { :label => "Subdomain", :placeholder => "subdomain from http://{{subdomain}}.lighthouseapp.com" }], [:api_token, { :label => "API Token", :placeholder => "123456789abcdef123456789abcdef" }], [:project_id, { :label => "Project ID", :placeholder => "123456" }] ]
- NOTE =
""
Class Method Summary collapse
Instance Method Summary collapse
- #comments_allowed? ⇒ Boolean
-
#configured? ⇒ Boolean
configured properly if all the fields are filled in.
- #create_issue(problem, reported_by = nil) ⇒ Object
- #errors ⇒ Object
- #ticket_link(ticket) ⇒ Object
- #url ⇒ Object
Class Method Details
.body_template ⇒ Object
92 93 94 95 96 97 98 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/errbit_lighthouse_plugin/issue_tracker.rb', line 33 def self.fields FIELDS end |
.label ⇒ Object
25 26 27 |
# File 'lib/errbit_lighthouse_plugin/issue_tracker.rb', line 25 def self.label LABEL end |
.note ⇒ Object
29 30 31 |
# File 'lib/errbit_lighthouse_plugin/issue_tracker.rb', line 29 def self.note NOTE end |
Instance Method Details
#comments_allowed? ⇒ Boolean
45 46 47 |
# File 'lib/errbit_lighthouse_plugin/issue_tracker.rb', line 45 def comments_allowed? false end |
#configured? ⇒ Boolean
configured properly if all the fields are filled in
50 51 52 53 54 55 |
# 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) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# 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..to_s.truncate(100)}" ticket.body = self.class.body_template.result(binding) ticket. << "errbit" ticket.save! problem.update_attributes( :issue_link => ticket_link(ticket), :issue_type => self.class.label ) end |
#errors ⇒ Object
57 58 59 60 61 62 63 |
# 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) ⇒ Object
84 85 86 87 88 89 90 |
# 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 ⇒ Object
37 38 39 40 41 42 43 |
# 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 |