errbit_bitbucket_plugin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2187dea2792a4812e4fb6a53d404f56963ccb8d7
4
+ data.tar.gz: f6b80c592053bfb68c75c47573cd9dc5baff723a
5
+ SHA512:
6
+ metadata.gz: 58751b3e03f965ce756b92451cd2c1e0c67569e35eb8e93eef26cbd2291543be573b74bbdacdab8a411942dd373514ea57c1ad9e6ddd01b692360c46712e006f
7
+ data.tar.gz: 454aba7a11a6325afceb816f6b2252bf13a4bf231bb07b8dd34d9a5c2b36ce0ed50b2c7c53b4d5ceb0f9df1f54f29fc652054c1cd22d09be536b52ac83c36c75
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in errbit_bitbucket_plugin.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthew McFarling
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ErrbitBitbucketPlugin
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'errbit_bitbucket_plugin'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install errbit_bitbucket_plugin
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/errbit_bitbucket_plugin/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'errbit_bitbucket_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "errbit_bitbucket_plugin"
8
+ spec.version = ErrbitBitbucketPlugin::VERSION
9
+ spec.authors = ["Matthew McFarling"]
10
+ spec.email = ["matt@codemancode.com"]
11
+ spec.summary = %q{BitBucket integration for Errbit.}
12
+ spec.description = %q{BitBucket integration for Errbit.}
13
+ spec.homepage = "https://github.com/codemancode/errbit_bitbucket_plugin"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "errbit_plugin"
22
+ spec.add_dependency "bitbucket_rest_api"
23
+ spec.add_dependency "faraday", "~> 0.8.1"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,12 @@
1
+ require 'errbit_bitbucket_plugin/version'
2
+ require 'errbit_bitbucket_plugin/error'
3
+ require 'errbit_bitbucket_plugin/issue_tracker'
4
+ require 'errbit_bitbucket_plugin/rails'
5
+
6
+ module ErrbitBitbucketPlugin
7
+ def self.root
8
+ File.expand_path '../..', __FILE__
9
+ end
10
+ end
11
+
12
+ ErrbitPlugin::Registry.add_issue_tracker(ErrbitBitbucketPlugin::IssueTracker)
@@ -0,0 +1,3 @@
1
+ module ErrbitBitbucketPlugin
2
+ class AuthenticationError < Exception; end
3
+ end
@@ -0,0 +1,103 @@
1
+ require 'bitbucket_rest_api'
2
+
3
+ module ErrbitBitbucketPlugin
4
+ class IssueTracker < ErrbitPlugin::IssueTracker
5
+
6
+ LABEL = 'bitbucket'
7
+
8
+ NOTE = 'Please configure your github repository in the <strong>BITBUCKET REPO</strong> field above. Please enter your username and password.'
9
+
10
+ FIELDS = {
11
+ :username => {
12
+ :placeholder => "Your username on bitbucket"
13
+ },
14
+ :password => {
15
+ :placeholder => "Your password on bitbucket"
16
+ }
17
+ }
18
+
19
+ def self.label
20
+ LABEL
21
+ end
22
+
23
+ def self.note
24
+ NOTE
25
+ end
26
+
27
+ def self.fields
28
+ FIELDS
29
+ end
30
+
31
+ def self.body_template
32
+ @body_template ||= ERB.new(File.read(
33
+ File.join(
34
+ ErrbitBitbucketPlugin.root, 'views', 'bitbucket_issues_body.txt.erb'
35
+ )
36
+ ))
37
+ end
38
+
39
+ def configured?
40
+ project_id
41
+ end
42
+
43
+ def project_id
44
+ app.bitbucket_repo
45
+ end
46
+
47
+ def errors
48
+ errors = []
49
+ if self.class.fields.detect {|f| params[f[0]].blank?}
50
+ errors << [:base, 'You must specify your Bitbucket username and password.']
51
+ end
52
+ errors
53
+ end
54
+
55
+ def check_params
56
+ if @params['username']
57
+ {}
58
+ else
59
+ { :username => 'Username must be present' }
60
+ end
61
+ end
62
+
63
+ def comments_allowed?
64
+ false
65
+ end
66
+
67
+ def bitbucket_client
68
+ BitBucket.new :login => params['username'], :password => params['password']
69
+ end
70
+
71
+ def create_issue(problem, reported_by = nil)
72
+ begin
73
+ issue_params = {
74
+ :title => "[#{ problem.environment }][#{ problem.where }] #{problem.message.to_s.truncate(100)}",
75
+ :content => self.class.body_template.result(binding).unpack('C*').pack('U*'),
76
+ :kind => 'bug',
77
+ :priority => 'major'
78
+ }
79
+ issue = bitbucket_client.issues.create(
80
+ params['username'],
81
+ project_id,
82
+ issue_params
83
+ )
84
+
85
+ problem.update_attributes(
86
+ :issue_link => bitbucket_url(issue.body.resource_uri),
87
+ :issue_type => 'bug'
88
+ )
89
+
90
+ rescue BitBucket::Error::Unauthorized
91
+ raise ErrbitBitbucketPlugin::AuthenticationError, "Could not authenticate with Bitbucket. Please check your username and password."
92
+ end
93
+ end
94
+
95
+ def bitbucket_url(resource_uri)
96
+ "https://bitbucket.org/" + resource_uri.split('/')[3,5].join('/').gsub(/issues/,'issue')
97
+ end
98
+
99
+ def url
100
+ "https://www.atlassian.com/software"
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,8 @@
1
+ if defined?(Rails)
2
+ module ErrbitBitbucketPlugin
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module ErrbitBitbucketPlugin
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,44 @@
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 %>
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errbit_bitbucket_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew McFarling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: errbit_plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bitbucket_rest_api
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: BitBucket integration for Errbit.
84
+ email:
85
+ - matt@codemancode.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - errbit_bitbucket_plugin.gemspec
96
+ - lib/errbit_bitbucket_plugin.rb
97
+ - lib/errbit_bitbucket_plugin/error.rb
98
+ - lib/errbit_bitbucket_plugin/issue_tracker.rb
99
+ - lib/errbit_bitbucket_plugin/rails.rb
100
+ - lib/errbit_bitbucket_plugin/version.rb
101
+ - vendor/assets/images/bitbucket_create.png
102
+ - vendor/assets/images/bitbucket_inactive.png
103
+ - views/bitbucket_issues_body.txt.erb
104
+ homepage: https://github.com/codemancode/errbit_bitbucket_plugin
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.2.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: BitBucket integration for Errbit.
128
+ test_files: []