rake_notifier 0.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.
- data/.gitignore +2 -0
- data/README.markdown +19 -0
- data/lib/rake_notifier.rb +41 -0
- data/rake_notifier.gemspec +16 -0
- metadata +98 -0
data/.gitignore
ADDED
data/README.markdown
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
### Rake Notifier send a notification to your email address whenever a Rake task in your application fails.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
#### Usage
|
|
5
|
+
1. Add to Gemfile
|
|
6
|
+
```ruby
|
|
7
|
+
gem 'rake_notifier'
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. If you had already setup exception_notification_rails3.gem, rake_notifier.gem will read your email configurations from it.
|
|
11
|
+
|
|
12
|
+
3. If your dont use exception_notification_rails3.gem, you can setup it
|
|
13
|
+
customly, just
|
|
14
|
+
```ruby
|
|
15
|
+
Rake.email_from = 'your@email.com'
|
|
16
|
+
Rake.email_to = 'another@email.com'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### And then you're ready to go.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require 'pony'
|
|
2
|
+
require 'rake/task'
|
|
3
|
+
|
|
4
|
+
# load only_one_rake.gem first, because it'll overwrite Rake::Task#execute directly
|
|
5
|
+
require 'only_one_rake'
|
|
6
|
+
|
|
7
|
+
module Rake
|
|
8
|
+
mattr_accessor :email_from, :email_to
|
|
9
|
+
|
|
10
|
+
class Task
|
|
11
|
+
alias :orig_execute :execute
|
|
12
|
+
def execute(args=nil)
|
|
13
|
+
orig_execute(args)
|
|
14
|
+
rescue Exception => exception
|
|
15
|
+
handle_exception(exception)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def handle_exception(exception)
|
|
19
|
+
if Rake.email_from.blank? # lazy load
|
|
20
|
+
# fetch emails from ExceptionNotifier's configuration
|
|
21
|
+
if defined? ExceptionNotifier
|
|
22
|
+
args = Rails::Application.subclasses.map {|app| app.config.middleware.middlewares }.flatten.select {|m| m === ExceptionNotifier }.map {|en| en.args }.flatten
|
|
23
|
+
if args.blank?
|
|
24
|
+
raise "Please setup your ExceptionNotifier first"
|
|
25
|
+
else
|
|
26
|
+
Rake.email_from = args[0][:sender_address]
|
|
27
|
+
Rake.email_to = args.map {|i| i[:exception_recipients] }.flatten.join(", ")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
$stderr.puts
|
|
33
|
+
$stderr.puts subject = "Rake exception - #{exception.message}"
|
|
34
|
+
$stderr.puts body = "#{exception.message}\n\n#{exception.backtrace.join("\n")}"
|
|
35
|
+
Pony.mail(:from => Rake.email_from, :to => Rake.email_to, :subject => subject, :body => body)
|
|
36
|
+
$stderr.puts
|
|
37
|
+
$stderr.puts "Exception details sent to #{Rake.email_to}"
|
|
38
|
+
$stderr.puts
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "rake_notifier"
|
|
3
|
+
s.version = "0.1"
|
|
4
|
+
s.date = '2013-05-08'
|
|
5
|
+
s.summary = ""
|
|
6
|
+
s.description = s.summary
|
|
7
|
+
s.authors = ["Oscar Del Ben", "David Chen"]
|
|
8
|
+
s.email = 'mvjome@gmail.com'
|
|
9
|
+
s.files = `git ls-files`.split("\n")
|
|
10
|
+
s.homepage = 'http://github.com/mvj3/rake_notifier'
|
|
11
|
+
s.licenses = ["MIT"]
|
|
12
|
+
|
|
13
|
+
s.add_dependency "rake"
|
|
14
|
+
s.add_dependency "pony"
|
|
15
|
+
s.add_dependency "only_one_rake"
|
|
16
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rake_notifier
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Oscar Del Ben
|
|
9
|
+
- David Chen
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rake
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
none: false
|
|
19
|
+
requirements:
|
|
20
|
+
- - ! '>='
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '0'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
none: false
|
|
27
|
+
requirements:
|
|
28
|
+
- - ! '>='
|
|
29
|
+
- !ruby/object:Gem::Version
|
|
30
|
+
version: '0'
|
|
31
|
+
- !ruby/object:Gem::Dependency
|
|
32
|
+
name: pony
|
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
|
34
|
+
none: false
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
type: :runtime
|
|
40
|
+
prerelease: false
|
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: only_one_rake
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ! '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
type: :runtime
|
|
56
|
+
prerelease: false
|
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ! '>='
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0'
|
|
63
|
+
description: ''
|
|
64
|
+
email: mvjome@gmail.com
|
|
65
|
+
executables: []
|
|
66
|
+
extensions: []
|
|
67
|
+
extra_rdoc_files: []
|
|
68
|
+
files:
|
|
69
|
+
- .gitignore
|
|
70
|
+
- README.markdown
|
|
71
|
+
- lib/rake_notifier.rb
|
|
72
|
+
- rake_notifier.gemspec
|
|
73
|
+
homepage: http://github.com/mvj3/rake_notifier
|
|
74
|
+
licenses:
|
|
75
|
+
- MIT
|
|
76
|
+
post_install_message:
|
|
77
|
+
rdoc_options: []
|
|
78
|
+
require_paths:
|
|
79
|
+
- lib
|
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
none: false
|
|
88
|
+
requirements:
|
|
89
|
+
- - ! '>='
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubyforge_project:
|
|
94
|
+
rubygems_version: 1.8.25
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 3
|
|
97
|
+
summary: ''
|
|
98
|
+
test_files: []
|