Skip to content

Commit c387e73

Browse files
committed
initial import
1 parent c0f3b36 commit c387e73

2 files changed

Lines changed: 44 additions & 27 deletions

File tree

errbit_github_plugin.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ require 'errbit_github_plugin/version'
66
Gem::Specification.new do |spec|
77
spec.name = "errbit_github_plugin"
88
spec.version = ErrbitGithubPlugin::VERSION
9-
spec.authors = ["Cyril Mougel"]
10-
spec.email = ["cyril.mougel@gmail.com"]
11-
spec.description = %q{Add Github issue tracker plugin to errbit}
12-
spec.summary = %q{Add Github issue tracker plugin to errbit}
13-
spec.homepage = ""
9+
spec.authors = ["Stephen Crosby"]
10+
spec.email = ["stevecrozz@gmail.com"]
11+
spec.description = %q{GitHub integration for Errbit}
12+
spec.summary = %q{GitHub integration for Errbit}
13+
spec.homepage = "https://github.com/brandedcrate/errbit_github_plugin"
1414
spec.license = "MIT"
1515

1616
spec.files = `git ls-files`.split($/)

lib/errbit_github_plugin/issue_tracker.rb

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,41 @@
33
module ErrbitGithubPlugin
44
class IssueTracker < ErrbitPlugin::IssueTracker
55

6-
def label; 'github'; end
7-
def note
8-
'Please configure your github repository in the <strong>GITHUB REPO</strong> field above.<br/>' <<
9-
'Instead of providing your username & password, you can link your Github account ' <<
10-
'to your user profile, and allow Errbit to create issues using your OAuth token.'
11-
end
6+
LABEL = 'github'
7+
8+
NOTE = 'Please configure your github repository in the <strong>GITHUB ' <<
9+
'REPO</strong> field above.<br/> Instead of providing your ' <<
10+
'username & password, you can link your Github account to your ' <<
11+
'user profile, and allow Errbit to create issues using your ' <<
12+
'OAuth token.'
1213

13-
def fields
14-
{
15-
:username => {
16-
:placeholder => "Your username on GitHub"
17-
},
18-
:password => {
19-
:placeholder => "Password for your account"
20-
}
14+
FIELDS = {
15+
:username => {
16+
:placeholder => "Your username on GitHub"
17+
},
18+
:password => {
19+
:placeholder => "Password for your account"
2120
}
21+
}
22+
23+
def self.label
24+
LABEL
25+
end
26+
27+
def self.note
28+
NOTE
29+
end
30+
31+
def self.fields
32+
FIELDS
33+
end
34+
35+
def self.body_template
36+
@body_template ||= ERB.new(File.read(
37+
File.join(
38+
ErrbitGithubPlugin.root, 'views', 'github_issues_body.txt.erb'
39+
)
40+
))
2241
end
2342

2443
attr_accessor :oauth_token
@@ -35,9 +54,11 @@ def project_id
3554
end
3655

3756
def check_params
38-
if Fields.detect {|f| self[f[0]].blank? }
39-
errors.add :base, 'You must specify your GitHub username and password'
57+
errors = []
58+
if self.class.fields.detect {|f| params[f[0]].blank? }
59+
errors << [:base, 'You must specify your GitHub username and password']
4060
end
61+
errors
4162
end
4263

4364
def create_issue(problem, reported_by = nil)
@@ -52,21 +73,17 @@ def create_issue(problem, reported_by = nil)
5273
issue = client.create_issue(
5374
project_id,
5475
issue_title(problem),
55-
body_template.result(binding).unpack('C*').pack('U*')
76+
self.class.body_template.result(binding).unpack('C*').pack('U*')
5677
)
5778
@url = issue.html_url
5879
problem.update_attributes(
5980
:issue_link => issue.html_url,
60-
:issue_type => Label
81+
:issue_type => self.class.label
6182
)
6283

6384
rescue Octokit::Unauthorized
6485
raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password."
6586
end
6687
end
67-
68-
def body_template
69-
@@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/github_issues_body.txt.erb").gsub(/^\s*/, ''))
70-
end
7188
end
7289
end

0 commit comments

Comments
 (0)