redmine-reporting 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f59676859d1dd31152d7b49246ce7b0d86cae104
4
- data.tar.gz: 802fff1d7124b72fcd2486902204807f803bc6bc
3
+ metadata.gz: c3b87630b0f4b777429f6c3ff4de4586eee52909
4
+ data.tar.gz: 7a86c92b6a44c5d88e2bdfb43d2ebdd2d389e360
5
5
  SHA512:
6
- metadata.gz: a1af6b987a35f7cc93a03cdcbce7677cc6b4ff0b188116d04bb3afcd64e58d6a9b727b6b47b377bc89d739fd3aac95683cb5421c245f7cca8c5e122960d03042
7
- data.tar.gz: 91e782b6b0f44629ad8e4f63661aef46a72678c522d9de2203c43f185035936774912e4dc928d4bad0919223162215c387e47b13eabf9d79d8e8d9a8d05cc48b
6
+ metadata.gz: 258104f8eab4e65d97e8df80fc6cf278d17baca7fcbf1afee9d75f6c5f34077f353764e2d6d791b4d61dcec09804ebba61e3b41e4ec3a401c78cee5dd9309c24
7
+ data.tar.gz: 7b12cc3281fc0698042d343962af12f21e8ae0f6d441152009357f77725173e6b469544e2b8d465ca4fdb44dd575c584d10009d217d986ea0e475892aedd2c2d
@@ -30,8 +30,8 @@ module Redmine
30
30
  http_options: self.http_options
31
31
  }
32
32
  end
33
-
34
33
  alias :to_h :to_hash
34
+
35
35
  end
36
36
  end
37
37
  end
@@ -30,12 +30,12 @@ module Redmine
30
30
 
31
31
  Redmine::Reporting.report(exception) do
32
32
  notes do
33
- section("URL: #{desc[:url]}", '')
33
+ section("URL: #{desc[:url]} (#{desc[:params][:controller]}##{desc[:params][:action]})", '')
34
34
  section('Parameters') do
35
- output(desc[:params].collect{|k,v| "* #{k}: #{v}"}.join("\n"))
35
+ output(desc[:params].select{|k,v| ![:controller, :action].include?(k)}.collect{|k,v| "* *#{k}:* #{v}"}.join("\n"))
36
36
  end
37
37
  section('Session') do
38
- output(desc[:session].collect{|k,v| "* #{k}: #{v}"}.join("\n"))
38
+ output(desc[:session].collect{|k,v| "* *#{k}:* #{v}"}.join("\n"))
39
39
  end
40
40
  end
41
41
  end
@@ -28,6 +28,8 @@ module Redmine
28
28
  end
29
29
 
30
30
  def commit
31
+ reference_id = "#{Zlib.crc32(Time.now.to_f.to_s).to_s(16)}#{Zlib.crc32(@subject).to_s(16)}#{Zlib.crc32(@description).to_s(16)}"
32
+
31
33
  options = (config[:http_options] || {}).merge({
32
34
  headers: {
33
35
  'Content-type' => 'application/json',
@@ -35,7 +37,10 @@ module Redmine
35
37
  }
36
38
  })
37
39
 
38
- if issue_id.nil?
40
+ # add reference_id to description if updates are disabled
41
+ @description = "h1. #{reference_id}\n\n#{@description}" if config[:no_update]
42
+
43
+ if saved_issue_id.nil?
39
44
  resp = HTTParty.post("#{config[:base_url]}/issues.json", options.merge({
40
45
  body: {
41
46
  issue: {
@@ -50,12 +55,12 @@ module Redmine
50
55
 
51
56
  iid = resp['issue']['id'] rescue nil
52
57
 
53
- File.open(issue_id_file, File::CREAT|File::TRUNC|File::RDWR, 0600) {|f| f.write(iid.to_s)} unless iid.nil?
58
+ save_issue_data(iid, reference_id) unless iid.nil?
54
59
  end
55
60
 
56
- return false if issue_id.nil?
61
+ return false if (issue_id = saved_issue_id).nil?
57
62
 
58
- reference_id = "#{Zlib.crc32(Time.now.to_f.to_s).to_s(16)}#{Zlib.crc32(@subject).to_s(16)}#{Zlib.crc32(@description).to_s(16)}"
63
+ return saved_reference_id if config[:no_update]
59
64
 
60
65
  resp = HTTParty.put("#{config[:base_url]}/issues/#{issue_id}.json", options.merge({
61
66
  body: {
@@ -65,6 +70,8 @@ module Redmine
65
70
  }.to_json
66
71
  }))
67
72
 
73
+ save_issue_data(issue_id, reference_id)
74
+
68
75
  reference_id
69
76
  rescue => e
70
77
  # TODO ignore
@@ -81,6 +88,10 @@ module Redmine
81
88
  nil
82
89
  end
83
90
 
91
+ def chapter(title, content=nil, &block)
92
+ syntax_section('h1', title, content, &block)
93
+ end
94
+
84
95
  def section(title, content=nil, &block)
85
96
  syntax_section('h2', title, content, &block)
86
97
  end
@@ -116,13 +127,26 @@ module Redmine
116
127
  File.join(Dir.tmpdir, "redmine_reporting_#{issue_hash}")
117
128
  end
118
129
 
119
- def issue_id
130
+ def save_issue_data(issue_id, reference_id)
131
+ File.open(issue_id_file, File::CREAT|File::TRUNC|File::RDWR, 0600) {|f| f.write("#{issue_id.to_s};#{reference_id}")}
132
+ end
133
+
134
+ def read_issue_data
135
+ data = [nil, nil]
136
+
120
137
  if File.exists?(issue_id_file)
121
- id = File.open(issue_id_file, 'r').read.strip.to_i
122
- return id if id > 0
138
+ data = File.open(issue_id_file, 'r').read.split(';').collect{|d| d.strip} rescue [nil, nil]
123
139
  end
124
140
 
125
- nil
141
+ data
142
+ end
143
+
144
+ def saved_issue_id
145
+ read_issue_data.first
146
+ end
147
+
148
+ def saved_reference_id
149
+ read_issue_data.last
126
150
  end
127
151
 
128
152
  end
@@ -1,5 +1,5 @@
1
1
  module Redmine
2
2
  module Reporting
3
- VERSION = '0.1.2'
3
+ VERSION = '0.1.3'
4
4
  end
5
5
  end
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.2
4
+ version: 0.1.3
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-26 00:00:00.000000000 Z
11
+ date: 2013-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler