exception_handler 0.6.5 → 0.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +33 -33
  3. data/.rspec +3 -3
  4. data/.travis.yml +5 -5
  5. data/Gemfile +13 -13
  6. data/LICENSE.txt +22 -22
  7. data/README.md +349 -341
  8. data/Rakefile +7 -7
  9. data/app/assets/images/{favicon.ico → exception_handler.ico} +0 -0
  10. data/app/assets/images/exception_handler/alert.jpg +0 -0
  11. data/app/assets/images/exception_handler/bg.jpg +0 -0
  12. data/app/assets/images/exception_handler/favicon.ico +0 -0
  13. data/app/assets/images/exception_handler/icon.png +0 -0
  14. data/app/assets/stylesheets/exception_handler.css.erb +8 -8
  15. data/app/assets/stylesheets/styles/_base.css.erb +35 -34
  16. data/app/assets/stylesheets/styles/_exception.css.erb +105 -103
  17. data/app/assets/stylesheets/styles/_footer.css.erb +24 -27
  18. data/app/assets/stylesheets/styles/_responsive.css +5 -5
  19. data/app/controllers/exception_handler/exception_controller.rb +45 -38
  20. data/app/mailers/exception_handler/exception_mailer.rb +16 -16
  21. data/app/models/exception_handler/exception.rb +191 -191
  22. data/app/views/exception_handler/exception/show.html.erb +1 -1
  23. data/app/views/exception_handler/mailers/new_exception.erb +4 -4
  24. data/app/views/layouts/exception.html.erb +27 -21
  25. data/config/locales/exception_handler.en.yml +13 -13
  26. data/exception_handler.gemspec +80 -84
  27. data/lib/exception_handler.rb +32 -29
  28. data/lib/exception_handler/config.rb +80 -66
  29. data/lib/exception_handler/engine.rb +44 -36
  30. data/lib/generators/exception_handler/migration_generator.rb +55 -55
  31. data/lib/generators/exception_handler/views_generator.rb +42 -42
  32. data/lib/generators/templates/migration.rb.erb +16 -16
  33. data/spec/database.yml +2 -2
  34. data/spec/dummy/Rakefile +6 -6
  35. data/spec/dummy/app/assets/config/manifest.js +4 -4
  36. data/spec/dummy/app/assets/javascripts/application.js +13 -13
  37. data/spec/dummy/app/assets/javascripts/cable.coffee +11 -11
  38. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  39. data/spec/dummy/app/channels/application_cable/channel.rb +5 -5
  40. data/spec/dummy/app/channels/application_cable/connection.rb +5 -5
  41. data/spec/dummy/app/controllers/application_controller.rb +5 -5
  42. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  43. data/spec/dummy/app/jobs/application_job.rb +2 -2
  44. data/spec/dummy/app/mailers/application_mailer.rb +4 -4
  45. data/spec/dummy/app/models/application_record.rb +3 -3
  46. data/spec/dummy/app/views/layouts/application.html.erb +15 -15
  47. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
  48. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
  49. data/spec/dummy/bin/bundle +3 -3
  50. data/spec/dummy/bin/rails +4 -4
  51. data/spec/dummy/bin/rake +4 -4
  52. data/spec/dummy/bin/setup +34 -34
  53. data/spec/dummy/bin/update +29 -29
  54. data/spec/dummy/config.ru +8 -8
  55. data/spec/dummy/config/application.rb +21 -21
  56. data/spec/dummy/config/boot.rb +5 -5
  57. data/spec/dummy/config/cable.yml +10 -10
  58. data/spec/dummy/config/database.yml +25 -25
  59. data/spec/dummy/config/environment.rb +5 -5
  60. data/spec/dummy/config/environments/development.rb +62 -62
  61. data/spec/dummy/config/environments/production.rb +87 -87
  62. data/spec/dummy/config/environments/test.rb +42 -42
  63. data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -6
  64. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -6
  65. data/spec/dummy/config/initializers/assets.rb +11 -11
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  67. data/spec/dummy/config/initializers/callback_terminator.rb +6 -6
  68. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
  69. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  70. data/spec/dummy/config/initializers/inflections.rb +16 -16
  71. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  72. data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +4 -4
  73. data/spec/dummy/config/initializers/request_forgery_protection.rb +4 -4
  74. data/spec/dummy/config/initializers/session_store.rb +3 -3
  75. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  76. data/spec/dummy/config/locales/en.yml +23 -23
  77. data/spec/dummy/config/puma.rb +47 -47
  78. data/spec/dummy/config/routes.rb +6 -6
  79. data/spec/dummy/config/secrets.yml +22 -22
  80. data/spec/dummy/public/404.html +67 -67
  81. data/spec/dummy/public/422.html +67 -67
  82. data/spec/dummy/public/500.html +66 -66
  83. data/spec/exception_handler.rb +21 -21
  84. data/spec/exception_handler/exception_controller_spec.rb +18 -0
  85. data/spec/spec_helper.rb +54 -54
  86. metadata +11 -8
@@ -1,13 +1,13 @@
1
- ##################################
2
- ##################################
3
- # Have to use strings rather than integers
4
- ##################################
5
- ##################################
6
-
7
- en:
8
- exception:
9
- not_found: "Page missing"
10
- internal_server_error: "<strong>Our server experienced an error. Our developers have been notified and are resolving it:</strong> %{message}"
11
-
12
- ##################################
13
- ##################################
1
+ ##################################
2
+ ##################################
3
+ # Have to use strings rather than integers
4
+ ##################################
5
+ ##################################
6
+
7
+ en:
8
+ exception:
9
+ not_found: "Page missing"
10
+ internal_server_error: "<strong>%{status} Error</strong> %{message} <p>Return home</p>"
11
+
12
+ ##################################
13
+ ##################################
@@ -1,84 +1,80 @@
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 = 6
14
- TINY = 5
15
- PRE = nil # "alpha"
16
-
17
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
- end
19
- end
20
-
21
- # => Declaration
22
- # => https://github.com/rails/rails/blob/master/rails.gemspec#L1
23
- version = ExceptionHandler::VERSION::STRING
24
-
25
- ##############################################################
26
- ##############################################################
27
-
28
- # => Gem
29
- Gem::Specification.new do |s|
30
-
31
- ##############################################################
32
-
33
- # => General
34
- s.platform = Gem::Platform::RUBY
35
- s.name = "exception_handler"
36
- s.version = version
37
-
38
- # => Author
39
- s.authors = ["Richard Peck"]
40
- s.email = ["rpeck@frontlineutilities.co.uk"]
41
-
42
- # => Details
43
- s.summary = %q{Rails gem to show custom error pages in production. Also logs errors in db & sends notification emails}
44
- 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.}
45
- s.homepage = "http://github.com/richpeck/exception_handler"
46
-
47
- # => License
48
- s.license = "MIT"
49
-
50
- ##############################################################
51
-
52
- # => Files
53
- # => Remove "readme" dir from gem
54
- s.files = `git ls-files -z`.split("\x0")
55
- s.files.reject! { |fn| fn.include? "readme" } #-> https://github.com/gauntlt/gauntlt/blob/master/gauntlt.gemspec#L16
56
-
57
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
58
- s.test_files = s.files.grep(%r{^(test|spec|features)/}) unless RUBY_VERSION >= "2.2.0" #-> deprecated in Ruby 2.2.0
59
- s.require_paths = ["lib"]
60
-
61
- ##############################################################
62
-
63
- # => Ruby
64
- s.required_ruby_version = ">= 2.1.0"
65
-
66
- # => Runtime
67
- s.add_dependency "bundler", "~> 1.6"
68
- s.add_dependency "rails", ">= 4.2.0"
69
- s.add_dependency "responders", "~> 2.3"
70
-
71
- # => Extras
72
- s.add_development_dependency "autoprefixer-rails"
73
-
74
- # => Dev
75
- # => For testing etc
76
- s.add_development_dependency "rake"
77
- s.add_development_dependency "rspec"
78
- s.add_development_dependency "rspec-rails"
79
- s.add_development_dependency "sqlite3", ">= 1.3.10"
80
-
81
- ##############################################################
82
- ##############################################################
83
-
84
- end
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 = 0
15
+ PRE = nil # "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", "~> 1.6"
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,29 +1,32 @@
1
- #########################################################
2
- #########################################################
3
-
4
- module ExceptionHandler
5
-
6
- # => Table Prefix
7
- # => Keeps Rails Engine from generating all table prefixes with the engines name
8
- # => http://stackoverflow.com/questions/19435214/rails-mountable-engine-with-isolate-namespace-but-without-prefixed-namespace-on
9
- def self.table_name_prefix
10
- # => No prefix
11
- end
12
-
13
- # => Config
14
- # => Invoke instance of config (ExceptionHandler.config)
15
- mattr_accessor :config
16
-
17
- end
18
-
19
- #########################################################
20
- #########################################################
21
-
22
- # => Libs
23
- # => http://stackoverflow.com/a/4528011/1143732
24
- # => http://stackoverflow.com/a/21693468/1143732
25
- # => https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb#L8
26
- Dir.glob(File.join(File.dirname(__FILE__), 'exception_handler', '**/*.rb'), &method(:require))
27
-
28
- #########################################################
29
- #########################################################
1
+ #########################################################
2
+ #########################################################
3
+
4
+ module ExceptionHandler
5
+
6
+ # => Table Prefix
7
+ # => Keeps Rails Engine from generating all table prefixes with the engines name
8
+ # => http://stackoverflow.com/questions/19435214/rails-mountable-engine-with-isolate-namespace-but-without-prefixed-namespace-on
9
+ def self.table_name_prefix
10
+ # => No prefix
11
+ end
12
+
13
+ # => Config
14
+ # => Invoke instance of config (ExceptionHandler.config)
15
+ mattr_accessor :config
16
+
17
+ end
18
+
19
+ #########################################################
20
+ #########################################################
21
+
22
+ # => Libs
23
+ # => http://stackoverflow.com/a/4528011/1143732
24
+ # => http://stackoverflow.com/a/21693468/1143732
25
+ # => https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb#L8
26
+ Dir.glob(File.join(File.dirname(__FILE__), 'exception_handler', '**/*.rb'), &method(:require))
27
+
28
+ # => External Dependencies
29
+ require 'responders'
30
+
31
+ #########################################################
32
+ #########################################################
@@ -1,66 +1,80 @@
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
- attr_accessor :dev, :db, :email, :social, :layouts
14
-
15
- ###########################################
16
-
17
- #Init
18
- def initialize values=nil
19
- defaults = values.present? ? Config::DEFAULTS.deep_merge!(values) : DEFAULTS
20
- defaults.each do |k,v|
21
- instance_variable_set("@#{k}",v) #-> http://apidock.com/ruby/Object/instance_variable_set
22
- end
23
-
24
- # => Errors
25
- raise(Exception, "ExceptionHandler :: Valid Email Required") if @email && !@email.is_a?(String)
26
- #raise(Exception, "ExceptionHandler :: Migration Required → Table \"#{db}\" doesn't exist") if @db && !ActiveRecord::Base.connection.table_exists?(db)
27
- end
28
-
29
- ###########################################
30
-
31
- # Public (Instance) Methods #
32
-
33
- #DB
34
- def db
35
- @db == true ? TABLE_NAME : @db
36
- end
37
-
38
- ###########################################
39
-
40
- #Default Table Name
41
- # Has to be "errors" because "exceptions" is a reserved word
42
- TABLE_NAME = :errors
43
-
44
- # Defaults
45
- # http://stackoverflow.com/a/8917301/1143732
46
- DEFAULTS = {
47
- dev: false, #-> defaults to "false" for dev mode
48
- db: false, #-> defaults to :errors if true, else use "table_name" / :table_name
49
- email: false, #-> requires string email and ActionMailer
50
- social: {
51
- facebook: { name: "frontline.utilities", url: "https://facebook.com" },
52
- twitter: { name: "frontlineutils", url: "http://twitter.com" },
53
- youtube: { name: "frontlineutils", url: "https://youtube.com/user" },
54
- linkedin: { name: "frontline-utilities", url: "https://linkedin.com/company" },
55
- fusion: { name: "flutils", url: "https://frontlinefusion.com" }
56
- },
57
- layouts: {
58
- "400" => nil, # => inherits from "ApplicationController" layout
59
- "500" => "exception"
60
- },
61
- }
62
-
63
- ###########################################
64
-
65
- end
66
- end
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
+ attr_accessor :dev, :db, :email, :social, :layouts
14
+
15
+ ###########################################
16
+ ###########################################
17
+
18
+ # Table Name
19
+ # Has to be "errors" because "exceptions" is a reserved word
20
+ TABLE = :errors
21
+
22
+ # Social URLs
23
+ # Extracted from "social" block
24
+ SOCIAL = {
25
+ facebook: "https://facebook.com",
26
+ twitter: "http://twitter.com",
27
+ youtube: "https://youtube.com/user",
28
+ linkedin: "https://linkedin.com/company",
29
+ fusion: "http://frontlinefusion.com"
30
+ }
31
+
32
+ ###########################################
33
+ ###########################################
34
+
35
+ # Defaults
36
+ # http://stackoverflow.com/a/8917301/1143732
37
+ DEFAULTS = {
38
+ dev: false, #-> defaults to "false" for dev mode
39
+ db: false, #-> defaults to :errors if true, else use "table_name" / :table_name
40
+ email: false, #-> requires string email and ActionMailer
41
+ social: {
42
+ facebook: nil,
43
+ twitter: nil,
44
+ youtube: nil,
45
+ linkedin: nil,
46
+ fusion: nil,
47
+ },
48
+ layouts: {
49
+ "400" => nil, # => inherits from "ApplicationController" layout
50
+ "500" => "exception"
51
+ },
52
+ }
53
+
54
+ ###########################################
55
+ ###########################################
56
+
57
+ #Init
58
+ def initialize values
59
+ # => Vars
60
+ DEFAULTS.deep_merge!(values || {}).each do |k,v|
61
+ instance_variable_set("@#{k}",v)
62
+ end
63
+
64
+ # => Errors
65
+ raise(Exception, "ExceptionHandler :: Valid Email Required") if @email && !@email.is_a?(String)
66
+ #raise(Exception, "ExceptionHandler :: Migration Required → Table \"#{db}\" doesn't exist") if @db && !ActiveRecord::Base.connection.table_exists?(db)
67
+ end
68
+
69
+ ###########################################
70
+ ###########################################
71
+
72
+ def db
73
+ @db == true ? TABLE : @db
74
+ end
75
+
76
+ ###########################################
77
+ ###########################################
78
+
79
+ end
80
+ end
@@ -1,36 +1,44 @@
1
- module ExceptionHandler
2
- class Engine < Rails::Engine
3
-
4
- #########################################################
5
- #########################################################
6
-
7
- # => Wraps helpers in ExceptionHandler module
8
- # => http://guides.rubyonrails.org/engines.html#inside-an-engine
9
- # => http://stackoverflow.com/questions/31877839/accessing-helpers-from-the-parent-app-in-an-isolated-rails-engine
10
- isolate_namespace ExceptionHandler
11
-
12
- # => Tests
13
- config.generators do |g|
14
- g.test_framework :rspec
15
- end
16
-
17
- # => Assets
18
- # => For Sprockets 4, had to include link_tree in exception_handler.css
19
- config.assets.precompile << %w(exception_handler.css)
20
-
21
- #########################################################
22
- #########################################################
23
-
24
- # => Hooks
25
- # => This should be config.before_initialize but because ActiveRecord is not initialized, cannot check for table
26
- initializer :exception_handler, before: "better_errors.configure_rails_initialization" do |app|
27
- ExceptionHandler.config ||= ExceptionHandler::Config.new config.try(:exception_handler) # => Vars
28
- app.config.exceptions_app = ->(env) { ExceptionHandler::ExceptionController.action(:show).call(env) } # => Rails
29
- app.config.consider_all_requests_local = false if Rails.env.development? && ExceptionHandler.config.try(:dev) # => Dev
30
- end
31
-
32
- #########################################################
33
- #########################################################
34
-
35
- end
36
- end
1
+ module ExceptionHandler
2
+ class Engine < Rails::Engine
3
+
4
+ # => Rails default MIME types:
5
+ # => http://apidock.com/rails/ActionController/MimeResponds/InstanceMethods/respond_to#14-Rails-defined-Mime-Types
6
+
7
+ #########################################################
8
+ #########################################################
9
+
10
+ # => Wraps helpers in ExceptionHandler module
11
+ # => http://guides.rubyonrails.org/engines.html#inside-an-engine
12
+ # => http://stackoverflow.com/questions/31877839/accessing-helpers-from-the-parent-app-in-an-isolated-rails-engine
13
+ isolate_namespace ExceptionHandler
14
+
15
+ # => Tests
16
+ config.generators do |g|
17
+ g.test_framework :rspec
18
+ end
19
+
20
+ # => Assets
21
+ # => For Sprockets 4, had to include link_tree in exception_handler.css
22
+ config.assets.precompile << %w(exception_handler.css)
23
+
24
+ #########################################################
25
+ #########################################################
26
+
27
+ # => Hooks
28
+ # => This should be config.before_initialize but because ActiveRecord is not initialized, cannot check for table
29
+ initializer :exception_handler, before: "better_errors.configure_rails_initialization" do |app|
30
+
31
+ # => Vars
32
+ ExceptionHandler.config ||= ExceptionHandler::Config.new config.try(:exception_handler)
33
+
34
+ # => Middleware
35
+ app.config.exceptions_app = ->(env) { ExceptionHandler::ExceptionController.action(:show).call(env) }
36
+ app.config.consider_all_requests_local = !ExceptionHandler.config.try(:dev) if Rails.env.development?
37
+
38
+ end
39
+
40
+ #########################################################
41
+ #########################################################
42
+
43
+ end
44
+ end