dobexer 0.1.0

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.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in dobexer.gemspec
4
+ gemspec
@@ -0,0 +1,74 @@
1
+ Dobexer
2
+ =======
3
+
4
+ This gem aims to provide a simple integration of ExceptionNotification and
5
+ DelayedJob, so we can be emailed when an error occurs inside a job's
6
+ `perform`. It relies on collectiveidea's [delayed_job](https://github.com/collectiveidea/delayed_job) and smartinez87's [exception_notification](https://github.com/smartinez87/exception_notification) both the official versions you can find on rubygems.org.
7
+
8
+
9
+ Usage
10
+ -----
11
+
12
+ In order to make this thing work, you must use custom jobs with DelayedJob
13
+ (this is a DJ limitation) and then include the provided mixin:
14
+
15
+ class MyJob
16
+ include Dobexer::ExceptionNotifier
17
+
18
+ def perform
19
+ # Do work
20
+ end
21
+ end
22
+
23
+ Your Job class will then gain an `error` method which will perform the
24
+ integration with ExceptionNotification every time an exception occurs inside the
25
+ job's `perform`.
26
+
27
+
28
+ Sent notifications
29
+ ------------------
30
+
31
+ Dobexer will send an exception notification only the first time a job fails,
32
+ so even if the job itself runs for 25 attemps or more, the notification will
33
+ be sent only once.
34
+
35
+
36
+ Fake Request
37
+ ------------
38
+
39
+ ExceptionNotification expects a real *request* object to exists and of course
40
+ we don't have any from the DelayedJob context, this is why Dobexer will fake
41
+ it. Thus in the email sent by ExceptionNotification the request env will
42
+ appear like this:
43
+
44
+ -------------------------------
45
+ Request:
46
+ -------------------------------
47
+
48
+ * URL : http://delayed_job_fake_host
49
+ * IP address:
50
+ * Parameters: {}
51
+ * Rails root: /your/app/root
52
+
53
+
54
+ -------------------------------
55
+ Environment:
56
+ -------------------------------
57
+
58
+ * HTTP_HOST : delayed_job_fake_host
59
+ * REQUEST_METHOD : GET
60
+ * REQUEST_URI : /
61
+ * action_dispatch.request.content_type :
62
+ * action_dispatch.request.parameters : {}
63
+ * action_dispatch.request.path_parameters : {}
64
+ * action_dispatch.request.query_parameters : {}
65
+ * action_dispatch.request.request_parameters: {}
66
+ * rack.input :
67
+ * rack.request.query_hash : {}
68
+ * rack.request.query_string :
69
+ * rack.session : {}
70
+ * rack.url_scheme : http
71
+
72
+ * Process: 6666
73
+ * Server : Hostname
74
+
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "dobexer/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "dobexer"
7
+ s.version = Dobexer::VERSION
8
+ s.authors = ["Roger Campos"]
9
+ s.email = ["roger@itnig.net"]
10
+ s.homepage = ""
11
+ s.summary = %q{Integrates DelayedJob with Exception Notifier}
12
+ s.description = %q{Integrates DelayedJob with Exception Notifier}
13
+
14
+ s.rubyforge_project = "dobexer"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "delayed_job", ">= 2.1.0"
22
+ s.add_dependency "exception_notification", ">= 2.4.1"
23
+ end
@@ -0,0 +1,23 @@
1
+ require "dobexer/version"
2
+
3
+ module Dobexer
4
+ module ExceptionNotifier
5
+ end
6
+ end
7
+
8
+ if defined?(Delayed) && defined?(::ExceptionNotifier)
9
+ module Dobexer
10
+ module ExceptionNotifier
11
+ def error(job, exception)
12
+ return if job.attempts > 0
13
+
14
+ env = {"HTTP_HOST" => "delayed_job_fake_host",
15
+ "REQUEST_URI" => "/",
16
+ "REQUEST_METHOD" => "GET",
17
+ "rack.input" => "",
18
+ "rack.url_scheme" => "http"}
19
+ ::ExceptionNotifier::Notifier.exception_notification(env, exception).deliver
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Dobexer
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dobexer
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Roger Campos
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: delayed_job
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 2
31
+ - 1
32
+ - 0
33
+ version: 2.1.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: exception_notification
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 29
45
+ segments:
46
+ - 2
47
+ - 4
48
+ - 1
49
+ version: 2.4.1
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ description: Integrates DelayedJob with Exception Notifier
53
+ email:
54
+ - roger@itnig.net
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files: []
60
+
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - dobexer.gemspec
67
+ - lib/dobexer.rb
68
+ - lib/dobexer/version.rb
69
+ homepage: ""
70
+ licenses: []
71
+
72
+ post_install_message:
73
+ rdoc_options: []
74
+
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ requirements: []
96
+
97
+ rubyforge_project: dobexer
98
+ rubygems_version: 1.8.5
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Integrates DelayedJob with Exception Notifier
102
+ test_files: []
103
+