Skip to content

Commit 42736b3

Browse files
committed
include view, conform to new tracker interface
1 parent c387e73 commit 42736b3

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

lib/errbit_github_plugin.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
require 'errbit_github_plugin/issue_tracker'
44
require 'errbit_github_plugin/rails'
55

6-
ErrbitPlugin::Register.add_issue_tracker(
7-
'IssueTrackers::GithubIssuesTracker',
8-
ErrbitGithubPlugin::IssueTracker
9-
)
6+
module ErrbitGithubPlugin
7+
def self.root
8+
File.expand_path '../..', __FILE__
9+
end
10+
end
11+
12+
ErrbitPlugin::Registry.add_issue_tracker(ErrbitGithubPlugin::IssueTracker)

lib/errbit_github_plugin/issue_tracker.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,30 @@ def project_id
5353
app.github_repo
5454
end
5555

56-
def check_params
56+
def errors
5757
errors = []
5858
if self.class.fields.detect {|f| params[f[0]].blank? }
5959
errors << [:base, 'You must specify your GitHub username and password']
6060
end
6161
errors
6262
end
6363

64-
def create_issue(problem, reported_by = nil)
64+
def github_client
6565
# Login using OAuth token, if given.
6666
if oauth_token
67-
client = Octokit::Client.new(:login => username, :oauth_token => oauth_token)
67+
Octokit::Client.new(
68+
:login => params['username'], :oauth_token => oauth_token)
6869
else
69-
client = Octokit::Client.new(:login => username, :password => password)
70+
Octokit::Client.new(
71+
:login => params['username'], :password => params['password'])
7072
end
73+
end
7174

75+
def create_issue(problem, reported_by = nil)
7276
begin
73-
issue = client.create_issue(
77+
issue = github_client.create_issue(
7478
project_id,
75-
issue_title(problem),
79+
"[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}",
7680
self.class.body_template.result(binding).unpack('C*').pack('U*')
7781
)
7882
@url = issue.html_url

views/github_issues_body.txt.erb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[See this exception on Errbit](<%= problem.url %> "See this exception on Errbit")
2+
<% if notice = problem.notices.first %>
3+
# <%= notice.message %> #
4+
## Summary ##
5+
<% if notice.request['url'].present? %>
6+
### URL ###
7+
[<%= notice.request['url'] %>](<%= notice.request['url'] %>)"
8+
<% end %>
9+
### Where ###
10+
<%= notice.where %>
11+
12+
### Occured ###
13+
<%= notice.created_at.to_s(:micro) %>
14+
15+
### Similar ###
16+
<%= (notice.problem.notices_count - 1).to_s %>
17+
18+
## Params ##
19+
```
20+
<%= pretty_hash(notice.params) %>
21+
```
22+
23+
## Session ##
24+
```
25+
<%= pretty_hash(notice.session) %>
26+
```
27+
28+
## Backtrace ##
29+
```
30+
<% notice.backtrace_lines.each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>**
31+
<% end %>
32+
```
33+
34+
## Environment ##
35+
36+
<table>
37+
<% for key, val in notice.env_vars %>
38+
<tr>
39+
<td><%= key %>:</td>
40+
<td><%= val %></td>
41+
</tr>
42+
<% end %>
43+
</table>
44+
<% end %>
45+

0 commit comments

Comments
 (0)