redmine-reporting 0.1.0 → 0.1.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 +4 -4
- data/README.md +17 -2
- data/lib/redmine/reporting/configuration.rb +13 -0
- data/lib/redmine/reporting/report.rb +11 -9
- data/lib/redmine/reporting/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac501589d0737e31a91a96268028b61dbc16e021
|
4
|
+
data.tar.gz: a14f692beba30c48642f1dbf5a81142cfaa2ed5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17643533787ea69e2f4fb34752b312eef4ad187c3f9af8d2d0826274987bcd852c3cba13927e1dfc333b74dd8ca20ac13e33828853dd52381389ec14b82da260
|
7
|
+
data.tar.gz: d970eba7db83d58045d09840b81f2ef498ce901fcbadead4b8e82406165456b75fd84bb6ddd0a483f58efdbb02378467bfa05c5d9d670cd912ccff9776eafbd8
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# redmine-reporting
|
2
2
|
|
3
|
-
|
3
|
+
A simple gem to use with rails or any ruby project to report exceptions or other messages as issues to the Redmine project management system (http://www.redmine.org).
|
4
|
+
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -16,9 +17,23 @@ Or install it yourself as:
|
|
16
17
|
|
17
18
|
$ gem install redmine-reporting
|
18
19
|
|
20
|
+
Add a initializer ```config/initializers/redmine_reporting.rb``` with the following content.
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Redmine::Reporting.configure do |config|
|
24
|
+
config.base_url = 'https://redmine.example.net/'
|
25
|
+
config.api_key = '012345678901234567890123456789012'
|
26
|
+
config.project = 'your-project-identifier'
|
27
|
+
config.tracker = 1
|
28
|
+
config.category = 1
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
|
19
33
|
## Usage
|
20
34
|
|
21
|
-
|
35
|
+
If you are in a Rails project, the gem will automatically hook itself into the rack middleware and report any uncatched exception.
|
36
|
+
|
22
37
|
|
23
38
|
## Contributing
|
24
39
|
|
@@ -6,6 +6,19 @@ module Redmine
|
|
6
6
|
attr_accessor :project
|
7
7
|
attr_accessor :tracker
|
8
8
|
attr_accessor :category
|
9
|
+
attr_reader :http_options
|
10
|
+
|
11
|
+
def proxy(hostname, port)
|
12
|
+
@http_options ||= {}
|
13
|
+
@http_options[:http_proxyaddr] = hostname
|
14
|
+
@http_options[:http_proxyport] = port
|
15
|
+
end
|
16
|
+
|
17
|
+
def proxy_auth(username, password)
|
18
|
+
@http_options ||= {}
|
19
|
+
@http_options[:http_proxyuser] = username
|
20
|
+
@http_options[:http_proxypass] = password
|
21
|
+
end
|
9
22
|
end
|
10
23
|
end
|
11
24
|
end
|
@@ -26,20 +26,20 @@ module Redmine
|
|
26
26
|
def commit
|
27
27
|
config = Redmine::Reporting.configuration
|
28
28
|
|
29
|
-
options = {
|
29
|
+
options = (config.http_options || {}).merge({
|
30
30
|
headers: {
|
31
31
|
'Content-type' => 'application/json',
|
32
32
|
'X-Redmine-API-Key' => config.api_key
|
33
33
|
}
|
34
|
-
}
|
34
|
+
})
|
35
35
|
|
36
36
|
if issue_id.nil?
|
37
37
|
resp = HTTParty.post("#{config.base_url}/issues.json", options.merge({
|
38
38
|
body: {
|
39
39
|
issue: {
|
40
|
-
subject: @subject,
|
40
|
+
subject: @subject.strip,
|
41
41
|
project_id: config.project,
|
42
|
-
description: @description,
|
42
|
+
description: @description.strip,
|
43
43
|
tracker_id: config.tracker,
|
44
44
|
category_id: config.category
|
45
45
|
}
|
@@ -49,7 +49,7 @@ module Redmine
|
|
49
49
|
issue_id = resp['issue']['id'] rescue nil
|
50
50
|
|
51
51
|
unless issue_id.nil?
|
52
|
-
File.open(issue_id_file, File::CREAT|File::TRUNC|File::RDWR, 0600) {|f| f.write(issue_id.to_s)
|
52
|
+
File.open(issue_id_file, File::CREAT|File::TRUNC|File::RDWR, 0600) {|f| f.write(issue_id.to_s)}
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -60,13 +60,14 @@ module Redmine
|
|
60
60
|
resp = HTTParty.put("#{config.base_url}/issues/#{issue_id}.json", options.merge({
|
61
61
|
body: {
|
62
62
|
issue: {
|
63
|
-
notes: "h1. #{reference_id}\n\n#{@notes}"
|
63
|
+
notes: "h1. #{reference_id}\n\n#{@notes}".strip
|
64
64
|
}
|
65
65
|
}.to_json
|
66
66
|
}))
|
67
67
|
|
68
68
|
reference_id
|
69
|
-
rescue
|
69
|
+
rescue => e
|
70
|
+
# TODO ignore
|
70
71
|
nil
|
71
72
|
end
|
72
73
|
|
@@ -76,6 +77,7 @@ module Redmine
|
|
76
77
|
@current_var << "#{type}. #{title}\n\n"
|
77
78
|
data_to_syntax(content) unless content.nil?
|
78
79
|
data_to_syntax(&block) if block_given?
|
80
|
+
@current_var << "\n\n"
|
79
81
|
nil
|
80
82
|
end
|
81
83
|
|
@@ -88,7 +90,7 @@ module Redmine
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def output(content)
|
91
|
-
@current_var << content
|
93
|
+
@current_var << "#{content}\n"
|
92
94
|
nil
|
93
95
|
end
|
94
96
|
|
@@ -105,7 +107,7 @@ module Redmine
|
|
105
107
|
def issue_hash
|
106
108
|
config = Redmine::Reporting.configuration
|
107
109
|
|
108
|
-
Digest::SHA1.hexdigest([config.base_url, config.project, @subject, @description].join('//'))
|
110
|
+
Digest::SHA1.hexdigest([config.base_url, config.project, @subject.strip, @description.strip].join('//'))
|
109
111
|
end
|
110
112
|
|
111
113
|
def issue_id_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine-reporting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Schwab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|