mantis_bug_reporter 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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +1 -0
- data/lib/mantis_bug_reporter.rb +169 -0
- data/lib/mantis_bug_reporter/version.rb +3 -0
- data/mantis_bug_reporter.gemspec +24 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YmZiZDFhNjUyODgyODdkMGFlNmJhMzYyNTExZTJmNTZiNGZlYmU0Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZGQ5ODBkM2ZlOTU3NzJjOTFhOGNjNmMyOWQ5Mzk4MjIyYmYyZjY5OA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YmEyNWUxNTI5YmJmODM5MjBiNWM1MTI2YmM0MGM2MDdjMzJmNTdhZWNkOTVi
|
10
|
+
ZDM0OWQ2ZDJjODI5Y2FjMGIzZjEwNzBjZGQyYTIzMjA1Yjc3N2Q1YjJjOGU0
|
11
|
+
NDM0ZDE3Y2VkODA0NmVmYWIzNmFiZjNhYzRhOTNiOWExZWI5YjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YWYwMzA4YzA4MDIyMmMyYTAyZDA1N2I5NjdmYmE3MmZkNTc2MjE5MmY0ZjVh
|
14
|
+
ZWVmMDY0MTJlMWRmMzM5NzRiYTVkMzcxYmQ1OTIwNDYwN2FjMDY0MmRlMzhj
|
15
|
+
N2Q1ZGUyMzg4ZGVjN2ZmYTQ5OTY3OGZhODQxNmJkZmVmYTFhMzU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 mangantj
|
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,51 @@
|
|
1
|
+
# MantisBugReporter
|
2
|
+
|
3
|
+
NOTE: Renamed the gem from Mantis Auto Bug to Mantis Bug Reporter
|
4
|
+
|
5
|
+
TODO: Fix updating an issue
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'mantis_bug_reporter'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mantis_auto_bug
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Instantiate an instace of Mantis Bug Reporter :
|
24
|
+
|
25
|
+
MantisBugReporter::Client(username, password, wsdl, project_id, project_name)
|
26
|
+
|
27
|
+
File Bug method
|
28
|
+
|
29
|
+
client.file_bug(exception_object, env_object)
|
30
|
+
|
31
|
+
First checks if an issue already exists for a project. If so, it grabs the issue and then tries to update a
|
32
|
+
custom field I have created called Reports by incrementing the count to indicate how many times the bug has
|
33
|
+
been reporter.
|
34
|
+
|
35
|
+
Available methods to hook into:
|
36
|
+
|
37
|
+
client.mc_issue_exists?(issue_id)
|
38
|
+
client.mc_issue_get(issue_id)
|
39
|
+
client.mc_issue_note_add(issue_id, note)
|
40
|
+
client.mc_issue_add(summary, additional_information, category, description)
|
41
|
+
client.mc_issue_update(issue) #Currently not working :(
|
42
|
+
client.mc_issue_get_id_from_summary(summary)
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require "mantis_bug_reporter/version"
|
2
|
+
require "savon"
|
3
|
+
|
4
|
+
module MantisBugReporter
|
5
|
+
class Client
|
6
|
+
def initialize(username, password, wsdl, project_id, project_name)
|
7
|
+
Savon.configure do |config|
|
8
|
+
config.log = false
|
9
|
+
end
|
10
|
+
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
@wsdl = wsdl
|
14
|
+
@project_id = project_id
|
15
|
+
@project_name = project_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def mc_issue_exists?(issue_id)
|
19
|
+
client = Savon.client(@wsdl)
|
20
|
+
response = client.request(:mc_issue_exists) do
|
21
|
+
soap.body = {
|
22
|
+
username: username,
|
23
|
+
password: password,
|
24
|
+
issue_id: issue_id
|
25
|
+
}
|
26
|
+
end
|
27
|
+
if response.success?
|
28
|
+
return response.body[:mc_issue_exists_response][:return]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def mc_issue_note_add(issue_id, note)
|
33
|
+
client = Savon.client(@wsdl)
|
34
|
+
response = client.request(:mc_issue_note_add) do
|
35
|
+
soap.body = {
|
36
|
+
:username => username,
|
37
|
+
:password => password,
|
38
|
+
:issue_id => issue_id,
|
39
|
+
:note => { text: note }
|
40
|
+
}
|
41
|
+
end
|
42
|
+
if response.success?
|
43
|
+
return note_id = response.body[:mc_issue_note_add_response][:return]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Creates an issue in Mantis
|
48
|
+
def mc_issue_add(summary, additional_information, category, description)
|
49
|
+
client = Savon.client(@wsdl)
|
50
|
+
response = client.request(:mc_issue_add) do
|
51
|
+
soap.body = {
|
52
|
+
:username => username,
|
53
|
+
:password => password,
|
54
|
+
:issue => {
|
55
|
+
:summary => removeUniqueIdentifier(summary),
|
56
|
+
:project => { :id => @project_id, :name => project_name }, # For some reason Mantis wants the id and the name
|
57
|
+
:category => category,
|
58
|
+
:description => description + "<br /> <br />" + additional_information
|
59
|
+
}
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def mc_issue_get(issue_id)
|
65
|
+
client = Savon.client(@wsdl)
|
66
|
+
response = client.request(:mc_issue_get) do
|
67
|
+
soap.body = {
|
68
|
+
:username => username,
|
69
|
+
:password => password,
|
70
|
+
:issue_id => issue_id
|
71
|
+
}
|
72
|
+
end
|
73
|
+
if response.success?
|
74
|
+
return response.body[:mc_issue_get_response][:return]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def mc_issue_update(issue)
|
79
|
+
client = Savon.client(@wsdl)
|
80
|
+
response = client.request(:mc_issue_update) do
|
81
|
+
soap.body = {
|
82
|
+
:username => username,
|
83
|
+
:password => password,
|
84
|
+
:issue_id => issue[:id],
|
85
|
+
:issue => issue
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Checks if an issue already exists in Mantis by the summary
|
91
|
+
def mc_issue_get_id_from_summary(summary)
|
92
|
+
client = Savon.client(@wsdl)
|
93
|
+
response = client.request(:mc_issue_get_id_from_summary) do
|
94
|
+
soap.body = {
|
95
|
+
:username => username,
|
96
|
+
:password => password,
|
97
|
+
:summary => { text: removeUniqueIdentifier(summary[0..127]) } #Summary character max is 128
|
98
|
+
}
|
99
|
+
end
|
100
|
+
if response.success?
|
101
|
+
return response.body[:mc_issue_get_id_from_summary_response][:return]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def file_bug(exception, env)
|
106
|
+
summary = env["action_dispatch.request.path_parameters"][:controller] + "_controller - " + exception.to_s
|
107
|
+
category = "2. Development (Implementation) - Bug"
|
108
|
+
description = "The controller " + env["action_dispatch.request.path_parameters"][:controller] + " experienced an exception of " + exception.to_s
|
109
|
+
additional_information = exception.backtrace.to_s.delete("[" "]").gsub(",","<br />")
|
110
|
+
|
111
|
+
issue_id = self.mc_issue_get_id_from_summary(removeUniqueIdentifier(summary))
|
112
|
+
if issue_id.to_i == 0
|
113
|
+
self.mc_issue_add(summary, additional_information, category, description)
|
114
|
+
else
|
115
|
+
issue = self.mc_issue_get(issue_id.to_i)
|
116
|
+
begin
|
117
|
+
self.mc_issue_update(increment_mantis_reports_field(issue))
|
118
|
+
rescue Savon::Error => error
|
119
|
+
logger.debug error.to_s
|
120
|
+
puts error.to_s
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# We need these because Savon uses instance_eval for the request method
|
126
|
+
# which means that we do not have access to our MantisConnect::Client's
|
127
|
+
# instance variables within that block.
|
128
|
+
private
|
129
|
+
def username
|
130
|
+
@username
|
131
|
+
end
|
132
|
+
|
133
|
+
def password
|
134
|
+
@password
|
135
|
+
end
|
136
|
+
|
137
|
+
def project_id
|
138
|
+
@project_id
|
139
|
+
end
|
140
|
+
|
141
|
+
def project_name
|
142
|
+
@project_name
|
143
|
+
end
|
144
|
+
|
145
|
+
# Removes unique identifer if it exists
|
146
|
+
# Example <ReportViewsController:0x0000000865a240> to <ReportViewsController>
|
147
|
+
def removeUniqueIdentifier(exception)
|
148
|
+
if exception.index(':0x') != nil
|
149
|
+
return exception[0..(exception.index(':0x')-1)] + exception[(exception.index(':0x')+17)..-1]
|
150
|
+
else
|
151
|
+
return exception
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def increment_mantis_reports_field(issue)
|
156
|
+
issue[:custom_fields][:item].each do |item|
|
157
|
+
if item[:field][:name] == "Reports"
|
158
|
+
binding.pry
|
159
|
+
if item[:value].class == Hash
|
160
|
+
item.merge!(:value => "1")
|
161
|
+
else
|
162
|
+
item[:value] = (item[:value].to_i + 1).to_s
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
return issue
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mantis_bug_reporter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mantis_bug_reporter"
|
8
|
+
spec.version = MantisBugReporter::VERSION
|
9
|
+
spec.authors = ["mangantj"]
|
10
|
+
spec.email = ["mangantj@gmail.com"]
|
11
|
+
spec.description = %q{Ties into Mantis api to create issues, add notes, and update issues.}
|
12
|
+
spec.summary = %q{Ties into Mantis api to create issues, add notes, and update issues.}
|
13
|
+
spec.homepage = "https://github.com/mangantj/mantis_bug_reporter"
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_runtime_dependency "savon", "~> 1.2.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mantis_bug_reporter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mangantj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: savon
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.0
|
55
|
+
description: Ties into Mantis api to create issues, add notes, and update issues.
|
56
|
+
email:
|
57
|
+
- mangantj@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/mantis_bug_reporter.rb
|
68
|
+
- lib/mantis_bug_reporter/version.rb
|
69
|
+
- mantis_bug_reporter.gemspec
|
70
|
+
homepage: https://github.com/mangantj/mantis_bug_reporter
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.0.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Ties into Mantis api to create issues, add notes, and update issues.
|
94
|
+
test_files: []
|
95
|
+
has_rdoc:
|