exception_handler 0.7.6.0 → 0.7.7.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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +40 -33
  3. data/.slugignore +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +13 -13
  6. data/README.md +436 -436
  7. data/Rakefile +7 -7
  8. data/app/assets/stylesheets/exception_handler.css.erb +18 -18
  9. data/app/assets/stylesheets/styles/_base.css.erb +35 -35
  10. data/app/assets/stylesheets/styles/_exception.css.erb +105 -105
  11. data/app/assets/stylesheets/styles/_footer.css.erb +24 -24
  12. data/app/assets/stylesheets/styles/_responsive.css +5 -5
  13. data/app/controllers/exception_handler/exceptions_controller.rb +59 -59
  14. data/app/mailers/exception_handler/exception_mailer.rb +17 -17
  15. data/app/models/exception_handler/exception.rb +199 -191
  16. data/app/views/exception_handler/exceptions/show.html.erb +3 -3
  17. data/app/views/exception_handler/mailers/layout.haml +8 -8
  18. data/app/views/exception_handler/mailers/layout.text.erb +1 -1
  19. data/app/views/exception_handler/mailers/new_exception.erb +4 -4
  20. data/app/views/layouts/exception.html.erb +27 -27
  21. data/config/locales/exception_handler.en.yml +28 -28
  22. data/db/migrate/000000_create_errors.rb +34 -34
  23. data/exception_handler.gemspec +62 -80
  24. data/lib/exception_handler.rb +55 -45
  25. data/lib/exception_handler/config.rb +116 -104
  26. data/lib/exception_handler/engine.rb +70 -61
  27. data/lib/exception_handler/version.rb +25 -0
  28. data/lib/generators/exception_handler/views_generator.rb +33 -33
  29. metadata +7 -71
  30. data/.gitattributes +0 -1
  31. data/.rspec +0 -4
  32. data/LICENSE.txt +0 -22
  33. data/spec/database.yml +0 -3
  34. data/spec/dummy/Rakefile +0 -6
  35. data/spec/dummy/app/assets/config/manifest.js +0 -4
  36. data/spec/dummy/app/assets/images/.keep +0 -0
  37. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  38. data/spec/dummy/app/assets/javascripts/cable.coffee +0 -11
  39. data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
  40. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  41. data/spec/dummy/app/channels/application_cable/channel.rb +0 -5
  42. data/spec/dummy/app/channels/application_cable/connection.rb +0 -5
  43. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  44. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  45. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  46. data/spec/dummy/app/jobs/application_job.rb +0 -2
  47. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  48. data/spec/dummy/app/models/application_record.rb +0 -3
  49. data/spec/dummy/app/models/concerns/.keep +0 -0
  50. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  51. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  52. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  53. data/spec/dummy/bin/bundle +0 -3
  54. data/spec/dummy/bin/rails +0 -4
  55. data/spec/dummy/bin/rake +0 -4
  56. data/spec/dummy/bin/setup +0 -34
  57. data/spec/dummy/bin/update +0 -29
  58. data/spec/dummy/config.ru +0 -8
  59. data/spec/dummy/config/application.rb +0 -21
  60. data/spec/dummy/config/boot.rb +0 -5
  61. data/spec/dummy/config/cable.yml +0 -10
  62. data/spec/dummy/config/database.yml +0 -25
  63. data/spec/dummy/config/environment.rb +0 -5
  64. data/spec/dummy/config/environments/development.rb +0 -62
  65. data/spec/dummy/config/environments/production.rb +0 -87
  66. data/spec/dummy/config/environments/test.rb +0 -42
  67. data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +0 -6
  68. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -6
  69. data/spec/dummy/config/initializers/assets.rb +0 -11
  70. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  71. data/spec/dummy/config/initializers/callback_terminator.rb +0 -6
  72. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  73. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  74. data/spec/dummy/config/initializers/inflections.rb +0 -16
  75. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  76. data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +0 -4
  77. data/spec/dummy/config/initializers/request_forgery_protection.rb +0 -4
  78. data/spec/dummy/config/initializers/session_store.rb +0 -3
  79. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  80. data/spec/dummy/config/locales/en.yml +0 -23
  81. data/spec/dummy/config/puma.rb +0 -47
  82. data/spec/dummy/config/routes.rb +0 -6
  83. data/spec/dummy/config/secrets.yml +0 -22
  84. data/spec/dummy/lib/assets/.keep +0 -0
  85. data/spec/dummy/log/.keep +0 -0
  86. data/spec/dummy/public/404.html +0 -67
  87. data/spec/dummy/public/422.html +0 -67
  88. data/spec/dummy/public/500.html +0 -66
  89. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  90. data/spec/dummy/public/apple-touch-icon.png +0 -0
  91. data/spec/dummy/public/favicon.ico +0 -0
  92. data/spec/exception_handler.rb +0 -22
  93. data/spec/exception_handler/exception_controller_spec.rb +0 -18
  94. data/spec/spec_helper.rb +0 -55
@@ -1,4 +1,4 @@
1
- <h1><%= Rails.application.class.parent_name %> (<%= Rails.env.titleize %>)</h1>
2
-
3
- <strong><u><%= @exception.response %> (<%= @exception.status %>)</u></strong>
4
- <p><%= @exception.message %></p>
1
+ <h1><%= Rails.application.class.parent_name %> (<%= Rails.env.titleize %>)</h1>
2
+
3
+ <strong><u><%= @exception.response %> (<%= @exception.status %>)</u></strong>
4
+ <p><%= @exception.message %></p>
@@ -1,27 +1,27 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <!-- Head -->
4
- <head>
5
- <!-- Info -->
6
- <%= content_tag :title, "Error - #{@exception.status} (#{@exception.response.to_s.gsub("_", " ").titleize}) | #{Rails.application.class.parent_name.titleize}" %>
7
-
8
- <!-- Styling -->
9
- <%= stylesheet_link_tag :exception_handler %>
10
- <%= favicon_link_tag "exception_handler/favicon.ico" %>
11
-
12
- <!-- Auth -->
13
- <%= csrf_meta_tags %>
14
- </head>
15
-
16
- <!-- Body -->
17
- <%= content_tag :body, yield %>
18
-
19
- <!-- Footer -->
20
- <% if ExceptionHandler.config.try(:social) %>
21
- <%= content_tag :footer do %>
22
- <% ExceptionHandler.config.social.each do |k,v| %>
23
- <%= link_to image_tag("exception_handler/connect/#{k}.png"), ExceptionHandler::Config::SOCIAL[k] + "/" + v, id: k, title: "#{k.to_s.titleize} Feed", target: :blank if v %>
24
- <% end %>
25
- <% end %>
26
- <% end %>
27
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <!-- Head -->
4
+ <head>
5
+ <!-- Info -->
6
+ <%= content_tag :title, "Error - #{@exception.status} (#{@exception.response.to_s.gsub("_", " ").titleize}) | #{Rails.application.class.parent_name.titleize}" %>
7
+
8
+ <!-- Styling -->
9
+ <%= stylesheet_link_tag :exception_handler %>
10
+ <%= favicon_link_tag "exception_handler/favicon.ico" %>
11
+
12
+ <!-- Auth -->
13
+ <%= csrf_meta_tags %>
14
+ </head>
15
+
16
+ <!-- Body -->
17
+ <%= content_tag :body, yield %>
18
+
19
+ <!-- Footer -->
20
+ <% if ExceptionHandler.config.try(:social) %>
21
+ <%= content_tag :footer do %>
22
+ <% ExceptionHandler.config.social.each do |k,v| %>
23
+ <%= link_to image_tag("exception_handler/connect/#{k}.png"), ExceptionHandler::Config::SOCIAL[k] + "/" + v, id: k, title: "#{k.to_s.titleize} Feed", target: :blank if v %>
24
+ <% end %>
25
+ <% end %>
26
+ <% end %>
27
+ </html>
@@ -1,28 +1,28 @@
1
- #######################################################################################
2
- #######################################################################################
3
- ## _____ _ _ _ _ _ _ ##
4
- ## | ___| | | (_) | | | | | | | ##
5
- ## | |____ _____ ___ _ __ | |_ _ ___ _ __ | |_| | __ _ _ __ __| | | ___ _ __ ##
6
- ## | __\ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \ | _ |/ _` | '_ \ / _` | |/ _ \ '__| ##
7
- ## | |___> < (_| __/ |_) | |_| | (_) | | | | | | | | (_| | | | | (_| | | __/ | ##
8
- ## \____/_/\_\___\___| .__/ \__|_|\___/|_| |_| \_| |_/\__,_|_| |_|\__,_|_|\___|_| ##
9
- ## | | ##
10
- ## |_| ##
11
- #######################################################################################
12
- #######################################################################################
13
-
14
- # Have to use strings rather than integers
15
- # https://github.com/rack/rack/blob/1.5.2/lib/rack/utils.rb#L544
16
-
17
- # By default, exceptions will show their "response" code (404 = "Not Found")
18
- # If you want to create custom messages, you have to assign the values as [response]: "message"
19
-
20
- #######################################################################################
21
- #######################################################################################
22
-
23
- en:
24
- exception_handler:
25
- internal_server_error: "<strong>%{status} Error</strong> %{message} <p>Return home</p>"
26
-
27
- #######################################################################################
28
- #######################################################################################
1
+ #######################################################################################
2
+ #######################################################################################
3
+ ## _____ _ _ _ _ _ _ ##
4
+ ## | ___| | | (_) | | | | | | | ##
5
+ ## | |____ _____ ___ _ __ | |_ _ ___ _ __ | |_| | __ _ _ __ __| | | ___ _ __ ##
6
+ ## | __\ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \ | _ |/ _` | '_ \ / _` | |/ _ \ '__| ##
7
+ ## | |___> < (_| __/ |_) | |_| | (_) | | | | | | | | (_| | | | | (_| | | __/ | ##
8
+ ## \____/_/\_\___\___| .__/ \__|_|\___/|_| |_| \_| |_/\__,_|_| |_|\__,_|_|\___|_| ##
9
+ ## | | ##
10
+ ## |_| ##
11
+ #######################################################################################
12
+ #######################################################################################
13
+
14
+ # Have to use strings rather than integers
15
+ # https://github.com/rack/rack/blob/1.5.2/lib/rack/utils.rb#L544
16
+
17
+ # By default, exceptions will show their "response" code (404 = "Not Found")
18
+ # If you want to create custom messages, you have to assign the values as [response]: "message"
19
+
20
+ #######################################################################################
21
+ #######################################################################################
22
+
23
+ en:
24
+ exception_handler:
25
+ internal_server_error: "<strong>%{status} Error</strong> %{message} <p>Return home</p>"
26
+
27
+ #######################################################################################
28
+ #######################################################################################
@@ -1,34 +1,34 @@
1
- class CreateErrors < ActiveRecord::Migration[5.0]
2
-
3
- # => ATTRS
4
- require_relative "../../app/models/exception_handler/exception.rb"
5
-
6
- #########################################
7
- #########################################
8
-
9
- # => Defs
10
- @@table = ExceptionHandler.config.try(:db)
11
-
12
- #########################################
13
-
14
- # Up
15
- def up
16
- create_table @@table do |t|
17
- ExceptionHandler::ATTRS.each do |attr|
18
- t.text attr
19
- end
20
- t.timestamps
21
- end
22
- end
23
-
24
- #########################################
25
-
26
- # Down
27
- def down
28
- drop_table @@table, if_exists: true
29
- end
30
-
31
- #########################################
32
- #########################################
33
-
34
- end
1
+ class CreateErrors < ActiveRecord::Migration[5.0]
2
+
3
+ # => ATTRS
4
+ require_relative "../../app/models/exception_handler/exception.rb"
5
+
6
+ #########################################
7
+ #########################################
8
+
9
+ # => Defs
10
+ @@table = ExceptionHandler.config.try(:db)
11
+
12
+ #########################################
13
+
14
+ # Up
15
+ def up
16
+ create_table @@table do |t|
17
+ ExceptionHandler::ATTRS.each do |attr|
18
+ t.text attr
19
+ end
20
+ t.timestamps
21
+ end
22
+ end
23
+
24
+ #########################################
25
+
26
+ # Down
27
+ def down
28
+ drop_table @@table, if_exists: true
29
+ end
30
+
31
+ #########################################
32
+ #########################################
33
+
34
+ end
@@ -1,80 +1,62 @@
1
- # Dependencies
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- ##############################################################
6
- ##############################################################
7
-
8
- # => Version
9
- # => https://github.com/rails/rails/blob/master/version.rb
10
- module ExceptionHandler
11
- module VERSION
12
- MAJOR = 0
13
- MINOR = 7
14
- TINY = 6
15
- PRE = 0 # "alpha"
16
-
17
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
- end
19
- end
20
-
21
- ##############################################################
22
- ##############################################################
23
-
24
- # => Gem
25
- Gem::Specification.new do |s|
26
-
27
- ##############################################################
28
-
29
- # => General
30
- s.platform = Gem::Platform::RUBY
31
- s.name = "exception_handler"
32
- s.version = ExceptionHandler::VERSION::STRING
33
-
34
- # => Author
35
- s.authors = ["Richard Peck"]
36
- s.email = ["rpeck@frontlineutilities.co.uk"]
37
-
38
- # => Details
39
- s.summary = %q{Rails gem to show custom error pages in production. Also logs errors in db & sends notification emails}
40
- s.description = %q{Rails gem to create custom error pages. Captures exceptions using "exception_app" callback, routing to "Exception" controller, rendering the view as required.}
41
- s.homepage = "http://github.com/richpeck/exception_handler"
42
-
43
- # => License
44
- s.license = "MIT"
45
-
46
- ##############################################################
47
-
48
- # => Files
49
- # => Remove "readme" dir from gem
50
- s.files = `git ls-files -z`.split("\x0")
51
- s.files.reject! { |fn| fn.include? "readme" } #-> https://github.com/gauntlt/gauntlt/blob/master/gauntlt.gemspec#L16
52
-
53
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
54
- s.test_files = s.files.grep(%r{^(test|spec|features)/}) unless RUBY_VERSION >= "2.2.0" #-> deprecated in Ruby 2.2.0
55
- s.require_paths = ["lib"]
56
-
57
- ##############################################################
58
-
59
- # => Ruby
60
- s.required_ruby_version = ">= 2.1.0"
61
-
62
- # => Runtime
63
- s.add_dependency "bundler"
64
- s.add_dependency "rails", ">= 4.2.0"
65
- s.add_dependency "responders"
66
-
67
- # => Extras
68
- s.add_development_dependency "autoprefixer-rails"
69
-
70
- # => Dev
71
- # => For testing etc
72
- s.add_development_dependency "rake"
73
- s.add_development_dependency "rspec"
74
- s.add_development_dependency "rspec-rails"
75
- s.add_development_dependency "sqlite3", ">= 1.3.10"
76
-
77
- ##############################################################
78
- ##############################################################
79
-
80
- end
1
+ ########################################################################################
2
+ ########################################################################################
3
+
4
+ # => Version
5
+ require_relative 'lib/exception_handler/version'
6
+
7
+ ##############################################################
8
+ ##############################################################
9
+
10
+ ## Specs ##
11
+ Gem::Specification.new do |s|
12
+
13
+ ## General ##
14
+ s.name = "exception_handler"
15
+ s.authors = ["R.Peck"]
16
+ s.email = ["rpeck@fl.co.uk"]
17
+ s.version = ExceptionHandler::VERSION::STRING
18
+ s.platform = Gem::Platform::RUBY
19
+
20
+ ## Details ##
21
+ s.summary = %q{Rails gem to show custom error pages in production. Also logs errors in db & sends notification emails}
22
+ s.description = %q{Rails gem to create custom error pages. Captures exceptions using "exception_app" callback, routing to "Exception" controller, rendering the view as required.}
23
+ s.homepage = "https://github.com/richpeck/exception_handler"
24
+
25
+ ## License ##
26
+ s.license = "MIT"
27
+
28
+ ##############################################################
29
+ ##############################################################
30
+
31
+ ## Files ##
32
+ s.files = `git ls-files -z`.split("\x0")
33
+ s.files.reject! { |fn| fn.include? "readme" } #-> https://github.com/gauntlt/gauntlt/blob/master/gauntlt.gemspec#L16
34
+
35
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
36
+ s.test_files = s.files.grep(%r{^(test|spec|features)/}) unless RUBY_VERSION >= "2.2.0" #-> deprecated in Ruby 2.2.0
37
+ s.require_paths = ["lib"]
38
+
39
+ ##############################################################
40
+ ##############################################################
41
+
42
+ ## Ruby ##
43
+ s.required_ruby_version = ">= 2.1.0"
44
+
45
+ ## Runtime
46
+ s.add_dependency "bundler"
47
+ s.add_dependency "rails", ">= 4.2.0"
48
+ s.add_dependency "responders"
49
+
50
+ ## Extras ##
51
+ s.add_development_dependency "autoprefixer-rails"
52
+
53
+ ## Dev ##
54
+ s.add_development_dependency "rake"
55
+ s.add_development_dependency "rspec"
56
+ s.add_development_dependency "rspec-rails"
57
+ s.add_development_dependency "sqlite3", ">= 1.3.10"
58
+
59
+ ##############################################################
60
+ ##############################################################
61
+
62
+ end
@@ -1,45 +1,55 @@
1
- #########################################################
2
- #########################################################
3
-
4
- module ExceptionHandler
5
-
6
- ##############################
7
- ##############################
8
-
9
- # => Table Prefix
10
- # => Keeps Rails Engine from generating all table prefixes with the engines name
11
- # => http://stackoverflow.com/questions/19435214/rails-mountable-engine-with-isolate-namespace-but-without-prefixed-namespace-on
12
- def self.table_name_prefix
13
- # => No prefix
14
- end
15
-
16
- # => Config
17
- # => Invoke instance of config (ExceptionHandler.config)
18
- mattr_accessor :config
19
-
20
- ##############################
21
- ##############################
22
-
23
- # => Exceptions
24
- # => https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/errors.rb
25
- class Error < StandardError; end
26
-
27
- ##############################
28
- ##############################
29
-
30
- end
31
-
32
- #########################################################
33
- #########################################################
34
-
35
- # => Libs
36
- # => http://stackoverflow.com/a/4528011/1143732
37
- # => http://stackoverflow.com/a/21693468/1143732
38
- # => https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb#L8
39
- Dir.glob(File.join(File.dirname(__FILE__), 'exception_handler', '**/*.rb'), &method(:require))
40
-
41
- # => External Dependencies
42
- require 'responders'
43
-
44
- #########################################################
45
- #########################################################
1
+ ########################################################################################
2
+ ########################################################################################
3
+ ## _____ _ _ _ _ _ _ ##
4
+ ## | ___| | | (_) | | | | | | | ##
5
+ ## | |____ _____ ___ _ __ | |_ _ ___ _ __ | |_| | __ _ _ __ __| | | ___ _ __ ##
6
+ ## | __\ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \ | _ |/ _` | '_ \ / _` | |/ _ \ '__| ##
7
+ ## | |___> < (_| __/ |_) | |_| | (_) | | | | | | | | (_| | | | | (_| | | __/ | ##
8
+ ## \____/_/\_\___\___| .__/ \__|_|\___/|_| |_| \_| |_/\__,_|_| |_|\__,_|_|\___|_| ##
9
+ ## | | ##
10
+ ## |_| ##
11
+ ########################################################################################
12
+ ########################################################################################
13
+
14
+ module ExceptionHandler
15
+
16
+ ##############################
17
+ ##############################
18
+
19
+ # => Table Prefix
20
+ # => Keeps Rails Engine from generating all table prefixes with the engines name
21
+ # => http://stackoverflow.com/questions/19435214/rails-mountable-engine-with-isolate-namespace-but-without-prefixed-namespace-on
22
+ def self.table_name_prefix
23
+ # => No prefix
24
+ end
25
+
26
+ # => Config
27
+ # => Invoke instance of config (ExceptionHandler.config)
28
+ mattr_accessor :config
29
+
30
+ ##############################
31
+ ##############################
32
+
33
+ # => Exceptions
34
+ # => https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/errors.rb
35
+ class Error < StandardError; end
36
+
37
+ ##############################
38
+ ##############################
39
+
40
+ end
41
+
42
+ #########################################################
43
+ #########################################################
44
+
45
+ # => Libs
46
+ # => http://stackoverflow.com/a/4528011/1143732
47
+ # => http://stackoverflow.com/a/21693468/1143732
48
+ # => https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb#L8
49
+ Dir.glob(File.join(File.dirname(__FILE__), 'exception_handler', '**/*.rb'), &method(:require))
50
+
51
+ # => External Dependencies
52
+ require 'responders'
53
+
54
+ #########################################################
55
+ #########################################################
@@ -1,104 +1,116 @@
1
- ###########################################
2
-
3
- # Refs
4
- # http://stackoverflow.com/questions/10584638/setting-up-configuration-settings-when-writing-a-gem
5
- # http://robots.thoughtbot.com/mygem-configure-block
6
-
7
- ###########################################
8
-
9
- module ExceptionHandler
10
- class Config
11
-
12
- # => Instace Objects
13
- # => ExceptionHandler.config.dev
14
- # => ExceptionHandler.config.db
15
- # => ExceptionHandler.config.email
16
- # => ExceptionHandler.config.social
17
- # => ExceptionHandler.config.layouts
18
- # => ExceptionHandler.config.custom_exceptions
19
- attr_accessor :dev, :db, :email, :social, :layouts, :custom_exceptions
20
-
21
- ###########################################
22
- ###########################################
23
- ###########################################
24
- ###########################################
25
-
26
- # => Table Name
27
- # => Has to be "errors" because "exceptions" is a reserved word
28
- TABLE = :errors
29
-
30
- # => Social URLs
31
- # => Extracted from "social" block
32
- SOCIAL = {
33
- facebook: "https://facebook.com",
34
- twitter: "https://twitter.com",
35
- youtube: "https://youtube.com/user",
36
- linkedin: "https://linkedin.com/company",
37
- fusion: "https://frontlinefusion.com"
38
- }
39
-
40
- ###########################################
41
- ###########################################
42
-
43
- # => Defaults
44
- # => http://stackoverflow.com/a/8917301/1143732
45
- DEFAULTS = {
46
- dev: nil, # => defaults to "false" for dev mode
47
- db: nil, # => defaults to :errors if true, else use "table_name" / :table_name
48
- email: nil, # => requires string email and ActionMailer
49
- social: {
50
- facebook: nil,
51
- twitter: nil,
52
- youtube: nil,
53
- linkedin: nil,
54
- fusion: nil,
55
- },
56
- layouts: {
57
- # => nil inherits from ApplicationController
58
- # => 4xx errors should be nil
59
- # => 5xx errors should be "exception" but can be nil if explicitly defined
60
- 500 => "exception",
61
- 501 => "exception",
62
- 502 => "exception",
63
- 503 => "exception",
64
- 504 => "exception",
65
- 505 => "exception",
66
- 507 => "exception",
67
- 510 => "exception"
68
- }
69
- }
70
-
71
- ###########################################
72
- ###########################################
73
-
74
- # => Init
75
- # => Merges DEFAULTS to values, creates instances vars (for attr_accessor)
76
- def initialize values
77
-
78
- # => Vars
79
- DEFAULTS.deep_merge!(values || {}).each do |k,v|
80
- instance_variable_set("@#{k}",v)
81
- end
82
-
83
- # => Validation
84
- raise ExceptionHandler::Error, "Email Not Valid" if @email && !@email.nil? && !@email.is_a?(String)
85
- raise ExceptionHandler::Error, "Migration Required → \"#{db}\" doesn't exist" if @db && !ActiveRecord::Base.connection.table_exists?(db) && (File.basename($0) != "rake" && !ARGV.include?("db:migrate"))
86
-
87
- end
88
-
89
- ###########################################
90
- ###########################################
91
-
92
- # => DB
93
- # => If config db = "true", use TABLE constant
94
- def db
95
- @db == true ? TABLE : @db.try(:parameterize, separator: "_")
96
- end
97
-
98
- ###########################################
99
- ###########################################
100
- ###########################################
101
- ###########################################
102
-
103
- end
104
- end
1
+ ###########################################
2
+ ###########################################
3
+ ## _____ __ _ ##
4
+ ## / __ \ / _(_) ##
5
+ ## | / \/ ___ _ __ | |_ _ __ _ ##
6
+ ## | | / _ \| '_ \| _| |/ _` | ##
7
+ ## | \__/\ (_) | | | | | | | (_| | ##
8
+ ## \____/\___/|_| |_|_| |_|\__, | ##
9
+ ## __/ | ##
10
+ ## |___/ ##
11
+ ###########################################
12
+ ###########################################
13
+
14
+ # Refs
15
+ # http://stackoverflow.com/questions/10584638/setting-up-configuration-settings-when-writing-a-gem
16
+ # http://robots.thoughtbot.com/mygem-configure-block
17
+
18
+ ###########################################
19
+ ###########################################
20
+
21
+ module ExceptionHandler
22
+ class Config
23
+
24
+ # => Instace Objects
25
+ # => ExceptionHandler.config.dev
26
+ # => ExceptionHandler.config.db
27
+ # => ExceptionHandler.config.email
28
+ # => ExceptionHandler.config.social
29
+ # => ExceptionHandler.config.layouts
30
+ # => ExceptionHandler.config.custom_exceptions
31
+ attr_accessor :dev, :db, :email, :social, :layouts, :custom_exceptions
32
+
33
+ ###########################################
34
+ ###########################################
35
+ ###########################################
36
+ ###########################################
37
+
38
+ # => Table Name
39
+ # => Has to be "errors" because "exceptions" is a reserved word
40
+ TABLE = :errors
41
+
42
+ # => Social URLs
43
+ # => Extracted from "social" block
44
+ SOCIAL = {
45
+ facebook: "https://facebook.com",
46
+ twitter: "https://twitter.com",
47
+ youtube: "https://youtube.com/user",
48
+ linkedin: "https://linkedin.com/company",
49
+ fusion: "https://frontlinefusion.com"
50
+ }
51
+
52
+ ###########################################
53
+ ###########################################
54
+
55
+ # => Defaults
56
+ # => http://stackoverflow.com/a/8917301/1143732
57
+ DEFAULTS = {
58
+ dev: nil, # => defaults to "false" for dev mode
59
+ db: nil, # => defaults to :errors if true, else use "table_name" / :table_name
60
+ email: nil, # => requires string email and ActionMailer
61
+ social: {
62
+ facebook: nil,
63
+ twitter: nil,
64
+ youtube: nil,
65
+ linkedin: nil,
66
+ fusion: nil,
67
+ },
68
+ layouts: {
69
+ # => nil inherits from ApplicationController
70
+ # => 4xx errors should be nil
71
+ # => 5xx errors should be "exception" but can be nil if explicitly defined
72
+ 500 => "exception",
73
+ 501 => "exception",
74
+ 502 => "exception",
75
+ 503 => "exception",
76
+ 504 => "exception",
77
+ 505 => "exception",
78
+ 507 => "exception",
79
+ 510 => "exception"
80
+ }
81
+ }
82
+
83
+ ###########################################
84
+ ###########################################
85
+
86
+ # => Init
87
+ # => Merges DEFAULTS to values, creates instances vars (for attr_accessor)
88
+ def initialize values
89
+
90
+ # => Vars
91
+ DEFAULTS.deep_merge!(values || {}).each do |k,v|
92
+ instance_variable_set("@#{k}",v)
93
+ end
94
+
95
+ # => Validation
96
+ raise ExceptionHandler::Error, "Email Not Valid" if @email && !@email.nil? && !@email.is_a?(String)
97
+ raise ExceptionHandler::Error, "Migration Required → \"#{db}\" doesn't exist" if @db && !ActiveRecord::Base.connection.table_exists?(db) && (File.basename($0) != "rake" && !ARGV.include?("db:migrate"))
98
+
99
+ end
100
+
101
+ ###########################################
102
+ ###########################################
103
+
104
+ # => DB
105
+ # => If config db = "true", use TABLE constant
106
+ def db
107
+ @db == true ? TABLE : @db.try(:parameterize, separator: "_")
108
+ end
109
+
110
+ ###########################################
111
+ ###########################################
112
+ ###########################################
113
+ ###########################################
114
+
115
+ end
116
+ end