ixtlan-error-handler 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -73,6 +73,9 @@ module Ixtlan
73
73
  @to_emails,
74
74
  exception,
75
75
  "#{@base_url}/#{error.id}" ).deliver
76
+ true
77
+ else
78
+ false
76
79
  end
77
80
  end
78
81
 
@@ -122,7 +125,7 @@ module Ixtlan
122
125
  if(@last_cleanup.nil? || @last_cleanup < (now - 1))
123
126
  @last_cleanup = now
124
127
  begin
125
- delete_all( now - keep_logs )
128
+ delete_all( now - keep_dumps )
126
129
  logger.info "cleaned error dumps"
127
130
  rescue Exception => e
128
131
  logger.warn "error cleaning up error dumps: #{e.message}"
@@ -143,4 +146,4 @@ module Ixtlan
143
146
  end
144
147
  end
145
148
  end
146
- end
149
+ end
@@ -82,11 +82,11 @@ module Ixtlan
82
82
 
83
83
  def dump_error(exception)
84
84
  Rails.configuration.error_dumper.dump( exception,
85
- controller.request.env,
86
- controller.response.headers,
87
- controller.session,
88
- controller.params )
85
+ request.env,
86
+ response.headers,
87
+ session,
88
+ params )
89
89
  end
90
90
  end
91
91
  end
92
- end
92
+ end
@@ -22,32 +22,14 @@ class Error
22
22
  end
23
23
  end
24
24
 
25
- module Ixtlan
26
- module Errors
27
- module ActionMailer
28
- class Base
29
-
30
- def self.method_missing(method, *args)
31
- self.new
32
- end
33
-
34
- def self.deliver(val = nul)
35
- @delivered = val if val
36
- @delivered
37
- end
38
- def deliver
39
- self.class.deliver(true)
40
- end
41
- end
42
- end
43
- end
44
- end
25
+ require 'pony'
26
+ Pony.options = { :via => :test }
45
27
 
46
- require 'ixtlan/errors/error_dumper'
28
+ require 'ixtlan/errors/dumper'
47
29
  require 'date'
48
30
  require 'logger'
49
31
 
50
- class Controller
32
+ class Controller < Hash
51
33
 
52
34
  def request
53
35
  self
@@ -105,26 +87,29 @@ end
105
87
 
106
88
  DataMapper.setup(:default, "sqlite3::memory:")
107
89
  DataMapper.finalize
108
- DataMapper.repository.auto_migrate!
90
+ DataMapper.auto_migrate!
109
91
 
110
- describe Ixtlan::Errors::ErrorDumper do
92
+ describe Ixtlan::Errors::Dumper do
111
93
 
112
94
  before :each do
113
- @dumper = Ixtlan::Errors::ErrorDumper.new
95
+ @dumper = Ixtlan::Errors::Dumper.new
96
+ @dumper.model = Error
114
97
  @dumper.base_url = "http://localhost"
115
98
  @controller = Controller.new
116
99
  end
117
100
 
118
101
  it "should dump env and not send notification" do
119
- url = @dumper.dump(@controller, StandardError.new("dump it"))
120
- url.should =~ /http:\/\/localhost\/[0-9]+/
102
+ send = @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
103
+ send.should be_false
104
+
121
105
  @dumper.from_email = "asd"
122
- url = @dumper.dump(@controller, StandardError.new("dump it"))
123
- url.should =~ /http:\/\/localhost\/[0-9]+/
106
+ send = @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
107
+ send.should be_false
108
+
124
109
  @dumper.from_email = nil
125
110
  @dumper.to_emails = "dsa"
126
- url = @dumper.dump(@controller, StandardError.new("dump it"))
127
- url.should =~ /http:\/\/localhost\/[0-9]+/
111
+ send = @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
112
+ send.should be_false
128
113
  end
129
114
 
130
115
  it "should clean up error dumps" do
@@ -132,16 +117,19 @@ describe Ixtlan::Errors::ErrorDumper do
132
117
  Error.all.size.should > 0
133
118
  @dumper.keep_dumps = 0
134
119
  Error.all.size.should == 0
135
- @dumper.dump(@controller, StandardError.new("dump it"))
120
+
121
+ @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
136
122
  Error.all.size.should == 1
137
- @dumper.dump(@controller, StandardError.new("dump it"))
123
+
124
+ @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
138
125
  Error.all.size.should == 2
139
126
  end
140
127
 
141
128
  it "should send notifications" do
142
129
  @dumper.to_emails = "das"
143
130
  @dumper.from_email = "asd"
144
- @dumper.dump(@controller, StandardError.new("dump it"))
145
- Ixtlan::Errors::ActionMailer::Base.delivered.should be_true
131
+
132
+ send = @dumper.dump(StandardError.new("dump it"), @controller.request, @controller.response, @controller.session, @controller.params)
133
+ send.should be_true
146
134
  end
147
135
  end
@@ -46,7 +46,11 @@ class Rails
46
46
  self
47
47
  end
48
48
 
49
- def self.dump(controller, exception)
49
+ def self.dump(exception,
50
+ request,
51
+ response,
52
+ session,
53
+ params)
50
54
  @dumped = exception
51
55
  end
52
56
 
metadata CHANGED
@@ -1,101 +1,158 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ixtlan-error-handler
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Christian Meier
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-12-24 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-12-29 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: slf4r
16
- requirement: &13017120 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
25
+ requirements:
19
26
  - - ~>
20
- - !ruby/object:Gem::Version
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 0
31
+ - 4
32
+ - 2
21
33
  version: 0.4.2
22
34
  type: :runtime
23
- prerelease: false
24
- version_requirements: *13017120
25
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
26
37
  name: rspec
27
- requirement: &13014420 !ruby/object:Gem::Requirement
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
28
40
  none: false
29
- requirements:
41
+ requirements:
30
42
  - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '2.11'
43
+ - !ruby/object:Gem::Version
44
+ hash: 21
45
+ segments:
46
+ - 2
47
+ - 11
48
+ version: "2.11"
33
49
  type: :development
34
- prerelease: false
35
- version_requirements: *13014420
36
- - !ruby/object:Gem::Dependency
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
37
52
  name: rake
38
- requirement: &13013760 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
39
55
  none: false
40
- requirements:
56
+ requirements:
41
57
  - - ~>
42
- - !ruby/object:Gem::Version
58
+ - !ruby/object:Gem::Version
59
+ hash: 75
60
+ segments:
61
+ - 10
62
+ - 0
63
+ - 2
43
64
  version: 10.0.2
44
65
  type: :development
45
- prerelease: false
46
- version_requirements: *13013760
47
- - !ruby/object:Gem::Dependency
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
48
68
  name: dm-core
49
- requirement: &13013000 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
50
71
  none: false
51
- requirements:
72
+ requirements:
52
73
  - - ~>
53
- - !ruby/object:Gem::Version
74
+ - !ruby/object:Gem::Version
75
+ hash: 31
76
+ segments:
77
+ - 1
78
+ - 2
79
+ - 0
54
80
  version: 1.2.0
55
81
  type: :development
56
- prerelease: false
57
- version_requirements: *13013000
58
- - !ruby/object:Gem::Dependency
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
59
84
  name: dm-migrations
60
- requirement: &13012260 !ruby/object:Gem::Requirement
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
61
87
  none: false
62
- requirements:
88
+ requirements:
63
89
  - - ~>
64
- - !ruby/object:Gem::Version
90
+ - !ruby/object:Gem::Version
91
+ hash: 31
92
+ segments:
93
+ - 1
94
+ - 2
95
+ - 0
65
96
  version: 1.2.0
66
97
  type: :development
67
- prerelease: false
68
- version_requirements: *13012260
69
- - !ruby/object:Gem::Dependency
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
70
100
  name: dm-sqlite-adapter
71
- requirement: &13011800 !ruby/object:Gem::Requirement
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
72
103
  none: false
73
- requirements:
104
+ requirements:
74
105
  - - ~>
75
- - !ruby/object:Gem::Version
106
+ - !ruby/object:Gem::Version
107
+ hash: 31
108
+ segments:
109
+ - 1
110
+ - 2
111
+ - 0
76
112
  version: 1.2.0
77
113
  type: :development
114
+ version_requirements: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ name: pony
78
117
  prerelease: false
79
- version_requirements: *13011800
80
- - !ruby/object:Gem::Dependency
118
+ requirement: &id007 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ hash: 7
124
+ segments:
125
+ - 1
126
+ - 4
127
+ version: "1.4"
128
+ type: :development
129
+ version_requirements: *id007
130
+ - !ruby/object:Gem::Dependency
81
131
  name: copyright-header
82
- requirement: &13011240 !ruby/object:Gem::Requirement
132
+ prerelease: false
133
+ requirement: &id008 !ruby/object:Gem::Requirement
83
134
  none: false
84
- requirements:
135
+ requirements:
85
136
  - - ~>
86
- - !ruby/object:Gem::Version
137
+ - !ruby/object:Gem::Version
138
+ hash: 25
139
+ segments:
140
+ - 1
141
+ - 0
142
+ - 7
87
143
  version: 1.0.7
88
144
  type: :development
89
- prerelease: false
90
- version_requirements: *13011240
91
- description: dump errors on filesystem and notify developers, map different errors
92
- to specific pages
93
- email:
145
+ version_requirements: *id008
146
+ description: dump errors on filesystem and notify developers, map different errors to specific pages
147
+ email:
94
148
  - m.kristian@web.de
95
149
  executables: []
150
+
96
151
  extensions: []
152
+
97
153
  extra_rdoc_files: []
98
- files:
154
+
155
+ files:
99
156
  - MIT-LICENSE
100
157
  - README.textile
101
158
  - lib/ixtlan-error-handler.rb
@@ -122,37 +179,43 @@ files:
122
179
  - lib/ixtlan/errors/rack.rb
123
180
  - lib/ixtlan/errors/serializer.rb
124
181
  - spec/error_handler_spec.rb
182
+ - spec/dumper_spec.rb
125
183
  - spec/error_dumper_spec.rb~
126
184
  - spec/error_handler_spec.rb~
127
- - spec/error_dumper_spec.rb
128
185
  homepage: http://github.com/mkristian/ixtlan-error-handler
129
- licenses:
186
+ licenses:
130
187
  - MIT
131
188
  post_install_message:
132
- rdoc_options:
189
+ rdoc_options:
133
190
  - --main
134
191
  - README.textile
135
- require_paths:
192
+ require_paths:
136
193
  - lib
137
- required_ruby_version: !ruby/object:Gem::Requirement
194
+ required_ruby_version: !ruby/object:Gem::Requirement
138
195
  none: false
139
- requirements:
140
- - - ! '>='
141
- - !ruby/object:Gem::Version
142
- version: '0'
143
- required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
204
  none: false
145
- requirements:
146
- - - ! '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
211
+ version: "0"
149
212
  requirements: []
213
+
150
214
  rubyforge_project:
151
- rubygems_version: 1.8.11
215
+ rubygems_version: 1.8.15
152
216
  signing_key:
153
217
  specification_version: 3
154
218
  summary: dump errors on filesystem and notify developers
155
- test_files:
219
+ test_files:
156
220
  - spec/error_handler_spec.rb
157
- - spec/error_dumper_spec.rb
158
- has_rdoc:
221
+ - spec/dumper_spec.rb