exception-ketchup 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +21 -0
  5. data/Gemfile.lock +134 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +102 -0
  8. data/README.rdoc +102 -0
  9. data/Rakefile +49 -0
  10. data/VERSION +1 -0
  11. data/exception-ketchup.gemspec +122 -0
  12. data/lib/exception-ketchup.rb +118 -0
  13. data/lib/rails/controller.rb +111 -0
  14. data/lib/rails/error.rb +26 -0
  15. data/lib/rails/mailer.rb +25 -0
  16. data/lib/util/handler.rb +36 -0
  17. data/spec/dummy/README.rdoc +261 -0
  18. data/spec/dummy/Rakefile +7 -0
  19. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  20. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/mailers/.gitkeep +0 -0
  24. data/spec/dummy/app/models/.gitkeep +0 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/app/views/notifications/exception.html.erb +6 -0
  27. data/spec/dummy/config/application.rb +65 -0
  28. data/spec/dummy/config/boot.rb +10 -0
  29. data/spec/dummy/config/environment.rb +5 -0
  30. data/spec/dummy/config/environments/development.rb +31 -0
  31. data/spec/dummy/config/environments/production.rb +64 -0
  32. data/spec/dummy/config/environments/test.rb +35 -0
  33. data/spec/dummy/config/i18n-js.yml +22 -0
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/dummy/config/initializers/inflections.rb +15 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  38. data/spec/dummy/config/initializers/session_store.rb +8 -0
  39. data/spec/dummy/config/initializers/wrap_parameters.rb +10 -0
  40. data/spec/dummy/config/locales/en.yml +5 -0
  41. data/spec/dummy/config/mongoid.yml +80 -0
  42. data/spec/dummy/config/routes.rb +2 -0
  43. data/spec/dummy/config.ru +4 -0
  44. data/spec/dummy/lib/assets/.gitkeep +0 -0
  45. data/spec/dummy/public/404.html +26 -0
  46. data/spec/dummy/public/422.html +26 -0
  47. data/spec/dummy/public/500.html +25 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/dummy/script/rails +6 -0
  50. data/spec/lib/controller_spec.rb +113 -0
  51. data/spec/lib/error_spec.rb +29 -0
  52. data/spec/lib/exception-ketchup_spec.rb +44 -0
  53. data/spec/lib/mailer_spec.rb +46 -0
  54. data/spec/spec_helper.rb +30 -0
  55. metadata +284 -0
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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@ovula
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'rails'
7
+ gem 'mongoid'
8
+ gem 'bson_ext'
9
+
10
+ # Add dependencies to develop your gem here.
11
+ # Include everything needed to run rake, tests, features, etc.
12
+ group :development do
13
+ gem "rspec", "~> 2.8.0"
14
+ gem 'rspec-rails'
15
+ gem 'mongoid-rspec'
16
+ gem 'database_cleaner'
17
+ gem "rdoc", "~> 3.12"
18
+ gem "bundler"
19
+ gem "jeweler", "~> 1.8.4"
20
+ gem "fuubar"
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,134 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.1)
5
+ actionpack (= 3.2.1)
6
+ mail (~> 2.4.0)
7
+ actionpack (3.2.1)
8
+ activemodel (= 3.2.1)
9
+ activesupport (= 3.2.1)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.1)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.2)
17
+ activemodel (3.2.1)
18
+ activesupport (= 3.2.1)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.1)
21
+ activemodel (= 3.2.1)
22
+ activesupport (= 3.2.1)
23
+ arel (~> 3.0.0)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.1)
26
+ activemodel (= 3.2.1)
27
+ activesupport (= 3.2.1)
28
+ activesupport (3.2.1)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ bson (1.7.1)
33
+ bson_ext (1.7.1)
34
+ bson (~> 1.7.1)
35
+ builder (3.0.4)
36
+ database_cleaner (0.7.2)
37
+ diff-lcs (1.1.3)
38
+ erubis (2.7.0)
39
+ fuubar (1.0.0)
40
+ rspec (~> 2.0)
41
+ rspec-instafail (~> 0.2.0)
42
+ ruby-progressbar (~> 0.0.10)
43
+ git (1.2.5)
44
+ hike (1.2.1)
45
+ i18n (0.6.1)
46
+ jeweler (1.8.4)
47
+ bundler (~> 1.0)
48
+ git (>= 1.2.5)
49
+ rake
50
+ rdoc
51
+ journey (1.0.3)
52
+ json (1.7.6)
53
+ mail (2.4.4)
54
+ i18n (>= 0.4.0)
55
+ mime-types (~> 1.16)
56
+ treetop (~> 1.4.8)
57
+ mime-types (1.18)
58
+ mongo (1.7.1)
59
+ bson (~> 1.7.1)
60
+ mongoid (2.5.0)
61
+ activemodel (~> 3.1)
62
+ mongo (~> 1.7)
63
+ tzinfo (~> 0.3.22)
64
+ mongoid-rspec (1.4.4)
65
+ mongoid (~> 2.0)
66
+ rspec (~> 2)
67
+ multi_json (1.3.7)
68
+ polyglot (0.3.3)
69
+ rack (1.4.1)
70
+ rack-cache (1.2)
71
+ rack (>= 0.4)
72
+ rack-ssl (1.3.2)
73
+ rack
74
+ rack-test (0.6.1)
75
+ rack (>= 1.0)
76
+ rails (3.2.1)
77
+ actionmailer (= 3.2.1)
78
+ actionpack (= 3.2.1)
79
+ activerecord (= 3.2.1)
80
+ activeresource (= 3.2.1)
81
+ activesupport (= 3.2.1)
82
+ bundler (~> 1.0)
83
+ railties (= 3.2.1)
84
+ railties (3.2.1)
85
+ actionpack (= 3.2.1)
86
+ activesupport (= 3.2.1)
87
+ rack-ssl (~> 1.3.2)
88
+ rake (>= 0.8.7)
89
+ rdoc (~> 3.4)
90
+ thor (~> 0.14.6)
91
+ rake (10.0.3)
92
+ rdoc (3.12)
93
+ json (~> 1.4)
94
+ rspec (2.8.0)
95
+ rspec-core (~> 2.8.0)
96
+ rspec-expectations (~> 2.8.0)
97
+ rspec-mocks (~> 2.8.0)
98
+ rspec-core (2.8.0)
99
+ rspec-expectations (2.8.0)
100
+ diff-lcs (~> 1.1.2)
101
+ rspec-instafail (0.2.4)
102
+ rspec-mocks (2.8.0)
103
+ rspec-rails (2.8.1)
104
+ actionpack (>= 3.0)
105
+ activesupport (>= 3.0)
106
+ railties (>= 3.0)
107
+ rspec (~> 2.8.0)
108
+ ruby-progressbar (0.0.10)
109
+ sprockets (2.1.2)
110
+ hike (~> 1.2)
111
+ rack (~> 1.0)
112
+ tilt (~> 1.1, != 1.3.0)
113
+ thor (0.14.6)
114
+ tilt (1.3.3)
115
+ treetop (1.4.10)
116
+ polyglot
117
+ polyglot (>= 0.3.1)
118
+ tzinfo (0.3.35)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ bson_ext
125
+ bundler
126
+ database_cleaner
127
+ fuubar
128
+ jeweler (~> 1.8.4)
129
+ mongoid
130
+ mongoid-rspec
131
+ rails
132
+ rdoc (~> 3.12)
133
+ rspec (~> 2.8.0)
134
+ rspec-rails
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Daniel Schmidt
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,102 @@
1
+ ## Ketchup exception handling
2
+
3
+ Rails exception handling happens with ActionController extension and Mongoid support.
4
+
5
+ ## Install & Configuration
6
+
7
+ Add
8
+
9
+ ```ruby
10
+ gem "exception-ketchup"
11
+ ```
12
+
13
+ to your Gemfile.
14
+
15
+ Add a file to <code>Rails.root/initializers/</code>.
16
+
17
+ Configure <code>Ketchup::Exception</code>:
18
+
19
+ ```ruby
20
+
21
+ # Config Exception handling here.
22
+ Ketchup::Exception.setup do |config|
23
+ # A list email of addresses to which the exception notification should be mailed.
24
+ config.recipients = %W(daniel.schmidt@datenspiel.com lars.mueller@datenspiel.com)
25
+ # Subject to use for email.
26
+ config.subject = "Error happens at myovulasens"
27
+ # The path to the mail template
28
+ config.template_path = "notifications"
29
+ # The following are optional configurations
30
+ # Disables or enables delivering of exception messages. Defaults to true.
31
+ # config.deliver_mail = false
32
+ # Disables or enables persisting of exception messages. Defaults to true
33
+ # config.persist = false
34
+ # Define the collection name hwere to exception messages should be stored.
35
+ # Defaults to :errors
36
+ # config.exception_collection = :errors
37
+ # Define a Proc here that is responsible for logging messages.
38
+ # See exception-ketchup.rb for details about.
39
+ # config.log_error = lambda do |error|
40
+ # # do something with err.
41
+ # end
42
+ # The Rails env(s) to use. Optional for configuration, defaults to :production
43
+ # config.environment = [:production]
44
+ end
45
+ ```
46
+
47
+ ## Make it available
48
+
49
+ Add to your controller class:
50
+
51
+ ```ruby
52
+
53
+ class ApplicationController
54
+
55
+ ketchup_exceptions do |c|
56
+ c.rescue_errors = [
57
+ {:error => RestClient::ServerBrokeConnection, :with => :server_not_responding},
58
+ {:error => CanCan::AccessDenied, :with => :unauthorized,
59
+ :notify => false,
60
+ :remember => false,
61
+ :log => true}
62
+ ]
63
+ end
64
+
65
+ end
66
+
67
+ ```
68
+
69
+ <code>rescue_errors</code> - Configure which exceptions you want to treat in a special way by using the following options
70
+ * <code>error</code>: Class, mandatory.
71
+ Error-Class to handle
72
+ * <code>with</code>: Symbol|Proc.
73
+ Method to execute for individual error handling. This method should take
74
+ one argument which is the error that was raised.
75
+ If this is omitted, be sure to implement a <code>:respond_with_error</code> method.
76
+ * <code>remember</code>: Boolean, default: <code>true</code>
77
+ Wether or not write the error to the database
78
+ * <code>notify</code>: Boolean, default: <code>true</code>
79
+ Wether or not to send an email to the configured recipients
80
+ * <code>log</code>: Boolean, default: <code>true</code>
81
+ Wether or not to log the exception
82
+
83
+ **Note:**
84
+
85
+ If <code>config.deliver_mail</code> is set to false, <code>:notify</code> will be ignored.
86
+ If <code>config.persist</code> is set to false, <code>:remember</code> will be ignored.
87
+
88
+ ## Contributing to exception-ketchup
89
+
90
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
91
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
92
+ * Fork the project.
93
+ * Start a feature/bugfix branch.
94
+ * Commit and push until you are happy with your contribution.
95
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
96
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
97
+
98
+ == Copyright
99
+
100
+ Copyright (c) 2012 Daniel Schmidt. See LICENSE.txt for
101
+ further details.
102
+
data/README.rdoc ADDED
@@ -0,0 +1,102 @@
1
+ ## Ketchup exception handling
2
+
3
+ Rails exception handling happens with ActionController extension and Mongoid support.
4
+
5
+ ## Install & Configuration
6
+
7
+ Add
8
+
9
+ ```ruby
10
+ gem "exception-ketchup"
11
+ ```
12
+
13
+ to your Gemfile.
14
+
15
+ Add a file to <code>Rails.root/initializers/</code>.
16
+
17
+ Configure <code>Ketchup::Exception</code>:
18
+
19
+ ```ruby
20
+
21
+ # Config Exception handling here.
22
+ Ketchup::Exception.setup do |config|
23
+ # A list email of addresses to which the exception notification should be mailed.
24
+ config.recipients = %W(daniel.schmidt@datenspiel.com lars.mueller@datenspiel.com)
25
+ # Subject to use for email.
26
+ config.subject = "Error happens at myovulasens"
27
+ # The path to the mail template
28
+ config.template_path = "notifications"
29
+ # The following are optional configurations
30
+ # Disables or enables delivering of exception messages. Defaults to true.
31
+ # config.deliver_mail = false
32
+ # Disables or enables persisting of exception messages. Defaults to true
33
+ # config.persist = false
34
+ # Define the collection name hwere to exception messages should be stored.
35
+ # Defaults to :errors
36
+ # config.exception_collection = :errors
37
+ # Define a Proc here that is responsible for logging messages.
38
+ # See exception-ketchup.rb for details about.
39
+ # config.log_error = lambda do |error|
40
+ # # do something with err.
41
+ # end
42
+ # The Rails env(s) to use. Optional for configuration, defaults to :production
43
+ # config.environment = [:production]
44
+ end
45
+ ```
46
+
47
+ ## Make it available
48
+
49
+ Add to your controller class:
50
+
51
+ ```ruby
52
+
53
+ class ApplicationController
54
+
55
+ ketchup_exceptions do |c|
56
+ c.rescue_errors = [
57
+ {:error => RestClient::ServerBrokeConnection, :with => :server_not_responding},
58
+ {:error => CanCan::AccessDenied, :with => :unauthorized,
59
+ :notify => false,
60
+ :remember => false,
61
+ :log => true}
62
+ ]
63
+ end
64
+
65
+ end
66
+
67
+ ```
68
+
69
+ <code>rescue_errors</code> - Configure which exceptions you want to treat in a special way by using the following options
70
+ * <code>error</code>: Class, mandatory.
71
+ Error-Class to handle
72
+ * <code>with</code>: Symbol|Proc.
73
+ Method to execute for individual error handling. This method should take
74
+ one argument which is the error that was raised.
75
+ If this is omitted, be sure to implement a <code>:respond_with_error</code> method.
76
+ * <code>remember</code>: Boolean, default: <code>true</code>
77
+ Wether or not write the error to the database
78
+ * <code>notify</code>: Boolean, default: <code>true</code>
79
+ Wether or not to send an email to the configured recipients
80
+ * <code>log</code>: Boolean, default: <code>true</code>
81
+ Wether or not to log the exception
82
+
83
+ **Note:**
84
+
85
+ If <code>config.deliver_mail</code> is set to false, <code>:notify</code> will be ignored.
86
+ If <code>config.persist</code> is set to false, <code>:remember</code> will be ignored.
87
+
88
+ ## Contributing to exception-ketchup
89
+
90
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
91
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
92
+ * Fork the project.
93
+ * Start a feature/bugfix branch.
94
+ * Commit and push until you are happy with your contribution.
95
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
96
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
97
+
98
+ ## Copyright
99
+
100
+ Copyright (c) 2012 Datenspiel GmbH. Contributors Daniel Schmidt (@dsci), Lars Müller (@lmue)
101
+ See LICENSE.txt forfurther details.
102
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
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://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "exception-ketchup"
18
+ gem.homepage = "http://github.com/datenspiel/exception-ketchup"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails exception handling happens with ActionController extension and Mongoid support.}
21
+ gem.description = %Q{Rails exception handling happens with ActionController extension and Mongoid support.}
22
+ gem.email = "dsci@code79.net"
23
+ gem.authors = ["Daniel Schmidt", "Lars Müller"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "exception-ketchup #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,122 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "exception-ketchup"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Daniel Schmidt"]
12
+ s.date = "2013-01-04"
13
+ s.description = "TODO: longer description of your gem"
14
+ s.email = "dsci@code79.net"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/exception-ketchup.rb",
31
+ "lib/rails/controller.rb",
32
+ "lib/rails/error.rb",
33
+ "lib/rails/mailer.rb",
34
+ "lib/util/handler.rb",
35
+ "spec/dummy/README.rdoc",
36
+ "spec/dummy/Rakefile",
37
+ "spec/dummy/app/assets/javascripts/application.js",
38
+ "spec/dummy/app/assets/stylesheets/application.css",
39
+ "spec/dummy/app/controllers/application_controller.rb",
40
+ "spec/dummy/app/helpers/application_helper.rb",
41
+ "spec/dummy/app/mailers/.gitkeep",
42
+ "spec/dummy/app/models/.gitkeep",
43
+ "spec/dummy/app/views/layouts/application.html.erb",
44
+ "spec/dummy/app/views/notifications/exception.html.erb",
45
+ "spec/dummy/config.ru",
46
+ "spec/dummy/config/application.rb",
47
+ "spec/dummy/config/boot.rb",
48
+ "spec/dummy/config/environment.rb",
49
+ "spec/dummy/config/environments/development.rb",
50
+ "spec/dummy/config/environments/production.rb",
51
+ "spec/dummy/config/environments/test.rb",
52
+ "spec/dummy/config/i18n-js.yml",
53
+ "spec/dummy/config/initializers/backtrace_silencers.rb",
54
+ "spec/dummy/config/initializers/inflections.rb",
55
+ "spec/dummy/config/initializers/mime_types.rb",
56
+ "spec/dummy/config/initializers/secret_token.rb",
57
+ "spec/dummy/config/initializers/session_store.rb",
58
+ "spec/dummy/config/initializers/wrap_parameters.rb",
59
+ "spec/dummy/config/locales/en.yml",
60
+ "spec/dummy/config/mongoid.yml",
61
+ "spec/dummy/config/routes.rb",
62
+ "spec/dummy/lib/assets/.gitkeep",
63
+ "spec/dummy/public/404.html",
64
+ "spec/dummy/public/422.html",
65
+ "spec/dummy/public/500.html",
66
+ "spec/dummy/public/favicon.ico",
67
+ "spec/dummy/script/rails",
68
+ "spec/lib/controller_spec.rb",
69
+ "spec/lib/error_spec.rb",
70
+ "spec/lib/exception-ketchup_spec.rb",
71
+ "spec/lib/mailer_spec.rb",
72
+ "spec/spec_helper.rb"
73
+ ]
74
+ s.homepage = "http://github.com/datenspiel/exception-ketchup"
75
+ s.licenses = ["MIT"]
76
+ s.require_paths = ["lib"]
77
+ s.rubygems_version = "1.8.24"
78
+ s.summary = "TODO: one-line summary of your gem"
79
+
80
+ if s.respond_to? :specification_version then
81
+ s.specification_version = 3
82
+
83
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
84
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
85
+ s.add_runtime_dependency(%q<mongoid>, [">= 0"])
86
+ s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
87
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
88
+ s.add_development_dependency(%q<rspec-rails>, [">= 0"])
89
+ s.add_development_dependency(%q<mongoid-rspec>, [">= 0"])
90
+ s.add_development_dependency(%q<database_cleaner>, [">= 0"])
91
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
92
+ s.add_development_dependency(%q<bundler>, [">= 0"])
93
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
94
+ s.add_development_dependency(%q<fuubar>, [">= 0"])
95
+ else
96
+ s.add_dependency(%q<rails>, [">= 0"])
97
+ s.add_dependency(%q<mongoid>, [">= 0"])
98
+ s.add_dependency(%q<bson_ext>, [">= 0"])
99
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
100
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
101
+ s.add_dependency(%q<mongoid-rspec>, [">= 0"])
102
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
103
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
104
+ s.add_dependency(%q<bundler>, [">= 0"])
105
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
106
+ s.add_dependency(%q<fuubar>, [">= 0"])
107
+ end
108
+ else
109
+ s.add_dependency(%q<rails>, [">= 0"])
110
+ s.add_dependency(%q<mongoid>, [">= 0"])
111
+ s.add_dependency(%q<bson_ext>, [">= 0"])
112
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
113
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
114
+ s.add_dependency(%q<mongoid-rspec>, [">= 0"])
115
+ s.add_dependency(%q<database_cleaner>, [">= 0"])
116
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
117
+ s.add_dependency(%q<bundler>, [">= 0"])
118
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
119
+ s.add_dependency(%q<fuubar>, [">= 0"])
120
+ end
121
+ end
122
+
@@ -0,0 +1,118 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ %w(action_controller/railtie
5
+ action_mailer/railtie
6
+ mongoid).each { |library| require library }
7
+
8
+ require_relative 'util/handler'
9
+
10
+ # Exception handler for Ovulasens. It consists of a general
11
+ # configuration file, a Controller extension, a Mailer and
12
+ # MongoDB database Model.
13
+ #
14
+ # @author Daniel Schmidt
15
+ module Ketchup
16
+
17
+ module Exception
18
+
19
+ # Load handler to send mail or create database error entry.
20
+ autoload :Handler, 'util/handler'
21
+
22
+ # Setup ketchup. The config file should be in config/initializers.
23
+ def self.setup(&block)
24
+ yield(self)
25
+ end
26
+
27
+ @@sender = ""
28
+
29
+ # Enables or disables exception mailing. If mailing is disabled
30
+ # the :notify parameter in #rescue_errors will be ignored.
31
+ # Defaults to true (mailing is enabled.)
32
+ mattr_accessor :deliver_mail
33
+ @@deliver_mail = true
34
+
35
+ # Enables or disables persisting of errors. If persisting is disabled
36
+ # the :remember parameter in #rescue_errors will be ignored.
37
+ # Defaults to true (persisting is enabled.)
38
+ mattr_accessor :persist
39
+ @@persist = true
40
+
41
+ # The Rails env to use. Optional for configuration. Have to be symbols.
42
+ mattr_writer :environment
43
+ @@environment = [:production]
44
+
45
+ def self.environment
46
+ if @@environment.is_a?(Symbol) or @@environment.is_a?(String)
47
+ return [@@environment]
48
+ else
49
+ return @@environment
50
+ end
51
+ end
52
+
53
+ # A comma seperated list or an array of email
54
+ # addresses to which the exception notification
55
+ # should be mailed.
56
+ mattr_writer :recipients
57
+ @@recipients = []
58
+
59
+ # A comma seperated list or an array of email
60
+ # addresses to which the exception notification
61
+ # should be mailed.
62
+ def self.recipients
63
+ if @@deliver_mail
64
+ raise "[Ketchup] You have to provide at least one recipient!" if @@recipients.empty?
65
+ end
66
+ return @@recipients.join(",") if @@recipients.respond_to?(:join)
67
+ return @@recipients
68
+ end
69
+
70
+ # The senders address. Required for configuration
71
+ def self.sender=(sender)
72
+ @@sender = sender
73
+ end
74
+
75
+ def self.sender
76
+ if @@deliver_mail
77
+ STDOUT.write "[Ketchup] You have to provide a sender email." if @@sender.empty?
78
+ end
79
+ #return "hulla@hui.com"
80
+ return @@sender
81
+ end
82
+
83
+ # Define a log error proc. This method should take one argument which is
84
+ # the error that was raised.
85
+ mattr_accessor :log_error
86
+ @@log_error = lambda do |error|
87
+ Rails::logger.info("!!! CATCH ERROR: #{error.message}")
88
+ Rails::logger.info(error.backtrace.join("\n"))
89
+ end
90
+
91
+ # Subject to use for email.
92
+ mattr_accessor :subject
93
+ @@subject = ""
94
+
95
+ # The path to the mail template
96
+ mattr_accessor :template_path
97
+ @@template_path = ""
98
+
99
+ # The template name for OvuException::Ketchup::Mailer.
100
+ # Optional for configuration.
101
+ mattr_accessor :template_name
102
+ @@template_name = "exception"
103
+
104
+ # The collection the execption informations should be saved in
105
+ mattr_accessor :exception_collection
106
+ @@exception_collection = :errors
107
+
108
+ end
109
+ end
110
+
111
+ # require extensions.
112
+ require_relative "rails/error"
113
+ require_relative "rails/controller"
114
+ require_relative "rails/mailer.rb"
115
+
116
+ ActionController::Base.class_eval do
117
+ include Ketchup::Exception::Controller
118
+ end