exception_handler 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b14313cb847dd5ad1e6f11c110439c3f9f02891
4
- data.tar.gz: d481b5a7a526fbdffe2a8bd71379a5362e6414c5
3
+ metadata.gz: 9910d9ea8a74498ce664a912a9615bed8e8c9ce1
4
+ data.tar.gz: 20e2b4badb0d3bab269375565f0b8e7141c9bca6
5
5
  SHA512:
6
- metadata.gz: fe3128237d98b4c903a96a04a44e6bf313f3861e3ab859b6be2d623dbb3a20862a4479dd3a25270038f62efd501612283158fb2af82e0134840dbc94ec3e7fbb
7
- data.tar.gz: 4ce1ea49e147e2f2a423ce041decfa4f99d4acfa024d2e176f01bd958be54cc515b7b24c8ac69c77bbf502ec20f281bb74607aea00fff1b7c759379ec031efd4
6
+ metadata.gz: a2be4863eb8b102b2ecd78bd9d8895d08f2b276b31b7ecc9e497c76a7f1594efe1a5ddda192851b7a47173fca23137a3a786b0d376dcceed050d65693fdac6f0
7
+ data.tar.gz: f75a584b9264900b20d8af0f495318ca9a17db5c6b773526396838bad23898f4a4ec7de8902f22f3cd25c6dc874428040021d93433af6061ebbd542458b8f2ab
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ExceptionHandler
1
+ # [![Exception Handler](https://raw.githubusercontent.com/richpeck/exception_handler/master/readme/exception_handler.png "Exception Handler Logo")](http://frontlineutilities.co.uk/ruby-on-rails/exception-handler)
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/exception_handler.svg)](http://badge.fury.io/rb/exception_handler)
4
4
  [![Code Climate](https://codeclimate.com/github/richpeck/exception_handler.png)](https://codeclimate.com/github/richpeck/exception_handler)
@@ -6,14 +6,13 @@
6
6
  [![Coverage Status](https://coveralls.io/repos/richpeck/exception_handler/badge.png)](https://coveralls.io/r/richpeck/exception_handler)
7
7
  [![Build Status](https://travis-ci.org/richpeck/exception_handler.svg?branch=master)](https://travis-ci.org/richpeck/exception_handler)
8
8
 
9
- **ExceptionHandler** Rails Gem (adapted from [this tutorial](https://gist.github.com/wojtha/8433843))
10
9
 
11
- > - **[Custom Error Pages](#custom-error-pages)**
12
- > - **[Save Errors To DB](#save-errors-to-db)**
10
+ [**ExceptionHandler** Rails Gem](https://rubygems.org/gems/exception_handler) (adapted from [this tutorial](https://gist.github.com/wojtha/8433843) & our own middleware)
13
11
 
14
12
  Works with the [`config.exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration) hook in Rails' middleware stack:
15
13
 
16
- ```config.exceptions_app sets the exceptions application invoked by the ShowException middleware when an exception happens. Defaults to ActionDispatch::PublicExceptions.new(Rails.public_path).```
14
+ config.exceptions_app sets the exceptions application invoked by the ShowExceptionmiddleware
15
+ when an exception happens. Defaults to ActionDispatch::PublicExceptions.new(Rails.public_path).
17
16
 
18
17
  -----------
19
18
 
@@ -5,7 +5,7 @@ module ExceptionHandler
5
5
  respond_to :html, :xml, :json
6
6
 
7
7
  #Dependencies
8
- before_action :status
8
+ before_action :status, :app_name
9
9
 
10
10
  #Layout
11
11
  layout :layout_status
@@ -51,7 +51,12 @@ module ExceptionHandler
51
51
 
52
52
  #Layout
53
53
  def layout_status
54
- @status.to_s == "404" ? "application" : "error"
54
+ "error" if @status.to_s != "404"
55
+ end
56
+
57
+ #App
58
+ def app_name
59
+ @app_name = Rails.application.class.parent_name
55
60
  end
56
61
 
57
62
  end
@@ -1,7 +1,15 @@
1
- .box
2
- %h1
3
- = details[:name]
4
- %p
5
- = details[:message]
1
+ .error
2
+ /Alert
3
+ = image_tag 'exception_handler/alert.png', width: "150", alt: "Error!", title: "Sorry, A Server Error Occurred", class: "alert"
6
4
 
7
- = ExceptionHandler.config.db
5
+ /Message
6
+ .message
7
+ %strong
8
+ = details[:name]
9
+ %span
10
+ = details[:message]
11
+
12
+ /Contact
13
+ .contact
14
+ - ExceptionHandler.config.social.each do |item, address|
15
+ %a{ href: address }> #{image_tag "exception_handler/contact/#{item}.png", title: item.to_s.titleize}
@@ -3,7 +3,8 @@
3
3
  %head
4
4
 
5
5
  /Info
6
- = meta_tags
6
+ %title
7
+ = "Error :: #{@app_name}"
7
8
 
8
9
  /Styling
9
10
  :sass
@@ -18,36 +19,45 @@
18
19
  .error_container
19
20
  display: block
20
21
  margin: auto
21
- margin: 10% auto 0 auto
22
+ margin: 15% auto 0 auto
22
23
  width: 40%
23
24
 
24
25
  .error_container .error
25
26
  display: block
26
27
  text-align: center
27
28
 
28
- .error_container .error img
29
+ .error_container .error img.icon
29
30
  display: block
30
- margin: 0 auto 15px auto
31
+ margin: 0 auto 25px auto
31
32
 
32
33
  .error_container .message > *
33
34
  display: block
34
35
 
35
36
  .error_container .message strong
36
- font-weight: bold
37
+ font:
38
+ weight: bold
39
+ size: 1.5em
37
40
  color: #f00
41
+ margin: 15px 0 0
42
+
43
+ .error_container .message span
44
+ margin: 5px auto 0
45
+ font:
46
+ size: 0.75em
47
+ color: #606060
38
48
 
39
- .error_container .contact_info
49
+ .error_container .contact
40
50
  display: block
41
51
  text-align: center
42
- margin: 25px 0 0 0
52
+ margin: 20px 0 0 0
43
53
 
44
- .error_container .contact_info a
54
+ .error_container .contact a
45
55
  display: inline-block
46
- margin: 0
56
+ margin: 0 1px
47
57
  opacity: 0.4
48
58
  transition: opacity 0.15s ease
49
59
 
50
- .error_container .contact_info a:hover
60
+ .error_container .contact a:hover
51
61
  opacity: 0.8
52
62
 
53
63
 
@@ -16,20 +16,24 @@ module ExceptionHandler
16
16
  #Exception Handler
17
17
  class Exceptions < Rails::Engine
18
18
  initializer "exception_handler.configure_rails_initialization" do |app|
19
- app.config.middleware.use "ExceptionHandler::Message" #Parser
19
+ app.config.middleware.use "ExceptionHandler::Message" unless ExceptionHandler.config.db == false #Parser
20
20
  app.config.exceptions_app = ->(env) { ExceptionHandler::ExceptionController.action(:show).call(env) } #Pages
21
21
  end
22
22
  end
23
23
 
24
- #Config
24
+ ####################
25
+ # Config #
26
+ ####################
27
+
25
28
  #Ref http://robots.thoughtbot.com/mygem-configure-block
26
- mattr_accessor :config
29
+ mattr_accessor :config, :table
27
30
 
28
- #Init Config
31
+ #Vars
29
32
  @@config ||= Config.new
30
33
 
31
34
  #Block (for initializer)
32
35
  def self.setup
33
36
  yield(config) if block_given?
34
37
  end
38
+
35
39
  end
@@ -5,10 +5,17 @@
5
5
  ###########################################
6
6
  module ExceptionHandler
7
7
  class Config
8
- attr_accessor :db
8
+ attr_accessor :db, :social
9
9
 
10
- def initialize
11
- @db = false # -> db name (false = no; true = "errors"; [value] = [value])
10
+ def initialize
11
+ @db = false # -> db name (false = no; true = "errors"; [value] = [value])
12
+ @social = {
13
+ twitter: "http://twitter.com/frontlineutils",
14
+ facebook: "https://facebook.com/frontline.utilities",
15
+ linkedin: "https://linkedin.com/company/frontline-utilities",
16
+ youtube: "http://youtube.com/frontlineutils",
17
+ fusion: "http://frontlinefusion.com/frontlineutils"
18
+ }
12
19
  end
13
20
  end
14
21
  end
@@ -1,3 +1,3 @@
1
1
  module ExceptionHandler
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -1,7 +1,51 @@
1
1
  module ExceptionHandler
2
2
  class InstallGenerator < Rails::Generators::Base
3
- def create_initializer_file
4
- create_file "config/initializers/exception_handler.rb", "# Add initialization content here"
3
+
4
+ #Needed to reference files
5
+ source_root File.expand_path("../../templates", __FILE__)
6
+
7
+ #Option
8
+ class_option :assets, desc: 'Add views, controllers, models & assets to app (for customization)'
9
+ class_option :migration, type: :boolean, desc: 'Create migration'
10
+
11
+ #Config
12
+ def create_config_file
13
+ return unless options.empty?
14
+ template "exception_handler.rb", "config/initializers/exception_handler.rb" # https://github.com/plataformatec/devise/blob/master/lib/generators/devise/install_generator.rb#L13
15
+ end
16
+
17
+ #Assets
18
+ def create_customization assets = options.assets
19
+ #(views / controllers / models / assets)
20
+ return unless assets
21
+ file_generator assets
22
+ end
23
+
24
+ #Migration
25
+ def create_migration
26
+ return unless options.migration?
27
+ template "create_table.rb", "db/migrate/create_table.rb" #-> Need to use ActiveRecord::Generators::Base
28
+ end
29
+
30
+ protected
31
+
32
+ #File Generator
33
+ def file_generator args = options, options = %w(views controllers models assets)
34
+
35
+ #Valid?
36
+ return raise "Invalid Argument" unless options.include? args
37
+
38
+ #Types
39
+ if args.is_a? String
40
+ create_file "config/initializers/#{args}.rb", "# Add initialization content here"
41
+ elsif args.is_a? Array
42
+ for arg in args do
43
+ create_file "config/initializers/#{arg}.rb", "# Add initialization content here" #Need to use template
44
+ end
45
+ else
46
+ raise "Sorry, you either need to use 'views', 'controllers', 'models', 'assets' as the --files options"
47
+ end
48
+
5
49
  end
6
50
  end
7
51
  end
@@ -0,0 +1,14 @@
1
+ class CreateErrors < ActiveRecord::Migration
2
+ def change
3
+ create_table :errors do |t|
4
+ t.text :class_name
5
+ t.text :message
6
+ t.text :trace
7
+ t.text :target_url
8
+ t.text :referer_url
9
+ t.text :params
10
+ t.text :user_agent
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class CreateErrors < ActiveRecord::Migration
2
+ def change
3
+ create_table :errors do |t|
4
+ t.text :class_name
5
+ t.text :message
6
+ t.text :trace
7
+ t.text :target_url
8
+ t.text :referer_url
9
+ t.text :params
10
+ t.text :user_agent
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -4,11 +4,23 @@
4
4
  #Use the docs at http://github.com/richpeck/exception_handler for info
5
5
  ###
6
6
  ExceptionHandler.setup do |config|
7
+
7
8
  #DB -
8
9
  #Default = false / true ("errors")
9
10
  #Options = [string] = sets db name (if use true, default is "errors")
10
- config.db = true
11
+ config.db = "errors"
12
+
11
13
  #Email -
12
14
  #Default = false / true
13
15
  #config.email =
16
+
17
+ #Social
18
+ config.social = {
19
+ twitter: "http://twitter.com/frontlineutils",
20
+ facebook: "https://facebook.com/frontline.utilities",
21
+ linkedin: "https://linkedin.com/company/frontline-utilities",
22
+ youtube: "http://youtube.com/frontlineutils",
23
+ fusion: "http://frontlinefusion.com/frontlineutils"
24
+ }
25
+
14
26
  end
@@ -0,0 +1,18 @@
1
+ #Coveralls
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ ###########################################
6
+
7
+ require 'spec_helper'
8
+
9
+ ###########################################
10
+
11
+ describe "test" do
12
+
13
+ describe "404 Error" do
14
+ it "will show custom 404 error page" do
15
+ end
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Peck
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-29 00:00:00.000000000 Z
12
+ date: 2014-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -120,10 +120,13 @@ files:
120
120
  - lib/exception_handler/config.rb
121
121
  - lib/exception_handler/parser.rb
122
122
  - lib/exception_handler/version.rb
123
- - lib/generators/exception_handler/config_generator.rb
124
123
  - lib/generators/exception_handler/install_generator.rb
124
+ - lib/generators/templates/create_errors.rb
125
+ - lib/generators/templates/create_table.rb
125
126
  - lib/generators/templates/exception_handler.rb
127
+ - readme/exception_handler.png
126
128
  - spec/exception_spec.rb
129
+ - spec/installation_spec.rb
127
130
  - spec/spec_helper.rb
128
131
  - vendor/assets/images/exception_handler/bg.png
129
132
  homepage: http://frontlineutilities.co.uk/ror/custom_error_pages
@@ -153,4 +156,5 @@ summary: Rails gem to show custom error pages in production. Also logs errors in
153
156
  db if required
154
157
  test_files:
155
158
  - spec/exception_spec.rb
159
+ - spec/installation_spec.rb
156
160
  - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- module ExceptionHandler
2
- class ConfigGenerator < Rails::Generators::Base
3
- source_root File.expand_path("../../templates", __FILE__) #Needed to reference files
4
-
5
- def create_initializer_file
6
- template "exception_handler.rb", "config/initializers/exception_handler.rb" # https://github.com/plataformatec/devise/blob/master/lib/generators/devise/install_generator.rb#L13
7
- end
8
- end
9
- end