Class: ErrbitBitbucketPlugin::IssueTracker
- Inherits:
-
ErrbitPlugin::IssueTracker
- Object
- ErrbitPlugin::IssueTracker
- ErrbitBitbucketPlugin::IssueTracker
- Defined in:
- lib/errbit_bitbucket_plugin/issue_tracker.rb
Constant Summary collapse
- LABEL =
'bitbucket'- NOTE =
'Please configure your github repository in the <strong>BITBUCKET REPO</strong> field above. Please enter your username and password.'- FIELDS =
{ :username => { :placeholder => "Your username on bitbucket" }, :password => { :placeholder => "Your password on bitbucket" } }
Class Method Summary collapse
Instance Method Summary collapse
- #bitbucket_client ⇒ Object
- #bitbucket_url(resource_uri) ⇒ Object
- #check_params ⇒ Object
- #comments_allowed? ⇒ Boolean
- #configured? ⇒ Boolean
- #create_issue(problem, reported_by = nil) ⇒ Object
- #errors ⇒ Object
- #project_id ⇒ Object
- #url ⇒ Object
Class Method Details
.body_template ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 31 def self.body_template @body_template ||= ERB.new(File.read( File.join( ErrbitBitbucketPlugin.root, 'views', 'bitbucket_issues_body.txt.erb' ) )) end |
.fields ⇒ Object
27 28 29 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 27 def self.fields FIELDS end |
.label ⇒ Object
19 20 21 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 19 def self.label LABEL end |
.note ⇒ Object
23 24 25 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 23 def self.note NOTE end |
Instance Method Details
#bitbucket_client ⇒ Object
67 68 69 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 67 def bitbucket_client BitBucket.new :login => params['username'], :password => params['password'] end |
#bitbucket_url(resource_uri) ⇒ Object
95 96 97 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 95 def bitbucket_url(resource_uri) "https://bitbucket.org/" + resource_uri.split('/')[3,5].join('/').gsub(/issues/,'issue') end |
#check_params ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 55 def check_params if @params['username'] {} else { :username => 'Username must be present' } end end |
#comments_allowed? ⇒ Boolean
63 64 65 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 63 def comments_allowed? false end |
#configured? ⇒ Boolean
39 40 41 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 39 def configured? project_id end |
#create_issue(problem, reported_by = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 71 def create_issue(problem, reported_by = nil) begin issue_params = { :title => "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}", :content => self.class.body_template.result(binding).unpack('C*').pack('U*'), :kind => 'bug', :priority => 'major' } issue = bitbucket_client.issues.create( params['username'], project_id, issue_params ) problem.update_attributes( :issue_link => bitbucket_url(issue.body.resource_uri), :issue_type => 'bug' ) rescue BitBucket::Error:: raise ErrbitBitbucketPlugin::AuthenticationError, "Could not authenticate with Bitbucket. Please check your username and password." end end |
#errors ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 47 def errors errors = [] if self.class.fields.detect {|f| params[f[0]].blank?} errors << [:base, 'You must specify your Bitbucket username and password.'] end errors end |
#project_id ⇒ Object
43 44 45 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 43 def project_id app.bitbucket_repo end |
#url ⇒ Object
99 100 101 |
# File 'lib/errbit_bitbucket_plugin/issue_tracker.rb', line 99 def url "https://www.atlassian.com/software" end |