Class: ErrbitGithubPlugin::IssueTracker
- Inherits:
-
ErrbitPlugin::IssueTracker
- Object
- ErrbitPlugin::IssueTracker
- ErrbitGithubPlugin::IssueTracker
- Defined in:
- lib/errbit_github_plugin/issue_tracker.rb
Constant Summary collapse
- LABEL =
'github'- NOTE =
'Please configure your github repository in the <strong>GITHUB ' << 'REPO</strong> field above.<br/> Instead of providing your ' << 'username & password, you can link your Github account to your ' << 'user profile, and allow Errbit to create issues using your ' << 'OAuth token.'
- FIELDS =
{ :username => { :placeholder => "Your username on GitHub" }, :password => { :placeholder => "Password for your account" } }
Instance Attribute Summary collapse
-
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #comments_allowed? ⇒ Boolean
- #configured? ⇒ Boolean
- #create_issue(problem, reported_by = nil) ⇒ Object
- #errors ⇒ Object
- #github_client ⇒ Object
- #project_id ⇒ Object
Instance Attribute Details
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
43 44 45 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 43 def oauth_token @oauth_token end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
44 45 46 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 44 def url @url end |
Class Method Details
.body_template ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 35 def self.body_template @body_template ||= ERB.new(File.read( File.join( ErrbitGithubPlugin.root, 'views', 'github_issues_body.txt.erb' ) )) end |
.fields ⇒ Object
31 32 33 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 31 def self.fields FIELDS end |
.label ⇒ Object
23 24 25 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 23 def self.label LABEL end |
.note ⇒ Object
27 28 29 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 27 def self.note NOTE end |
Instance Method Details
#comments_allowed? ⇒ Boolean
50 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 50 def comments_allowed?; false; end |
#configured? ⇒ Boolean
46 47 48 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 46 def configured? project_id.present? end |
#create_issue(problem, reported_by = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 75 def create_issue(problem, reported_by = nil) begin issue = github_client.create_issue( project_id, "[#{ problem.environment }][#{ problem.where }] #{problem..to_s.truncate(100)}", self.class.body_template.result(binding).unpack('C*').pack('U*') ) @url = issue.html_url problem.update_attributes( :issue_link => issue.html_url, :issue_type => self.class.label ) rescue Octokit::Unauthorized raise ErrbitGithubPlugin::AuthenticationError, "Could not authenticate with GitHub. Please check your username and password." end end |
#errors ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 56 def errors errors = [] if self.class.fields.detect {|f| params[f[0]].blank? } errors << [:base, 'You must specify your GitHub username and password'] end errors end |
#github_client ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 64 def github_client # Login using OAuth token, if given. if oauth_token Octokit::Client.new( :login => params['username'], :oauth_token => oauth_token) else Octokit::Client.new( :login => params['username'], :password => params['password']) end end |
#project_id ⇒ Object
52 53 54 |
# File 'lib/errbit_github_plugin/issue_tracker.rb', line 52 def project_id app.github_repo end |