rails_exception_handler 2.3.5 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32267ce6778cb1486e485a000b8482d24b5bd360
4
- data.tar.gz: 767c02c57f3382f54d447dad4c9adf3902467d2a
3
+ metadata.gz: f1f7fe95e0609f50a4e9b019cc4c685aec54d4a9
4
+ data.tar.gz: 7cf25f2fd396d8d98ad82f9aeda580a99bcd42a6
5
5
  SHA512:
6
- metadata.gz: 45d7d4b55c3d36a96acfae8237899e065f3d1da54b00ac67cd3bd250b0ca2d8ac367d4bcbe5c8ec4f222cd78e4714404fea80324efeb49472652dec79893adc2
7
- data.tar.gz: 820ffdb2a5f84bc7626328f7f6219f21f640564d570613fed23111c7d6dd6ca962d08869f61b5e363d714a4ca1b4e587dc9ad744cf1cb9198670eae2d487b1b2
6
+ metadata.gz: '08740c06d7c7e5de8b75e2dc693d40d6aed88c3f7ee1b2b141f3b4599a719cb9931cc5c47316238f6f0c936967541c0581b6980880ecc55ae2e329e3ea01fd7d'
7
+ data.tar.gz: 26b7059fd57c9b393eb50cf04d264b9646c82a819161a5516022321d11b50b4e870d5bedb84f12fac2754c9f2c0b53b71431e931a0a306b33a79540972526fa9
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
  ruby File.read(".ruby-version").strip
3
+ #ruby '1.9.3', :patchlevel => "125"
3
4
 
4
5
  group :test, :development do
5
6
 
@@ -7,10 +8,12 @@ group :test, :development do
7
8
  #gem "rack-test", '0.5.7'
8
9
  #gem 'mongoid'
9
10
  #gem 'bson_ext'
11
+ #gem 'nokogiri', '1.6.8.1'
10
12
 
11
13
  #gem "rails", '3.2.22.5'
12
14
  #gem "rack-test", '0.6.2'
13
15
  #gem 'mongoid'
16
+ #gem 'nokogiri', '1.6.8.1'
14
17
 
15
18
  #gem "rails", '4.0.13'
16
19
  #gem "rack-test", '0.6.3'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_exception_handler (2.3.4)
4
+ rails_exception_handler (2.4.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -45,14 +45,14 @@ GEM
45
45
  tzinfo (~> 1.1)
46
46
  addressable (2.4.0)
47
47
  arel (8.0.0)
48
- bson (4.2.1)
48
+ bson (4.2.2)
49
49
  builder (3.2.3)
50
50
  coderay (1.1.1)
51
51
  concurrent-ruby (1.0.5)
52
52
  descendants_tracker (0.0.4)
53
53
  thread_safe (~> 0.3, >= 0.3.1)
54
54
  diff-lcs (1.3)
55
- erubi (1.6.0)
55
+ erubi (1.6.1)
56
56
  faraday (0.9.2)
57
57
  multipart-post (>= 1.2, < 3)
58
58
  git (1.3.0)
@@ -65,10 +65,10 @@ GEM
65
65
  oauth2 (~> 1.0)
66
66
  globalid (0.4.0)
67
67
  activesupport (>= 4.2.0)
68
- hashie (3.5.5)
68
+ hashie (3.5.6)
69
69
  highline (1.7.8)
70
- i18n (0.8.4)
71
- jeweler (2.3.6)
70
+ i18n (0.8.6)
71
+ jeweler (2.3.7)
72
72
  builder
73
73
  bundler (>= 1)
74
74
  git (>= 1.2.5)
@@ -87,10 +87,10 @@ GEM
87
87
  method_source (0.8.2)
88
88
  mime-types (2.99.3)
89
89
  mini_portile2 (2.2.0)
90
- minitest (5.10.2)
91
- mongo (2.4.2)
90
+ minitest (5.10.3)
91
+ mongo (2.4.3)
92
92
  bson (>= 4.2.1, < 5.0.0)
93
- mongoid (6.2.0)
93
+ mongoid (6.2.1)
94
94
  activemodel (~> 5.1)
95
95
  mongo (>= 2.4.1, < 3.0.0)
96
96
  multi_json (1.12.1)
@@ -165,7 +165,7 @@ GEM
165
165
  activesupport (>= 4.0)
166
166
  sprockets (>= 3.0.0)
167
167
  sqlite3 (1.3.13)
168
- thor (0.19.4)
168
+ thor (0.20.0)
169
169
  thread_safe (0.3.6)
170
170
  tzinfo (1.2.3)
171
171
  thread_safe (~> 0.1)
@@ -191,4 +191,4 @@ RUBY VERSION
191
191
  ruby 2.4.1p111
192
192
 
193
193
  BUNDLED WITH
194
- 1.15.1
194
+ 1.15.4
data/HISTORY CHANGED
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
 
3
+ v2.4.0
4
+ - Email storage strategy, by https://github.com/lethunder
5
+
3
6
  v2.3.5 - June 19th 2017
4
7
  - Fix compatibility with Ruby 2.4 and Rails 5
5
8
 
data/README.markdown CHANGED
@@ -235,6 +235,21 @@ config.storage_strategies = [:remote_url => {:target => 'http://example.com/erro
235
235
  This option is meant for those who want to store the exception in a database table, but does not have direct access to the database itself, making active record store unsuitable. You need a web app on a server that has access to the database. An HTTP POST request will be sent to the specified URL with the error message as data.
236
236
  If you use a Rails app at the other end you should simply be able to do `RailsExceptionHandler::ActiveRecord::ErrorMessage.create(params[:error_message])` or `RailsExceptionHandler::Mongoid::ErrorMessage.create(params[:error_message])` to save the report depending upon your database choice.
237
237
 
238
+ ### Sending the error report as an email
239
+
240
+ ```ruby
241
+ config.storage_strategies = [:email => {:recipients => "test1@example.com,test2@example.com"}]
242
+ ```
243
+
244
+ Exceptions will be notified by email. Make sure the application got an
245
+ `ApplicationMailer` with default from specified:
246
+
247
+ ```ruby
248
+ class ApplicationMailer < ActionMailer::Base
249
+ default from: 'from@example.com'
250
+ end
251
+ ```
252
+
238
253
  # Exception filters
239
254
 
240
255
  Sometimes it is necessary to filter errors. All filters are disabled by default and I recommend you deploy your application this way initially, and then add filters as they become necessary.
@@ -298,10 +313,6 @@ config.filters = [:referer_url_regxp => /\problematicreferer/i]
298
313
 
299
314
  https://github.com/Sharagoz/rails_exception_handler/graphs/contributors
300
315
 
301
- Would you like to contribute? Here are some things on the todo list:
302
-
303
- * An email storage strategy for those that wish to be notified of the exceptions through email
304
-
305
316
  # Licence
306
317
 
307
318
  Copyright © 2017 Bjørn Trondsen, released under the MIT license
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.name = "rails_exception_handler"
22
22
  gem.homepage = "http://github.com/Sharagoz/rails_exception_handler"
23
23
  gem.license = "MIT"
24
- gem.summary = %Q{Exception Handling for Rails 3}
24
+ gem.summary = %Q{Highly customizable exception handling for Ruby on Rails}
25
25
  gem.description = %Q{}
26
26
  gem.email = "contact@sharagoz.com"
27
27
  gem.authors = ["Sharagoz"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.5
1
+ 2.4.0
@@ -0,0 +1,15 @@
1
+ if(RailsExceptionHandler.configuration.activate?)
2
+ class RailsExceptionHandler::ErrorMailer < ApplicationMailer
3
+
4
+ # Subject can be set in your I18n file at config/locales/en.yml
5
+ # with the following lookup:
6
+ #
7
+ # en.error_mailer.send_error_mail_to_admin.subject
8
+ #
9
+ def send_error_mail_to_admin(info,email)
10
+ @info = JSON.parse(info)
11
+ mail(to: email, subject: 'An error occured on your application')
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ <p>
2
+ Hi boss,
3
+ </p>
4
+ <p>
5
+ an error occured at <%= @info["created_at"] %>
6
+ </p>
7
+
8
+ <% @info.each do |key, value| %>
9
+ <% next if value.blank? %>
10
+ <p>
11
+ <%= key.upcase %><br/>
12
+ <%= value %>
13
+ </p>
14
+
15
+ <% end %>
@@ -0,0 +1,8 @@
1
+ Hi boss,
2
+ an error occured at <%= @info["created_at"] %>
3
+
4
+ <% @info.each do |key, value| %>
5
+ <% next if value.blank? %>
6
+ <%= key.upcase %>
7
+ <%= value %>
8
+ <% end %>
@@ -32,6 +32,8 @@ class RailsExceptionHandler::Handler
32
32
  RailsExceptionHandler::Storage.send(strategy, @parsed_error.external_info)
33
33
  elsif(strategy.class == Hash && strategy[:remote_url])
34
34
  RailsExceptionHandler::Storage.remote_url(strategy[:remote_url][:target],@parsed_error.external_info)
35
+ elsif(strategy.class == Hash && strategy[:email])
36
+ RailsExceptionHandler::Storage.email(strategy[:email][:recipients],@parsed_error.external_info)
35
37
  else
36
38
  raise "RailsExceptionHandler: Unknown storage strategy #{strategy.inspect}"
37
39
  end
@@ -29,6 +29,17 @@ class RailsExceptionHandler::Storage
29
29
  Net::HTTP::post_form(uri, params)
30
30
  end
31
31
 
32
+ # Notify application admin that an error occured
33
+ def self.email(recipients,info)
34
+ return if recipients.blank?
35
+ if Rails::VERSION::MAJOR == 3 || (Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR < 2)
36
+ delivery_method = :deliver
37
+ else
38
+ delivery_method = :deliver_later
39
+ end
40
+ RailsExceptionHandler::ErrorMailer.send_error_mail_to_admin(info.to_json,recipients).send(delivery_method)
41
+ end
42
+
32
43
  private
33
44
 
34
45
  # Credit: Hash flattening technique borrowed from Peter Marklund: http://marklunds.com/articles/one/314
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: rails_exception_handler 2.3.5 ruby lib
5
+ # stub: rails_exception_handler 2.4.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "rails_exception_handler".freeze
9
- s.version = "2.3.5"
9
+ s.version = "2.4.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Sharagoz".freeze]
14
- s.date = "2017-06-19"
14
+ s.date = "2017-08-29"
15
15
  s.description = "".freeze
16
16
  s.email = "contact@sharagoz.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -28,8 +28,11 @@ Gem::Specification.new do |s|
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "app/controllers/error_response_controller.rb",
31
+ "app/mailers/rails_exception_handler/error_mailer.rb",
31
32
  "app/models/rails_exception_handler/active_record/error_message.rb",
32
33
  "app/models/rails_exception_handler/mongoid/error_message.rb",
34
+ "app/views/rails_exception_handler/error_mailer/send_error_mail_to_admin.html.erb",
35
+ "app/views/rails_exception_handler/error_mailer/send_error_mail_to_admin.text.erb",
33
36
  "gemfiles/rails30.gemfile",
34
37
  "gemfiles/rails32.187-ree.gemfile",
35
38
  "gemfiles/rails32.gemfile",
@@ -85,7 +88,7 @@ Gem::Specification.new do |s|
85
88
  s.homepage = "http://github.com/Sharagoz/rails_exception_handler".freeze
86
89
  s.licenses = ["MIT".freeze]
87
90
  s.rubygems_version = "2.6.12".freeze
88
- s.summary = "Exception Handling for Rails 3".freeze
91
+ s.summary = "Highly customizable exception handling for Ruby on Rails".freeze
89
92
 
90
93
  if s.respond_to? :specification_version then
91
94
  s.specification_version = 4
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_exception_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharagoz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -153,8 +153,11 @@ files:
153
153
  - Rakefile
154
154
  - VERSION
155
155
  - app/controllers/error_response_controller.rb
156
+ - app/mailers/rails_exception_handler/error_mailer.rb
156
157
  - app/models/rails_exception_handler/active_record/error_message.rb
157
158
  - app/models/rails_exception_handler/mongoid/error_message.rb
159
+ - app/views/rails_exception_handler/error_mailer/send_error_mail_to_admin.html.erb
160
+ - app/views/rails_exception_handler/error_mailer/send_error_mail_to_admin.text.erb
158
161
  - gemfiles/rails30.gemfile
159
162
  - gemfiles/rails32.187-ree.gemfile
160
163
  - gemfiles/rails32.gemfile
@@ -229,5 +232,5 @@ rubyforge_project:
229
232
  rubygems_version: 2.6.12
230
233
  signing_key:
231
234
  specification_version: 4
232
- summary: Exception Handling for Rails 3
235
+ summary: Highly customizable exception handling for Ruby on Rails
233
236
  test_files: []