Commit 18c3dc28ea5b0eb3f645266a336e035a77ab5aff
Exists in
master
and in
1 other branch
Merge branch 'master' of https://github.com/errbit/errbit into issue_148
Showing
11 changed files
with
321 additions
and
291 deletions
Show diff stats
Gemfile
1 | source 'http://rubygems.org' | 1 | source 'http://rubygems.org' |
2 | 2 | ||
3 | gem 'rails', '3.2.8' | 3 | gem 'rails', '3.2.8' |
4 | - | ||
5 | -gem 'nokogiri' | ||
6 | gem 'mongoid', '~> 2.4.10' | 4 | gem 'mongoid', '~> 2.4.10' |
7 | - | ||
8 | -# force SSL | ||
9 | -gem 'rack-ssl', :require => 'rack/ssl' | ||
10 | - | 5 | +gem 'mongoid_rails_migrations' |
6 | +gem 'devise', '~> 1.5.3' | ||
7 | +gem 'nokogiri' | ||
11 | gem 'haml' | 8 | gem 'haml' |
12 | gem 'htmlentities', "~> 4.3.0" | 9 | gem 'htmlentities', "~> 4.3.0" |
10 | +gem 'rack-ssl', :require => 'rack/ssl' # force SSL | ||
13 | 11 | ||
14 | -gem 'devise', '~> 1.5.3' | 12 | +gem 'useragent', '~> 0.3.1' |
13 | +gem 'inherited_resources' | ||
14 | +gem 'SystemTimer', :platform => :ruby_18 | ||
15 | +gem 'actionmailer_inline_css', "~> 1.3.0" | ||
16 | +gem 'kaminari' | ||
17 | +gem 'rack-ssl-enforcer' | ||
18 | +gem 'fabrication', "~> 1.3.0" # Used for both tests and demo data | ||
19 | +gem 'rails_autolink', '~> 1.0.9' | ||
20 | +# Please don't update hoptoad_notifier to airbrake. | ||
21 | +# It's for internal use only, and we monkeypatch certain methods | ||
22 | +gem 'hoptoad_notifier', "~> 2.4" | ||
15 | 23 | ||
16 | -gem 'omniauth-github' | ||
17 | -gem 'oa-core' | ||
18 | 24 | ||
25 | +# Remove / comment out any of the gems below if you want to disable | ||
26 | +# a given issue tracker, notification service, or authentication. | ||
27 | + | ||
28 | +# Issue Trackers | ||
29 | +# --------------------------------------- | ||
30 | +# Lighthouse | ||
19 | gem 'lighthouse-api' | 31 | gem 'lighthouse-api' |
32 | +# Redmine | ||
20 | gem 'oruen_redmine_client', :require => 'redmine_client' | 33 | gem 'oruen_redmine_client', :require => 'redmine_client' |
21 | -gem 'mongoid_rails_migrations' | ||
22 | -gem 'useragent', '~> 0.3.1' | 34 | +# Pivotal Tracker |
23 | gem 'pivotal-tracker' | 35 | gem 'pivotal-tracker' |
36 | +# Fogbugz | ||
24 | gem 'ruby-fogbugz', :require => 'fogbugz' | 37 | gem 'ruby-fogbugz', :require => 'fogbugz' |
25 | - | 38 | +# Github Issues |
26 | gem 'octokit', '~> 1.0.0' | 39 | gem 'octokit', '~> 1.0.0' |
27 | 40 | ||
28 | -gem 'inherited_resources' | ||
29 | -gem 'SystemTimer', :platform => :ruby_18 | ||
30 | -gem 'actionmailer_inline_css', "~> 1.3.0" | ||
31 | -gem 'kaminari' | ||
32 | -gem 'rack-ssl-enforcer' | ||
33 | -gem 'fabrication', "~> 1.3.0" # Both for tests, and loading demo data | ||
34 | -gem 'rails_autolink', '~> 1.0.9' | 41 | +# Notification services |
42 | +# --------------------------------------- | ||
43 | +# Campfire | ||
35 | gem 'campy' | 44 | gem 'campy' |
45 | +# Hipchat | ||
36 | gem 'hipchat' | 46 | gem 'hipchat' |
37 | gem 'hoi' | 47 | gem 'hoi' |
38 | 48 | ||
39 | -# Please don't update this to airbrake - We override the send_notice method | ||
40 | -# to handle internal errors. | ||
41 | -gem 'hoptoad_notifier', "~> 2.4" | 49 | +# Authentication |
50 | +# --------------------------------------- | ||
51 | +# GitHub OAuth | ||
52 | +gem 'omniauth-github' | ||
53 | + | ||
42 | 54 | ||
43 | platform :ruby do | 55 | platform :ruby do |
44 | gem 'mongo', '= 1.6.2' | 56 | gem 'mongo', '= 1.6.2' |
@@ -46,6 +58,8 @@ platform :ruby do | @@ -46,6 +58,8 @@ platform :ruby do | ||
46 | gem 'bson_ext', '= 1.6.2' | 58 | gem 'bson_ext', '= 1.6.2' |
47 | end | 59 | end |
48 | 60 | ||
61 | +gem 'omniauth' | ||
62 | +gem 'oa-core' | ||
49 | gem 'ri_cal' | 63 | gem 'ri_cal' |
50 | gem 'yajl-ruby', :require => "yajl" | 64 | gem 'yajl-ruby', :require => "yajl" |
51 | 65 |
Gemfile.lock
@@ -85,7 +85,7 @@ GEM | @@ -85,7 +85,7 @@ GEM | ||
85 | execjs (1.4.0) | 85 | execjs (1.4.0) |
86 | multi_json (~> 1.0) | 86 | multi_json (~> 1.0) |
87 | fabrication (1.3.2) | 87 | fabrication (1.3.2) |
88 | - faraday (0.8.1) | 88 | + faraday (0.8.4) |
89 | multipart-post (~> 1.1) | 89 | multipart-post (~> 1.1) |
90 | faraday_middleware (0.8.8) | 90 | faraday_middleware (0.8.8) |
91 | faraday (>= 0.7.4, < 0.9) | 91 | faraday (>= 0.7.4, < 0.9) |
@@ -175,13 +175,13 @@ GEM | @@ -175,13 +175,13 @@ GEM | ||
175 | faraday_middleware (~> 0.8) | 175 | faraday_middleware (~> 0.8) |
176 | hashie (~> 1.2) | 176 | hashie (~> 1.2) |
177 | multi_json (~> 1.3) | 177 | multi_json (~> 1.3) |
178 | - omniauth (1.1.0) | 178 | + omniauth (1.1.1) |
179 | hashie (~> 1.2) | 179 | hashie (~> 1.2) |
180 | rack | 180 | rack |
181 | omniauth-github (1.0.2) | 181 | omniauth-github (1.0.2) |
182 | omniauth (~> 1.0) | 182 | omniauth (~> 1.0) |
183 | omniauth-oauth2 (~> 1.1) | 183 | omniauth-oauth2 (~> 1.1) |
184 | - omniauth-oauth2 (1.1.0) | 184 | + omniauth-oauth2 (1.1.1) |
185 | oauth2 (~> 0.8.0) | 185 | oauth2 (~> 0.8.0) |
186 | omniauth (~> 1.0) | 186 | omniauth (~> 1.0) |
187 | orm_adapter (0.0.7) | 187 | orm_adapter (0.0.7) |
@@ -334,6 +334,7 @@ DEPENDENCIES | @@ -334,6 +334,7 @@ DEPENDENCIES | ||
334 | nokogiri | 334 | nokogiri |
335 | oa-core | 335 | oa-core |
336 | octokit (~> 1.0.0) | 336 | octokit (~> 1.0.0) |
337 | + omniauth | ||
337 | omniauth-github | 338 | omniauth-github |
338 | oruen_redmine_client | 339 | oruen_redmine_client |
339 | pivotal-tracker | 340 | pivotal-tracker |
app/models/issue_trackers/fogbugz_tracker.rb
1 | -class IssueTrackers::FogbugzTracker < IssueTracker | ||
2 | - Label = "fogbugz" | ||
3 | - Fields = [ | ||
4 | - [:project_id, { | ||
5 | - :label => "Area Name" | ||
6 | - }], | ||
7 | - [:account, { | ||
8 | - :label => "FogBugz URL", | ||
9 | - :placeholder => "abc from http://abc.fogbugz.com/" | ||
10 | - }], | ||
11 | - [:username, { | ||
12 | - :placeholder => "Username/Email for your account" | ||
13 | - }], | ||
14 | - [:password, { | ||
15 | - :placeholder => "Password for your account" | ||
16 | - }] | ||
17 | - ] | ||
18 | - | ||
19 | - def check_params | ||
20 | - if Fields.detect {|f| self[f[0]].blank? } | ||
21 | - errors.add :base, 'You must specify your FogBugz Area Name, FogBugz URL, Username, and Password' | 1 | +if defined? Fogbugz |
2 | + class IssueTrackers::FogbugzTracker < IssueTracker | ||
3 | + Label = "fogbugz" | ||
4 | + Fields = [ | ||
5 | + [:project_id, { | ||
6 | + :label => "Area Name" | ||
7 | + }], | ||
8 | + [:account, { | ||
9 | + :label => "FogBugz URL", | ||
10 | + :placeholder => "abc from http://abc.fogbugz.com/" | ||
11 | + }], | ||
12 | + [:username, { | ||
13 | + :placeholder => "Username/Email for your account" | ||
14 | + }], | ||
15 | + [:password, { | ||
16 | + :placeholder => "Password for your account" | ||
17 | + }] | ||
18 | + ] | ||
19 | + | ||
20 | + def check_params | ||
21 | + if Fields.detect {|f| self[f[0]].blank? } | ||
22 | + errors.add :base, 'You must specify your FogBugz Area Name, FogBugz URL, Username, and Password' | ||
23 | + end | ||
22 | end | 24 | end |
23 | - end | ||
24 | 25 | ||
25 | - def create_issue(problem, reported_by = nil) | ||
26 | - fogbugz = Fogbugz::Interface.new(:email => username, :password => password, :uri => "https://#{account}.fogbugz.com") | ||
27 | - fogbugz.authenticate | 26 | + def create_issue(problem, reported_by = nil) |
27 | + fogbugz = Fogbugz::Interface.new(:email => username, :password => password, :uri => "https://#{account}.fogbugz.com") | ||
28 | + fogbugz.authenticate | ||
28 | 29 | ||
29 | - issue = {} | ||
30 | - issue['sTitle'] = issue_title problem | ||
31 | - issue['sArea'] = project_id | ||
32 | - issue['sEvent'] = body_template.result(binding) | ||
33 | - issue['sTags'] = ['errbit'].join(',') | ||
34 | - issue['cols'] = ['ixBug'].join(',') | 30 | + issue = {} |
31 | + issue['sTitle'] = issue_title problem | ||
32 | + issue['sArea'] = project_id | ||
33 | + issue['sEvent'] = body_template.result(binding) | ||
34 | + issue['sTags'] = ['errbit'].join(',') | ||
35 | + issue['cols'] = ['ixBug'].join(',') | ||
35 | 36 | ||
36 | - fb_resp = fogbugz.command(:new, issue) | ||
37 | - problem.update_attributes( | ||
38 | - :issue_link => "https://#{account}.fogbugz.com/default.asp?#{fb_resp['case']['ixBug']}", | ||
39 | - :issue_type => Label | ||
40 | - ) | 37 | + fb_resp = fogbugz.command(:new, issue) |
38 | + problem.update_attributes( | ||
39 | + :issue_link => "https://#{account}.fogbugz.com/default.asp?#{fb_resp['case']['ixBug']}", | ||
40 | + :issue_type => Label | ||
41 | + ) | ||
41 | 42 | ||
42 | - end | 43 | + end |
43 | 44 | ||
44 | - def body_template | ||
45 | - @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/fogbugz_body.txt.erb")) | ||
46 | - end | 45 | + def body_template |
46 | + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/fogbugz_body.txt.erb")) | ||
47 | + end | ||
47 | 48 | ||
48 | - def url | ||
49 | - "http://#{account}.fogbugz.com/" | 49 | + def url |
50 | + "http://#{account}.fogbugz.com/" | ||
51 | + end | ||
50 | end | 52 | end |
51 | end | 53 | end |
52 | - |
app/models/issue_trackers/github_issues_tracker.rb
1 | -class IssueTrackers::GithubIssuesTracker < IssueTracker | ||
2 | - Label = "github" | ||
3 | - Note = 'Please configure your github repository in the <strong>GITHUB REPO</strong> field above.<br/>' << | ||
4 | - 'Instead of providing your username & password, you can link your Github account ' << | ||
5 | - 'to your user profile, and allow Errbit to create issues using your OAuth token.' | ||
6 | - | ||
7 | - Fields = [ | ||
8 | - [:username, { | ||
9 | - :placeholder => "Your username on GitHub" | ||
10 | - }], | ||
11 | - [:password, { | ||
12 | - :placeholder => "Password for your account" | ||
13 | - }] | ||
14 | - ] | ||
15 | - | ||
16 | - attr_accessor :oauth_token | ||
17 | - | ||
18 | - def project_id | ||
19 | - app.github_repo | ||
20 | - end | ||
21 | - | ||
22 | - def check_params | ||
23 | - if Fields.detect {|f| self[f[0]].blank? } | ||
24 | - errors.add :base, 'You must specify your GitHub username and password' | 1 | +if defined? Octokit |
2 | + class IssueTrackers::GithubIssuesTracker < IssueTracker | ||
3 | + Label = "github" | ||
4 | + Note = 'Please configure your github repository in the <strong>GITHUB REPO</strong> field above.<br/>' << | ||
5 | + 'Instead of providing your username & password, you can link your Github account ' << | ||
6 | + 'to your user profile, and allow Errbit to create issues using your OAuth token.' | ||
7 | + | ||
8 | + Fields = [ | ||
9 | + [:username, { | ||
10 | + :placeholder => "Your username on GitHub" | ||
11 | + }], | ||
12 | + [:password, { | ||
13 | + :placeholder => "Password for your account" | ||
14 | + }] | ||
15 | + ] | ||
16 | + | ||
17 | + attr_accessor :oauth_token | ||
18 | + | ||
19 | + def project_id | ||
20 | + app.github_repo | ||
25 | end | 21 | end |
26 | - end | ||
27 | 22 | ||
28 | - def create_issue(problem, reported_by = nil) | ||
29 | - # Login using OAuth token, if given. | ||
30 | - if oauth_token | ||
31 | - client = Octokit::Client.new(:login => username, :oauth_token => oauth_token) | ||
32 | - else | ||
33 | - client = Octokit::Client.new(:login => username, :password => password) | 23 | + def check_params |
24 | + if Fields.detect {|f| self[f[0]].blank? } | ||
25 | + errors.add :base, 'You must specify your GitHub username and password' | ||
26 | + end | ||
34 | end | 27 | end |
35 | 28 | ||
36 | - begin | ||
37 | - issue = client.create_issue(project_id, issue_title(problem), body_template.result(binding).unpack('C*').pack('U*'), options = {}) | ||
38 | - problem.update_attributes( | ||
39 | - :issue_link => issue.html_url, | ||
40 | - :issue_type => Label | ||
41 | - ) | ||
42 | - | ||
43 | - rescue Octokit::Unauthorized | ||
44 | - raise IssueTrackers::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password." | 29 | + def create_issue(problem, reported_by = nil) |
30 | + # Login using OAuth token, if given. | ||
31 | + if oauth_token | ||
32 | + client = Octokit::Client.new(:login => username, :oauth_token => oauth_token) | ||
33 | + else | ||
34 | + client = Octokit::Client.new(:login => username, :password => password) | ||
35 | + end | ||
36 | + | ||
37 | + begin | ||
38 | + issue = client.create_issue(project_id, issue_title(problem), body_template.result(binding).unpack('C*').pack('U*'), options = {}) | ||
39 | + problem.update_attributes( | ||
40 | + :issue_link => issue.html_url, | ||
41 | + :issue_type => Label | ||
42 | + ) | ||
43 | + | ||
44 | + rescue Octokit::Unauthorized | ||
45 | + raise IssueTrackers::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password." | ||
46 | + end | ||
45 | end | 47 | end |
46 | - end | ||
47 | 48 | ||
48 | - def body_template | ||
49 | - @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/github_issues_body.txt.erb").gsub(/^\s*/, '')) | ||
50 | - end | 49 | + def body_template |
50 | + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/github_issues_body.txt.erb").gsub(/^\s*/, '')) | ||
51 | + end | ||
51 | 52 | ||
52 | - def url | ||
53 | - "https://github.com/#{project_id}/issues" | 53 | + def url |
54 | + "https://github.com/#{project_id}/issues" | ||
55 | + end | ||
54 | end | 56 | end |
55 | -end | 57 | -end |
58 | +end | ||
56 | \ No newline at end of file | 59 | \ No newline at end of file |
app/models/issue_trackers/lighthouse_tracker.rb
1 | -class IssueTrackers::LighthouseTracker < IssueTracker | ||
2 | - Label = "lighthouseapp" | ||
3 | - Fields = [ | ||
4 | - [:account, { | ||
5 | - :placeholder => "abc from http://abc.lighthouseapp.com" | ||
6 | - }], | ||
7 | - [:api_token, { | ||
8 | - :placeholder => "API Token for your account" | ||
9 | - }], | ||
10 | - [:project_id, { | ||
11 | - :placeholder => "Lighthouse project" | ||
12 | - }] | ||
13 | - ] | ||
14 | - | ||
15 | - def check_params | ||
16 | - if Fields.detect {|f| self[f[0]].blank? } | ||
17 | - errors.add :base, 'You must specify your Lighthouseapp account, API token and Project ID' | 1 | +if defined? Lighthouse |
2 | + class IssueTrackers::LighthouseTracker < IssueTracker | ||
3 | + Label = "lighthouseapp" | ||
4 | + Fields = [ | ||
5 | + [:account, { | ||
6 | + :placeholder => "abc from http://abc.lighthouseapp.com" | ||
7 | + }], | ||
8 | + [:api_token, { | ||
9 | + :placeholder => "API Token for your account" | ||
10 | + }], | ||
11 | + [:project_id, { | ||
12 | + :placeholder => "Lighthouse project" | ||
13 | + }] | ||
14 | + ] | ||
15 | + | ||
16 | + def check_params | ||
17 | + if Fields.detect {|f| self[f[0]].blank? } | ||
18 | + errors.add :base, 'You must specify your Lighthouseapp account, API token and Project ID' | ||
19 | + end | ||
18 | end | 20 | end |
19 | - end | ||
20 | 21 | ||
21 | - def create_issue(problem, reported_by = nil) | ||
22 | - Lighthouse.account = account | ||
23 | - Lighthouse.token = api_token | ||
24 | - # updating lighthouse account | ||
25 | - Lighthouse::Ticket.site | ||
26 | - Lighthouse::Ticket.format = :xml | ||
27 | - ticket = Lighthouse::Ticket.new(:project_id => project_id) | ||
28 | - ticket.title = issue_title problem | 22 | + def create_issue(problem, reported_by = nil) |
23 | + Lighthouse.account = account | ||
24 | + Lighthouse.token = api_token | ||
25 | + # updating lighthouse account | ||
26 | + Lighthouse::Ticket.site | ||
27 | + Lighthouse::Ticket.format = :xml | ||
28 | + ticket = Lighthouse::Ticket.new(:project_id => project_id) | ||
29 | + ticket.title = issue_title problem | ||
29 | 30 | ||
30 | - ticket.body = body_template.result(binding) | 31 | + ticket.body = body_template.result(binding) |
31 | 32 | ||
32 | - ticket.tags << "errbit" | ||
33 | - ticket.save! | ||
34 | - problem.update_attributes( | ||
35 | - :issue_link => "#{Lighthouse::Ticket.site.to_s.sub(/#{Lighthouse::Ticket.site.path}$/, '')}#{Lighthouse::Ticket.element_path(ticket.id, :project_id => project_id)}".sub(/\.xml$/, ''), | ||
36 | - :issue_type => Label | ||
37 | - ) | 33 | + ticket.tags << "errbit" |
34 | + ticket.save! | ||
35 | + problem.update_attributes( | ||
36 | + :issue_link => "#{Lighthouse::Ticket.site.to_s.sub(/#{Lighthouse::Ticket.site.path}$/, '')}#{Lighthouse::Ticket.element_path(ticket.id, :project_id => project_id)}".sub(/\.xml$/, ''), | ||
37 | + :issue_type => Label | ||
38 | + ) | ||
38 | 39 | ||
39 | - end | 40 | + end |
40 | 41 | ||
41 | - def body_template | ||
42 | - @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/lighthouseapp_body.txt.erb").gsub(/^\s*/, '')) | ||
43 | - end | 42 | + def body_template |
43 | + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/lighthouseapp_body.txt.erb").gsub(/^\s*/, '')) | ||
44 | + end | ||
44 | 45 | ||
45 | - def url | ||
46 | - "http://#{account}.lighthouseapp.com" | 46 | + def url |
47 | + "http://#{account}.lighthouseapp.com" | ||
48 | + end | ||
47 | end | 49 | end |
48 | -end | ||
49 | - | 50 | +end |
50 | \ No newline at end of file | 51 | \ No newline at end of file |
app/models/issue_trackers/pivotal_labs_tracker.rb
1 | -class IssueTrackers::PivotalLabsTracker < IssueTracker | ||
2 | - Label = "pivotal" | ||
3 | - Fields = [ | ||
4 | - [:api_token, { | ||
5 | - :placeholder => "API Token for your account" | ||
6 | - }], | ||
7 | - [:project_id, {}] | ||
8 | - ] | 1 | +if defined? PivotalTracker |
2 | + class IssueTrackers::PivotalLabsTracker < IssueTracker | ||
3 | + Label = "pivotal" | ||
4 | + Fields = [ | ||
5 | + [:api_token, { | ||
6 | + :placeholder => "API Token for your account" | ||
7 | + }], | ||
8 | + [:project_id, {}] | ||
9 | + ] | ||
9 | 10 | ||
10 | - def check_params | ||
11 | - if Fields.detect {|f| self[f[0]].blank? } | ||
12 | - errors.add :base, 'You must specify your Pivotal Tracker API token and Project ID' | 11 | + def check_params |
12 | + if Fields.detect {|f| self[f[0]].blank? } | ||
13 | + errors.add :base, 'You must specify your Pivotal Tracker API token and Project ID' | ||
14 | + end | ||
13 | end | 15 | end |
14 | - end | ||
15 | 16 | ||
16 | - def create_issue(problem, reported_by = nil) | ||
17 | - PivotalTracker::Client.token = api_token | ||
18 | - PivotalTracker::Client.use_ssl = true | ||
19 | - project = PivotalTracker::Project.find project_id.to_i | ||
20 | - story = project.stories.create :name => issue_title(problem), | ||
21 | - :story_type => 'bug', :description => body_template.result(binding), | ||
22 | - :requested_by => reported_by.name | 17 | + def create_issue(problem, reported_by = nil) |
18 | + PivotalTracker::Client.token = api_token | ||
19 | + PivotalTracker::Client.use_ssl = true | ||
20 | + project = PivotalTracker::Project.find project_id.to_i | ||
21 | + story = project.stories.create :name => issue_title(problem), | ||
22 | + :story_type => 'bug', :description => body_template.result(binding), | ||
23 | + :requested_by => reported_by.name | ||
23 | 24 | ||
24 | - if story.errors.present? | ||
25 | - raise IssueTrackers::IssueTrackerError, story.errors.first | ||
26 | - else | ||
27 | - problem.update_attributes( | ||
28 | - :issue_link => "https://www.pivotaltracker.com/story/show/#{story.id}", | ||
29 | - :issue_type => Label | ||
30 | - ) | 25 | + if story.errors.present? |
26 | + raise IssueTrackers::IssueTrackerError, story.errors.first | ||
27 | + else | ||
28 | + problem.update_attributes( | ||
29 | + :issue_link => "https://www.pivotaltracker.com/story/show/#{story.id}", | ||
30 | + :issue_type => Label | ||
31 | + ) | ||
32 | + end | ||
31 | end | 33 | end |
32 | - end | ||
33 | 34 | ||
34 | - def body_template | ||
35 | - @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/pivotal_body.txt.erb")) | ||
36 | - end | 35 | + def body_template |
36 | + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/pivotal_body.txt.erb")) | ||
37 | + end | ||
37 | 38 | ||
38 | - def url | ||
39 | - "https://www.pivotaltracker.com/" | 39 | + def url |
40 | + "https://www.pivotaltracker.com/" | ||
41 | + end | ||
40 | end | 42 | end |
41 | -end | ||
42 | - | 43 | +end |
43 | \ No newline at end of file | 44 | \ No newline at end of file |
app/models/issue_trackers/redmine_tracker.rb
1 | -class IssueTrackers::RedmineTracker < IssueTracker | ||
2 | - Label = "redmine" | ||
3 | - Fields = [ | ||
4 | - [:account, { | ||
5 | - :label => "Redmine URL", | ||
6 | - :placeholder => "e.g. http://www.redmine.org/" | ||
7 | - }], | ||
8 | - [:api_token, { | ||
9 | - :placeholder => "API Token for your account" | ||
10 | - }], | ||
11 | - [:project_id, { | ||
12 | - :label => "Ticket Project", | ||
13 | - :placeholder => "Redmine Project where tickets will be created" | ||
14 | - }], | ||
15 | - [:alt_project_id, { | ||
16 | - :optional => true, | ||
17 | - :label => "App Project", | ||
18 | - :placeholder => "Where app's files & revisions can be viewed. (Leave blank to use the above project by default)" | ||
19 | - }] | ||
20 | - ] | 1 | +if defined? RedmineClient |
2 | + class IssueTrackers::RedmineTracker < IssueTracker | ||
3 | + Label = "redmine" | ||
4 | + Fields = [ | ||
5 | + [:account, { | ||
6 | + :label => "Redmine URL", | ||
7 | + :placeholder => "e.g. http://www.redmine.org/" | ||
8 | + }], | ||
9 | + [:api_token, { | ||
10 | + :placeholder => "API Token for your account" | ||
11 | + }], | ||
12 | + [:project_id, { | ||
13 | + :label => "Ticket Project", | ||
14 | + :placeholder => "Redmine Project where tickets will be created" | ||
15 | + }], | ||
16 | + [:alt_project_id, { | ||
17 | + :optional => true, | ||
18 | + :label => "App Project", | ||
19 | + :placeholder => "Where app's files & revisions can be viewed. (Leave blank to use the above project by default)" | ||
20 | + }] | ||
21 | + ] | ||
21 | 22 | ||
22 | - def check_params | ||
23 | - if Fields.detect {|f| self[f[0]].blank? && !f[1][:optional]} | ||
24 | - errors.add :base, 'You must specify your Redmine URL, API token and Project ID' | 23 | + def check_params |
24 | + if Fields.detect {|f| self[f[0]].blank? && !f[1][:optional]} | ||
25 | + errors.add :base, 'You must specify your Redmine URL, API token and Project ID' | ||
26 | + end | ||
25 | end | 27 | end |
26 | - end | ||
27 | 28 | ||
28 | - def create_issue(problem, reported_by = nil) | ||
29 | - token = api_token | ||
30 | - acc = account | ||
31 | - RedmineClient::Base.configure do | ||
32 | - self.token = token | ||
33 | - self.site = acc | ||
34 | - self.format = :xml | 29 | + def create_issue(problem, reported_by = nil) |
30 | + token = api_token | ||
31 | + acc = account | ||
32 | + RedmineClient::Base.configure do | ||
33 | + self.token = token | ||
34 | + self.site = acc | ||
35 | + self.format = :xml | ||
36 | + end | ||
37 | + issue = RedmineClient::Issue.new(:project_id => project_id) | ||
38 | + issue.subject = issue_title problem | ||
39 | + issue.description = body_template.result(binding) | ||
40 | + issue.save! | ||
41 | + problem.update_attributes( | ||
42 | + :issue_link => "#{RedmineClient::Issue.site.to_s.sub(/#{RedmineClient::Issue.site.path}$/, '')}#{RedmineClient::Issue.element_path(issue.id, :project_id => project_id)}".sub(/\.xml\?project_id=#{project_id}$/, "\?project_id=#{project_id}"), | ||
43 | + :issue_type => Label | ||
44 | + ) | ||
35 | end | 45 | end |
36 | - issue = RedmineClient::Issue.new(:project_id => project_id) | ||
37 | - issue.subject = issue_title problem | ||
38 | - issue.description = body_template.result(binding) | ||
39 | - issue.save! | ||
40 | - problem.update_attributes( | ||
41 | - :issue_link => "#{RedmineClient::Issue.site.to_s.sub(/#{RedmineClient::Issue.site.path}$/, '')}#{RedmineClient::Issue.element_path(issue.id, :project_id => project_id)}".sub(/\.xml\?project_id=#{project_id}$/, "\?project_id=#{project_id}"), | ||
42 | - :issue_type => Label | ||
43 | - ) | ||
44 | - end | ||
45 | 46 | ||
46 | - def url_to_file(file_path, line_number = nil) | ||
47 | - # alt_project_id let's users specify a different project for tickets / app files. | ||
48 | - project = self.alt_project_id.present? ? self.alt_project_id : self.project_id | ||
49 | - url = "#{self.account}/projects/#{project}/repository/annotate/#{file_path.sub(/^\//,'')}" | ||
50 | - line_number ? url << "#L#{line_number}" : url | ||
51 | - end | 47 | + def url_to_file(file_path, line_number = nil) |
48 | + # alt_project_id let's users specify a different project for tickets / app files. | ||
49 | + project = self.alt_project_id.present? ? self.alt_project_id : self.project_id | ||
50 | + url = "#{self.account}/projects/#{project}/repository/annotate/#{file_path.sub(/^\//,'')}" | ||
51 | + line_number ? url << "#L#{line_number}" : url | ||
52 | + end | ||
52 | 53 | ||
53 | - def body_template | ||
54 | - @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/textile_body.txt.erb")) | ||
55 | - end | 54 | + def body_template |
55 | + @@body_template ||= ERB.new(File.read(Rails.root + "app/views/issue_trackers/textile_body.txt.erb")) | ||
56 | + end | ||
56 | 57 | ||
57 | - def url | ||
58 | - acc_url = account.start_with?('http') ? account : "http://#{account}" | ||
59 | - URI.parse("#{acc_url}?project_id=#{project_id}").to_s | ||
60 | - rescue URI::InvalidURIError | 58 | + def url |
59 | + acc_url = account.start_with?('http') ? account : "http://#{account}" | ||
60 | + URI.parse("#{acc_url}?project_id=#{project_id}").to_s | ||
61 | + rescue URI::InvalidURIError | ||
62 | + end | ||
61 | end | 63 | end |
62 | end | 64 | end |
63 | - |
app/models/notification_services/campfire_service.rb
1 | -class NotificationServices::CampfireService < NotificationService | ||
2 | - Label = "campfire" | ||
3 | - Fields = [ | ||
4 | - [:subdomain, { | ||
5 | - :placeholder => "Campfire Subdomain" | ||
6 | - }], | ||
7 | - [:api_token, { | ||
8 | - :placeholder => "API Token" | ||
9 | - }], | ||
10 | - [:room_id, { | ||
11 | - :placeholder => "Room ID", | ||
12 | - :label => "Room ID" | ||
13 | - }], | ||
14 | - ] | 1 | +if defined? Campy |
2 | + class NotificationServices::CampfireService < NotificationService | ||
3 | + Label = "campfire" | ||
4 | + Fields = [ | ||
5 | + [:subdomain, { | ||
6 | + :placeholder => "Campfire Subdomain" | ||
7 | + }], | ||
8 | + [:api_token, { | ||
9 | + :placeholder => "API Token" | ||
10 | + }], | ||
11 | + [:room_id, { | ||
12 | + :placeholder => "Room ID", | ||
13 | + :label => "Room ID" | ||
14 | + }], | ||
15 | + ] | ||
15 | 16 | ||
16 | - def check_params | ||
17 | - if Fields.detect {|f| self[f[0]].blank? } | ||
18 | - errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' | 17 | + def check_params |
18 | + if Fields.detect {|f| self[f[0]].blank? } | ||
19 | + errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' | ||
20 | + end | ||
19 | end | 21 | end |
20 | - end | ||
21 | 22 | ||
22 | - def create_notification(problem) | ||
23 | - # build the campfire client | ||
24 | - campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id) | 23 | + def create_notification(problem) |
24 | + # build the campfire client | ||
25 | + campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id) | ||
25 | 26 | ||
26 | - # post the issue to the campfire room | ||
27 | - campy.speak "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{notification_description problem}" | 27 | + # post the issue to the campfire room |
28 | + campy.speak "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{notification_description problem}" | ||
29 | + end | ||
28 | end | 30 | end |
29 | end | 31 | end |
30 | \ No newline at end of file | 32 | \ No newline at end of file |
app/models/notification_services/hipchat_service.rb
1 | -class NotificationServices::HipchatService < NotificationService | ||
2 | - Label = 'hipchat' | ||
3 | - Fields = [ | ||
4 | - [:api_token, { | ||
5 | - :placeholder => "API Token" | ||
6 | - }], | ||
7 | - [:room_id, { | ||
8 | - :placeholder => "Room ID", | ||
9 | - :label => "Room ID" | ||
10 | - }], | ||
11 | - ] | 1 | +if defined? HipChat |
2 | + class NotificationServices::HipchatService < NotificationService | ||
3 | + Label = 'hipchat' | ||
4 | + Fields = [ | ||
5 | + [:api_token, { | ||
6 | + :placeholder => "API Token" | ||
7 | + }], | ||
8 | + [:room_id, { | ||
9 | + :placeholder => "Room ID", | ||
10 | + :label => "Room ID" | ||
11 | + }], | ||
12 | + ] | ||
12 | 13 | ||
13 | - def check_params | ||
14 | - if Fields.any? { |f, _| self[f].blank? } | ||
15 | - errors.add :base, 'You must specify your Hipchat API token and Room ID' | 14 | + def check_params |
15 | + if Fields.any? { |f, _| self[f].blank? } | ||
16 | + errors.add :base, 'You must specify your Hipchat API token and Room ID' | ||
17 | + end | ||
16 | end | 18 | end |
17 | - end | ||
18 | 19 | ||
19 | - def create_notification(problem) | ||
20 | - url = app_problem_url problem.app, problem | ||
21 | - message = <<-MSG.strip_heredoc | ||
22 | - [#{ERB::Util.html_escape problem.app.name}]#{ERB::Util.html_escape notification_description(problem)}<br> | ||
23 | - <a href="#{url}">#{url}</a> | ||
24 | - MSG | 20 | + def create_notification(problem) |
21 | + url = app_problem_url problem.app, problem | ||
22 | + message = <<-MSG.strip_heredoc | ||
23 | + [#{ERB::Util.html_escape problem.app.name}]#{ERB::Util.html_escape notification_description(problem)}<br> | ||
24 | + <a href="#{url}">#{url}</a> | ||
25 | + MSG | ||
25 | 26 | ||
26 | - client = HipChat::Client.new(api_token) | ||
27 | - client[room_id].send('Errbit', message, :color => 'red') | 27 | + client = HipChat::Client.new(api_token) |
28 | + client[room_id].send('Errbit', message, :color => 'red') | ||
29 | + end | ||
28 | end | 30 | end |
29 | -end | 31 | -end |
32 | +end | ||
30 | \ No newline at end of file | 33 | \ No newline at end of file |
config/initializers/_load_config.rb
@@ -60,6 +60,9 @@ default_config.each do |k,v| | @@ -60,6 +60,9 @@ default_config.each do |k,v| | ||
60 | Errbit::Config.send("#{k}=", v) if Errbit::Config.send(k) === nil | 60 | Errbit::Config.send("#{k}=", v) if Errbit::Config.send(k) === nil |
61 | end | 61 | end |
62 | 62 | ||
63 | +# Disable GitHub oauth if gem is missing | ||
64 | +Errbit::Config.github_authentication = false unless defined?(OmniAuth::Strategies::GitHub) | ||
65 | + | ||
63 | # Set SMTP settings if given. | 66 | # Set SMTP settings if given. |
64 | if smtp = Errbit::Config.smtp_settings | 67 | if smtp = Errbit::Config.smtp_settings |
65 | ActionMailer::Base.delivery_method = :smtp | 68 | ActionMailer::Base.delivery_method = :smtp |
lib/issue_trackers/apis/mingle.rb
1 | +require 'active_resource' | ||
2 | + | ||
1 | module Mingle | 3 | module Mingle |
2 | class Card < ActiveResource::Base | 4 | class Card < ActiveResource::Base |
3 | # site template ~> "https://username:password@mingle.example.com/api/v1/projects/:project_id/" | 5 | # site template ~> "https://username:password@mingle.example.com/api/v1/projects/:project_id/" |