exception_handler 0.2.1 → 0.2.5

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: d804786a9e059b8d5ac5b055892c16d42f58d55f
4
- data.tar.gz: 1e27dda5d5a2cabd8470c352d1cc186851c695ca
3
+ metadata.gz: 7b14313cb847dd5ad1e6f11c110439c3f9f02891
4
+ data.tar.gz: d481b5a7a526fbdffe2a8bd71379a5362e6414c5
5
5
  SHA512:
6
- metadata.gz: ef0e66479c5055ac155826555636428f23466255d8a060fe4b428b7558a1f2556fb6c8e9d3877125e7bf1dacf1379e35f0fc9214e51476458e90daf975f7a0aa
7
- data.tar.gz: be954599ca3c05944b191c7167ba87dc57d980d90cf0ffa0cc185a2ea1baa863f93230fe58cf5e8a055c4d6ee2bf41d43b2bc8b73a67a336aee70b5c07e82643
6
+ metadata.gz: fe3128237d98b4c903a96a04a44e6bf313f3861e3ab859b6be2d623dbb3a20862a4479dd3a25270038f62efd501612283158fb2af82e0134840dbc94ec3e7fbb
7
+ data.tar.gz: 4ce1ea49e147e2f2a423ce041decfa4f99d4acfa024d2e176f01bd958be54cc515b7b24c8ac69c77bbf502ec20f281bb74607aea00fff1b7c759379ec031efd4
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  rvm:
2
+ - 1.9.3
2
3
  - 2.0.0
3
4
  - 2.1.1
4
5
  - ruby-head
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in custom_error_pages.gemspec
4
4
  gemspec
5
+
6
+ ###########################################
7
+
8
+ group :test do
9
+ gem 'coveralls', require: false
10
+ end
11
+
12
+ ###########################################
data/README.md CHANGED
@@ -8,10 +8,24 @@
8
8
 
9
9
  **ExceptionHandler** Rails Gem (adapted from [this tutorial](https://gist.github.com/wojtha/8433843))
10
10
 
11
+ > - **[Custom Error Pages](#custom-error-pages)**
12
+ > - **[Save Errors To DB](#save-errors-to-db)**
13
+
11
14
  Works with the [`config.exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration) hook in Rails' middleware stack:
12
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
17
 
18
+ -----------
19
+
20
+ ####Custom Error Pages
21
+
22
+ You can create *custom error pages*. These allow you to serve your own design error pages in production; showing both the error, and the problem. This is a big step forward from the standard Rails error reporting facility
23
+
24
+
25
+
26
+ ####Save Errors To DB
27
+
28
+ Sometimes, you want to save your errors to your database (admin areas, multi-tenant apps, etc). We've included some middleware which captures the routes
15
29
 
16
30
  ---------
17
31
 
@@ -29,6 +43,24 @@ Or install it yourself as:
29
43
 
30
44
  $ gem install exception_handler
31
45
 
46
+ ###Generators
47
+
48
+ # General
49
+ $ rails generate exception_handler:install
50
+
51
+ #Config (for db)
52
+ $ rails generate exception_handler:config
53
+
54
+ #Assets
55
+ $ rails generate exception_handler:assets:all
56
+ -
57
+ $ rails generate exception_handler:assets:views
58
+ $ rails generate exception_handler:assets:controllers
59
+ $ rails generate exception_handler:assets:models
60
+ $ rails generate exception_handler:assets:assets
61
+
62
+
63
+
32
64
  ---------
33
65
 
34
66
  ## Usage
@@ -46,9 +78,25 @@ resolved in a new version
46
78
 
47
79
  No action required
48
80
 
81
+ ###Demo
82
+
83
+ Demo to be put onto Heroku etc
49
84
 
50
85
  --------
51
86
 
87
+ ## Support
88
+
89
+ If you need help, you may consider:
90
+
91
+ 1. Watching this [**video tutorial**](http://www.youtube.com/watch?v=Zo2vav3dYnY):
92
+
93
+ [![ExceptionHandler Update](http://img.youtube.com/vi/Zo2vav3dYnY/0.jpg)](http://www.youtube.com/watch?v=Zo2vav3dYnY)
94
+ 2. Read [**our tutorial**](http://google.com)
95
+ 3. Ask on [**StackOverflow**](http://stackoverflow.com)
96
+ 4. Go on the [**gem support page**](http://frontlineutilities.co.uk)
97
+
98
+ ---------
99
+
52
100
  ## Contributing
53
101
 
54
102
  1. Fork it ( https://github.com/richpeck/exception_handler/fork )
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ ###########################################
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,9 @@
1
+ module ExceptionHandler
2
+ class Error < ActiveRecord::Base
3
+ #Table is called "errors"
4
+ #Dev needs to use migration to create db
5
+
6
+ #Associations
7
+ belongs_to :usable, polymorphic: true
8
+ end
9
+ end
@@ -3,3 +3,5 @@
3
3
  = details[:name]
4
4
  %p
5
5
  = details[:message]
6
+
7
+ = ExceptionHandler.config.db
@@ -6,8 +6,8 @@ require 'exception_handler/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "exception_handler"
8
8
  spec.version = ExceptionHandler::VERSION
9
- spec.authors = ["Richard Peck"]
10
- spec.email = ["rpeck@frontlineutilities.co.uk"]
9
+ spec.authors = ["Richard Peck", "Joe Hilton"]
10
+ spec.email = ["rpeck@frontlineutilities.co.uk", "jhilton@frontlineutilities.co.uk"]
11
11
  spec.summary = %q{Rails gem to show custom error pages in production. Also logs errors in "errors" db if required}
12
12
  spec.description = %q{Rails gem to create custom error pages. Captures exceptions using "exception_app" callback, routing to "Exception" controller, rendering the view as required.}
13
13
  spec.homepage = "http://frontlineutilities.co.uk/ror/custom_error_pages"
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rails", "~> 4.0.0"
23
23
  spec.add_development_dependency "haml", "~> 4.0.5"
24
24
  spec.add_development_dependency "sass", "~> 3.3.7"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
25
27
  end
@@ -1,9 +1,13 @@
1
1
  ###########################################
2
2
 
3
+ #Core Dependencies
3
4
  require "action_dispatch"
4
5
 
5
- require "exception_handler/version"
6
- require "exception_handler/parser"
6
+ #Gem Files
7
+ versions = %w(version parser config)
8
+ for version in versions do
9
+ require "exception_handler/#{version}"
10
+ end
7
11
 
8
12
  ###########################################
9
13
 
@@ -17,4 +21,15 @@ module ExceptionHandler
17
21
  end
18
22
  end
19
23
 
24
+ #Config
25
+ #Ref http://robots.thoughtbot.com/mygem-configure-block
26
+ mattr_accessor :config
27
+
28
+ #Init Config
29
+ @@config ||= Config.new
30
+
31
+ #Block (for initializer)
32
+ def self.setup
33
+ yield(config) if block_given?
34
+ end
20
35
  end
@@ -0,0 +1,14 @@
1
+ ###########################################
2
+ # Refs
3
+ # http://stackoverflow.com/questions/10584638/setting-up-configuration-settings-when-writing-a-gem
4
+ # http://robots.thoughtbot.com/mygem-configure-block
5
+ ###########################################
6
+ module ExceptionHandler
7
+ class Config
8
+ attr_accessor :db
9
+
10
+ def initialize
11
+ @db = false # -> db name (false = no; true = "errors"; [value] = [value])
12
+ end
13
+ end
14
+ end
@@ -42,7 +42,7 @@ module ExceptionHandler
42
42
  #Save
43
43
  def save
44
44
  ActiveRecord::Base.logger.silence do
45
- #ExceptionHandler::Error.create(relevant_info)
45
+ ExceptionHandler::Error.create(relevant_info)
46
46
  end
47
47
  log(relevant_info)
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module ExceptionHandler
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,7 @@
1
+ module ExceptionHandler
2
+ class InstallGenerator < Rails::Generators::Base
3
+ def create_initializer_file
4
+ create_file "config/initializers/exception_handler.rb", "# Add initialization content here"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ #Exception Handler
2
+ ###
3
+ #You can add different settings using this block
4
+ #Use the docs at http://github.com/richpeck/exception_handler for info
5
+ ###
6
+ ExceptionHandler.setup do |config|
7
+ #DB -
8
+ #Default = false / true ("errors")
9
+ #Options = [string] = sets db name (if use true, default is "errors")
10
+ config.db = true
11
+ #Email -
12
+ #Default = false / true
13
+ #config.email =
14
+ 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
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Peck
8
+ - Joe Hilton
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
12
+ date: 2014-05-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -66,27 +67,64 @@ dependencies:
66
67
  - - ~>
67
68
  - !ruby/object:Gem::Version
68
69
  version: 3.3.7
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
69
98
  description: Rails gem to create custom error pages. Captures exceptions using "exception_app"
70
99
  callback, routing to "Exception" controller, rendering the view as required.
71
100
  email:
72
101
  - rpeck@frontlineutilities.co.uk
102
+ - jhilton@frontlineutilities.co.uk
73
103
  executables: []
74
104
  extensions: []
75
105
  extra_rdoc_files: []
76
106
  files:
77
107
  - .gitignore
108
+ - .rspec
78
109
  - .travis.yml
79
110
  - Gemfile
80
111
  - LICENSE.txt
81
112
  - README.md
82
113
  - Rakefile
83
114
  - app/controllers/exception_handler/exception_controller.rb
115
+ - app/models/exception_handler/error.rb
84
116
  - app/views/exception_handler/exception/show.html.haml
85
117
  - app/views/layouts/error.html.haml
86
118
  - exception_handler.gemspec
87
119
  - lib/exception_handler.rb
120
+ - lib/exception_handler/config.rb
88
121
  - lib/exception_handler/parser.rb
89
122
  - lib/exception_handler/version.rb
123
+ - lib/generators/exception_handler/config_generator.rb
124
+ - lib/generators/exception_handler/install_generator.rb
125
+ - lib/generators/templates/exception_handler.rb
126
+ - spec/exception_spec.rb
127
+ - spec/spec_helper.rb
90
128
  - vendor/assets/images/exception_handler/bg.png
91
129
  homepage: http://frontlineutilities.co.uk/ror/custom_error_pages
92
130
  licenses:
@@ -113,4 +151,6 @@ signing_key:
113
151
  specification_version: 4
114
152
  summary: Rails gem to show custom error pages in production. Also logs errors in "errors"
115
153
  db if required
116
- test_files: []
154
+ test_files:
155
+ - spec/exception_spec.rb
156
+ - spec/spec_helper.rb