errbit_trac_plugin 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 43a7f52c6cf58ca035b2edd0e21d6b3f2f616359
4
+ data.tar.gz: 367bfe1d2a49fc521b4086ee676366d56699a1ea
5
+ SHA512:
6
+ metadata.gz: f6e77b706037b6a978b7361430dc8f71719cdf5a0f2339d44c61e5edb9fc4fa0acacf702927c40cb539f35d4b3efd71afc51f9d0a8d94c355b37f889e4e90bb5
7
+ data.tar.gz: 7e393a7e1359cddc0d8f84515e6fc08a187196bb09b6c496d964d4be77fa397f4509700e8a62c504f64ace7924e693f7a69f1df0874c19c0b4af2c0f1ba7592d
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in errbit_trac_plugin.gemspec
4
+ gemspec
5
+
6
+ gem 'errbit_plugin', :git => 'https://github.com/errbit/errbit_plugin.git'
7
+ gem 'rspec'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'coveralls', :require => false
11
+ gem 'trac4r', '~> 1.2.4'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Stephen Crosby
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,22 @@
1
+ # ErrbitTracPlugin
2
+
3
+ Trac integration for errbit. This plugin adds trac as an optional issue
4
+ tracker for errbit apps.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'errbit_trac_plugin'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install errbit_trac_plugin
19
+
20
+ ## Usage
21
+
22
+ TODO: Write usage instructions here
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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_trac_plugin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'errbit_trac_plugin'
8
+ spec.version = ErrbitTracPlugin::VERSION
9
+ spec.authors = ['Stephen Crosby']
10
+ spec.email = ['stevecrozz@gmail.com']
11
+ spec.description = %q{Add Trac issue tracker plugin to errbit}
12
+ spec.summary = %q{Add Trac issue tracker plugin to errbit}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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 'trac4r', '~> 1.2.4'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'jeweler', '~> 2.0.1'
27
+ end
@@ -0,0 +1,32 @@
1
+ require "errbit_trac_plugin/version"
2
+ require 'errbit_trac_plugin/error'
3
+ require 'errbit_trac_plugin/issue_tracker'
4
+ require 'errbit_trac_plugin/rails'
5
+
6
+ module ErrbitTracPlugin
7
+ def self.root
8
+ File.expand_path '../..', __FILE__
9
+ end
10
+
11
+ def self.pretty_hash(hash, nesting = 0)
12
+ tab_size = 2
13
+ nesting += 1
14
+
15
+ pretty = "{"
16
+ sorted_keys = hash.keys.sort
17
+ sorted_keys.each do |key|
18
+ val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect
19
+ pretty += "\n#{' '*nesting*tab_size}"
20
+ pretty += "#{key.inspect} => #{val}"
21
+ pretty += "," unless key == sorted_keys.last
22
+
23
+ end
24
+ nesting -= 1
25
+ pretty += "\n#{' '*nesting*tab_size}}"
26
+ end
27
+ end
28
+
29
+ ErrbitPlugin::Register.add_issue_tracker(
30
+ 'ErrbitTracPlugin::IssueTracker',
31
+ ErrbitTracPlugin::IssueTracker
32
+ )
@@ -0,0 +1,3 @@
1
+ module ErrbitTracPlugin
2
+ class AuthenticationError < Exception; end
3
+ end
@@ -0,0 +1,102 @@
1
+ require 'trac4r'
2
+
3
+ module ErrbitTracPlugin
4
+ class IssueTracker < ErrbitPlugin::IssueTracker
5
+
6
+ LABEL = 'trac'
7
+
8
+ FIELDS = [
9
+ [:base_url, {
10
+ :label => 'Trac Project URL (without /xmlrpc)',
11
+ :placeholder => 'http://www.example.com/trac/project'
12
+ }],
13
+ [:username, {
14
+ :label => 'Trac User',
15
+ :placeholder => 'johndoe'
16
+ }],
17
+ [:password, {
18
+ :label => 'Trac Password',
19
+ :placeholder => 'p@assW0rd'
20
+ }],
21
+ [:issue_kind, {
22
+ :label => 'Type of issue to create',
23
+ :placeholder => 'defect'
24
+ }],
25
+ ]
26
+
27
+ NOTE = 'This issue tracker integrates with ' \
28
+ '<a href="http://trac.edgewall.org/">trac</a> through the ' \
29
+ '<a href="http://trac-hacks.org/wiki/XmlRpcPlugin">XmlRpcPlugin</a>. ' \
30
+ 'Fill in the form below with a URL to your trac project, and account ' \
31
+ 'credentials for a user with the XML_RPC permision.'
32
+
33
+ def label
34
+ LABEL
35
+ end
36
+
37
+ def fields
38
+ FIELDS
39
+ end
40
+
41
+ def url
42
+ params["base_url"]
43
+ end
44
+
45
+ def configured?
46
+ true
47
+ end
48
+
49
+ def note
50
+ NOTE
51
+ end
52
+
53
+ def check_params
54
+ if fields.detect { |f| self[f[0]].blank? && !f[1][:optional] }
55
+ errors.add :base, 'You must specify all values!'
56
+ end
57
+ end
58
+
59
+ def comments_allowed?
60
+ false
61
+ end
62
+
63
+ # @param problem Problem
64
+ def create_issue(problem, reported_by = nil)
65
+ if reported_by
66
+ reporter = reported_by.name
67
+ else
68
+ reporter = "errbit"
69
+ end
70
+
71
+ client = Trac.new(params['base_url'], params['username'], params['password'])
72
+
73
+ ticket_id = client.tickets.create(issue_title(problem),
74
+ body_template.result(binding), {
75
+ :type => params['issue_kind'],
76
+ :reporter => reporter,
77
+ :keywords => "errbit",
78
+ })
79
+
80
+ problem.update_attributes(
81
+ :issue_link => link_for_issue(ticket_id),
82
+ :issue_type => label
83
+ )
84
+ end
85
+
86
+ def link_for_issue(ticket_id)
87
+ # if it ends in /, remove the /
88
+ if matches = /(.*)\/$/.match(params['base_url'])
89
+ url = matches[1]
90
+ else
91
+ url = params['base_url']
92
+ end
93
+
94
+ "%s/ticket/%s" % [url, ticket_id]
95
+ end
96
+
97
+ def body_template
98
+ @@body_template ||= ERB.new(File.read(
99
+ File.join(ErrbitTracPlugin.root, 'views', 'trac_body.txt.erb')))
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,6 @@
1
+ if defined?(Rails)
2
+ module ErrbitTracPlugin
3
+ class RailsEngine < Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module ErrbitTracPlugin
2
+ VERSION = "0.0.1"
3
+ end
Binary file
@@ -0,0 +1,48 @@
1
+ <% notice = problem.notices.first %>
2
+ <% if notice %>
3
+ = <%= notice.message %> =
4
+ <% end %>
5
+
6
+ See this exception on Errbit
7
+ <%= Rails.application.routes_url_helpers
8
+ .app_problem_url(app, problem, ActionMailer::Base.default_url_options)
9
+ %>
10
+
11
+ == Summary ==
12
+ <% if notice && notice.request['url'].present? %>
13
+ URL:: <%= notice.request['url'] %>
14
+ <% end %>
15
+ Where:: <%= problem.where %>
16
+ Occured:: <%= problem.created_at.to_s(:micro) %>
17
+ Similar:: <%= (problem.notices_count - 1).to_s %>
18
+
19
+ <% if notice && notice.env_vars.present? %>
20
+ == Environment ==
21
+ {{{
22
+ <%= ErrbitTracPlugin.pretty_hash(notice.env_vars) %>
23
+ }}}
24
+ <% end %>
25
+
26
+ <% if notice && notice.params.present? %>
27
+ == Params ==
28
+ {{{
29
+ <%= ErrbitTracPlugin.pretty_hash(notice.params) %>
30
+ }}}
31
+ <% end %>
32
+
33
+ <% if notice && notice.session.present? %>
34
+ == Session ==
35
+ {{{
36
+ <%= ErrbitTracPlugin.pretty_hash(notice.session) %>
37
+ }}}
38
+ <% end %>
39
+
40
+ <% if notice && notice.backtrace_lines.present? %>
41
+ == Backtrace ==
42
+ {{{
43
+ <% notice.backtrace_lines[0,10].each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>**
44
+ <% end %>
45
+ }}}
46
+ <% end %>
47
+
48
+
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: errbit_trac_plugin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Crosby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-08 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: trac4r
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.1
83
+ description: Add Trac issue tracker plugin to errbit
84
+ email:
85
+ - stevecrozz@gmail.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_trac_plugin.gemspec
96
+ - lib/errbit_trac_plugin.rb
97
+ - lib/errbit_trac_plugin/error.rb
98
+ - lib/errbit_trac_plugin/issue_tracker.rb
99
+ - lib/errbit_trac_plugin/rails.rb
100
+ - lib/errbit_trac_plugin/version.rb
101
+ - vendor/assets/images/trac_create.png
102
+ - vendor/assets/images/trac_goto.png
103
+ - vendor/assets/images/trac_inactive.png
104
+ - views/trac_body.txt.erb
105
+ homepage: ''
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.0
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Add Trac issue tracker plugin to errbit
129
+ test_files: []