exception_master 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 811b18e8eec17b8fb0b13bf539545dc706d28400
4
+ data.tar.gz: 90d009838f020311632f64e5a773bbc4caef125a
5
+ SHA512:
6
+ metadata.gz: 16189cd32760d7dd55fabf0b587b5e5b0d1703658dcc0482ae6af938d7c52b09e5a1e6e55d687ead2c7b5e9b569ec64c3e64c3a660b971622b03bca740c576df
7
+ data.tar.gz: 7a41fd374be7bf8e25c7f25cf5d16f75bed48d4bc7ff3ca22fdcb1f6f46ecbdded7b222e27ddeb29d9c026351fabaa72ed28b5ecd3dfd346893d4965f0ac0865
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+ gem 'pony'
10
+
11
+ group :development do
12
+ gem "bundler", "~> 1.0"
13
+ gem "jeweler", "~> 2.0.1"
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec'
18
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,75 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.3)
7
+ diff-lcs (1.2.5)
8
+ faraday (0.9.0)
9
+ multipart-post (>= 1.2, < 3)
10
+ git (1.2.6)
11
+ github_api (0.11.3)
12
+ addressable (~> 2.3)
13
+ descendants_tracker (~> 0.0.1)
14
+ faraday (~> 0.8, < 0.10)
15
+ hashie (>= 1.2)
16
+ multi_json (>= 1.7.5, < 2.0)
17
+ nokogiri (~> 1.6.0)
18
+ oauth2
19
+ hashie (2.0.5)
20
+ highline (1.6.21)
21
+ jeweler (2.0.1)
22
+ builder
23
+ bundler (>= 1.0)
24
+ git (>= 1.2.5)
25
+ github_api
26
+ highline (>= 1.6.15)
27
+ nokogiri (>= 1.5.10)
28
+ rake
29
+ rdoc
30
+ json (1.8.1)
31
+ jwt (0.1.11)
32
+ multi_json (>= 1.5)
33
+ mail (2.5.4)
34
+ mime-types (~> 1.16)
35
+ treetop (~> 1.4.8)
36
+ mime-types (1.25.1)
37
+ mini_portile (0.5.2)
38
+ multi_json (1.9.0)
39
+ multi_xml (0.5.5)
40
+ multipart-post (2.0.0)
41
+ nokogiri (1.6.1)
42
+ mini_portile (~> 0.5.0)
43
+ oauth2 (0.9.3)
44
+ faraday (>= 0.8, < 0.10)
45
+ jwt (~> 0.1.8)
46
+ multi_json (~> 1.3)
47
+ multi_xml (~> 0.5)
48
+ rack (~> 1.2)
49
+ polyglot (0.3.4)
50
+ pony (1.8)
51
+ mail (>= 2.0)
52
+ rack (1.5.2)
53
+ rake (10.1.1)
54
+ rdoc (4.1.1)
55
+ json (~> 1.4)
56
+ rspec (2.14.1)
57
+ rspec-core (~> 2.14.0)
58
+ rspec-expectations (~> 2.14.0)
59
+ rspec-mocks (~> 2.14.0)
60
+ rspec-core (2.14.8)
61
+ rspec-expectations (2.14.5)
62
+ diff-lcs (>= 1.1.3, < 2.0)
63
+ rspec-mocks (2.14.6)
64
+ treetop (1.4.15)
65
+ polyglot
66
+ polyglot (>= 0.3.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler (~> 1.0)
73
+ jeweler (~> 2.0.1)
74
+ pony
75
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Roman Snitko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ Exception Master
2
+ ================
3
+
4
+ Because ExceptionNotification only works with Rails and it sucks.
5
+ Because other exception notification gems require you to have an account on one of those error managing web services.
6
+
7
+ Fuck that.
8
+
9
+ Pure Ruby. Pure exceptions. Sends via sendmail by default (but can do SMTP). Uses Pony gem to send emails, so you can provide all the options that `Pony.mail` expects. This is how you use this gem:
10
+
11
+ require 'exception_master'
12
+
13
+ ExceptionMaster.new(
14
+ raise_error: true,
15
+ email_settings: { to: 'your-email@here.com' }
16
+ }).watch do
17
+
18
+ # all your code goes inside the block here
19
+ 1/0
20
+
21
+ end
22
+
23
+
24
+ If `raise_error` is set to true, then after sending an email, it still raises the exception and exits the program (default is `true`). `email_settings` is a hash of options that `Pony.mail` receives - consult the documentation for that gem. But don't worry too much, by default we use Sendmail, so your emails should be sent just alright if you have something like Postfix running.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "exception_master"
18
+ gem.homepage = "http://github.com/snitko/exception_master"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Simple [email] exception notifications for Ruby programs}
21
+ gem.description = %Q{Kinda like ExceptionNotification, but for Ruby, not just for Rails}
22
+ gem.email = "roman.snitko@gmail.com"
23
+ gem.authors = ["Roman Snitko"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,35 @@
1
+ require 'pony'
2
+ require 'erb'
3
+
4
+ class ExceptionMaster
5
+
6
+ attr_reader :email_config
7
+
8
+ def initialize(raise_error: true, email_config: {})
9
+
10
+ @email_config = { via: :sendmail, from: 'exception-master@localhost', subject: 'Error' }
11
+ @email_config.merge!(email_config)
12
+ @raise_error = raise_error
13
+
14
+ if @email_config[:to].nil?
15
+ raise "Please specify email addresses of email recipients using :to key in email_config attr (value should be array)"
16
+ end
17
+
18
+ end
19
+
20
+ def watch
21
+ yield
22
+ rescue Exception => e
23
+ Pony.mail(@email_config.merge({html_body: error_to_html(e)}))
24
+ raise(e) if @raise_error
25
+ end
26
+
27
+
28
+ private
29
+
30
+ def error_to_html(e)
31
+ template = ERB.new(File.read(File.expand_path(File.dirname(__FILE__)) + '/../views/error.html.erb'))
32
+ template.result(binding)
33
+ end
34
+
35
+ end
@@ -0,0 +1,20 @@
1
+ require_relative '../lib/exception_master'
2
+
3
+ describe ExceptionMaster do
4
+
5
+ it "writes Pony settings" do
6
+ em = ExceptionMaster.new(email_config: {via: :smtp, to: 'exception-master-receiver@localhost'})
7
+ em.email_config[:via].should == :smtp
8
+ end
9
+
10
+ it "sends en email on error" do
11
+ Pony.should_receive(:mail).once
12
+ ExceptionMaster.new(raise_error: false, email_config: {to: 'exception-master-receiver@localhost'}).watch { 1/0 }
13
+ end
14
+
15
+ it "raises error after sending an email" do
16
+ Pony.stub(:mail)
17
+ expect { ExceptionMaster.new(raise_error: true, email_settings: { to: 'exception-master-receiver@localhost'}).watch { 1/0 } }.to raise_exception
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ <table>
2
+
3
+ <tr>
4
+ <td>
5
+ <h3><%= e.class.to_s %>: <%= e.message %></h3>
6
+ </td>
7
+ </tr>
8
+
9
+ <tr>
10
+ <td>
11
+ <p>Backtrace:</p>
12
+ <code>
13
+ <% e.backtrace.each do |line| %>
14
+ <%= line %><br/>
15
+ <% end %>
16
+ </code>
17
+ </td>
18
+ </tr>
19
+
20
+ </table>
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exception_master
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Roman Snitko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pony
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jeweler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.1
55
+ description: Kinda like ExceptionNotification, but for Ruby, not just for Rails
56
+ email: roman.snitko@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files:
60
+ - LICENSE.txt
61
+ - README.md
62
+ files:
63
+ - .document
64
+ - .rspec
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - VERSION
71
+ - lib/exception_master.rb
72
+ - spec/exception_master_spec.rb
73
+ - views/error.html.erb
74
+ homepage: http://github.com/snitko/exception_master
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Simple [email] exception notifications for Ruby programs
98
+ test_files: []