Dex 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/Dex.rb +4 -3
  2. data/lib/Dex/version.rb +1 -1
  3. data/spec/Dex.rb +17 -0
  4. metadata +2 -2
data/lib/Dex.rb CHANGED
@@ -90,9 +90,10 @@ class Dex
90
90
  bt = :backtrace
91
91
  ex = :exception
92
92
  stat = :status
93
+ created = :created_at
93
94
 
94
- final = Hash[ msg => 'Unknown', ex => 'Unknown', stat => 0, :created_at=>Time.now.utc ]
95
- if e.respond_to?(:exception)
95
+ final = Hash[ msg => 'Unknown', ex => 'Unknown', stat => 0, created =>Time.now.utc ]
96
+ if e.respond_to?(ex)
96
97
  final[ msg ] = e.message
97
98
  final[ bt ] = e.backtrace
98
99
  final[ ex ] = e.exception.class.name
@@ -113,7 +114,7 @@ class Dex
113
114
  end
114
115
  end
115
116
 
116
- final[ bt ] = (final[bt] || []).join("\n")
117
+ final[ bt ] = [ final[bt] ].compact.join("\n")
117
118
 
118
119
  final.keys.each { |k|
119
120
  v = final[k]
@@ -1,3 +1,3 @@
1
1
  class Dex
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -155,6 +155,23 @@ describe "Dex :insert" do
155
155
  }
156
156
  end
157
157
 
158
+ it "accepts a Hash with an overriding :backtrace String" do
159
+ target = "file:1:txt1\nfile:2:txt2"
160
+ dex = new_dex "custom hash"
161
+ rollback(dex) {
162
+ dex.insert :exception=>"Nginx Error", :message=>"upstream not found", :backtrace=>target, :status=>1
163
+ last(dex)[:backtrace].should == target
164
+ }
165
+ end
166
+
167
+ it "accepts a Hash with an overriding :backtrace nil" do
168
+ dex = new_dex "custom hash"
169
+ rollback(dex) {
170
+ dex.insert :exception=>"Nginx Error", :message=>"upstream not found", :backtrace=>nil, :status=>1
171
+ last(dex)[:backtrace].should == ''
172
+ }
173
+ end
174
+
158
175
  end # === Dex :insert
159
176
 
160
177
  describe "Dex :keep_only" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Dex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-11 00:00:00.000000000 Z
12
+ date: 2012-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bacon