auto_error 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,15 @@
1
- module AutoError
2
- class AppErrorsController < ApplicationController
3
- before_filter :ensure_authenticated
1
+ class AutoError::AppErrorsController < AutoError::ApplicationController
2
+ before_filter :ensure_authenticated
4
3
 
5
- def index
6
- @errors = AppError.unresolved
7
- render json: @errors.map { |ae| AppErrorDecorator.new(ae).as_json }
8
- end
4
+ def index
5
+ @errors = AutoError::AppError.unresolved
6
+ render json: @errors.map { |ae| AutoError::AppErrorDecorator.new(ae).as_json }
7
+ end
9
8
 
10
- def destroy
11
- @error = AppError.find( params[:id] )
12
- @error.resolved_at = Time.now
13
- @error.save
14
- render json: { ok: true }
15
- end
9
+ def destroy
10
+ @error = AutoError::AppError.find( params[:id] )
11
+ @error.resolved_at = Time.now
12
+ @error.save
13
+ render json: { ok: true }
16
14
  end
17
15
  end
@@ -1,13 +1,11 @@
1
- module AutoError
2
- class ApplicationController < ActionController::Base
3
- include AutoError::ApplicationHelper
4
- helper :all
1
+ class AutoError::ApplicationController < ActionController::Base
2
+ include AutoError::ApplicationHelper
3
+ helper :all
5
4
 
6
- private
5
+ protected
7
6
 
8
- def ensure_authenticated
9
- context = AutoError::AuthContext.new(env)
10
- raise AutoError::Errors::Denied unless AutoError::Config.auth_with.call(context)
11
- end
7
+ def ensure_authenticated
8
+ context = AutoError::AuthContext.new(env)
9
+ raise AutoError::Errors::Denied unless AutoError::Config.auth_with.call(context)
12
10
  end
13
11
  end
@@ -1,32 +1,30 @@
1
- module AutoError
2
- class ErrorsController < ApplicationController
1
+ class AutoError::ErrorsController < AutoError::ApplicationController
3
2
 
4
- def show
5
- # reset action_controller.instance to the original controller
6
- # that caused the exception
7
- env['action_controller.instance'] = env.delete('auto_error.original_controller.instance')
3
+ def show
4
+ # reset action_controller.instance to the original controller
5
+ # that caused the exception
6
+ env['action_controller.instance'] = env.delete('auto_error.original_controller.instance')
8
7
 
9
- @exception = env['action_dispatch.exception']
10
- @status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
11
- @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
12
- @params = env['action_dispatch.request.parameters'].symbolize_keys
8
+ @exception = env['action_dispatch.exception']
9
+ @status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
10
+ @rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
11
+ @params = env['action_dispatch.request.parameters'].symbolize_keys
13
12
 
14
- @status_code = 500 unless [403, 404].include?(@status_code)
13
+ @status_code = 500 unless [403, 404].include?(@status_code)
15
14
 
16
- if @status_code == 500
17
- controller = "#{@params[:controller].camelize}Controller" rescue 'N/A'
18
- action = @params[:action] || 'N/A'
19
- where = { controller: controller, action: action }
20
- data = {
21
- path: env['REQUEST_URI'],
22
- method: env['REQUEST_METHOD'],
23
- ip: env['REMOTE_ADDR']
24
- }
25
- AppError.log!( env, @exception, where, data )
26
- end
27
-
28
- AutoError::Config.error_template_renderer.bind(self).( @status_code )
15
+ if @status_code == 500
16
+ controller = "#{@params[:controller].camelize}Controller" rescue 'N/A'
17
+ action = @params[:action] || 'N/A'
18
+ where = { controller: controller, action: action }
19
+ data = {
20
+ path: env['REQUEST_URI'],
21
+ method: env['REQUEST_METHOD'],
22
+ ip: env['REMOTE_ADDR']
23
+ }
24
+ AutoError::AppError.log!( env, @exception, where, data )
29
25
  end
30
26
 
27
+ AutoError::Config.error_template_renderer.bind(self).( @status_code )
31
28
  end
29
+
32
30
  end
@@ -1,9 +1,7 @@
1
- module AutoError
2
- class MainController < ApplicationController
3
- before_filter :ensure_authenticated
1
+ class AutoError::MainController < AutoError::ApplicationController
2
+ before_filter :ensure_authenticated
4
3
 
5
- def index
6
- render layout: 'auto_error/application'
7
- end
4
+ def index
5
+ render layout: 'auto_error/application'
8
6
  end
9
7
  end
data/lib/auto_error.rb CHANGED
@@ -22,7 +22,7 @@ require 'auto_error/engine'
22
22
 
23
23
  module AutoError
24
24
  def self.setup!( app_config )
25
- Config.send(:set_defaults)
25
+ AutoError::Config.send(:set_defaults)
26
26
  app_config.action_dispatch.rescue_responses["AutoError::Errors::Denied"] = :forbidden
27
27
  app_config.action_dispatch.rescue_responses["AutoError::Errors::NotFound"] = :not_found
28
28
 
@@ -1,3 +1,3 @@
1
1
  module AutoError
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_error
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -266,7 +266,6 @@ files:
266
266
  - app/views/errors/500.html.erb
267
267
  - app/views/layouts/auto_error/application.html.erb
268
268
  - app/views/layouts/errors.html.erb
269
- - config/initializers/fabrication.rb
270
269
  - config/routes.rb
271
270
  - db/migrate/20130128004546_create_auto_error_app_errors.rb
272
271
  - lib/auto_error/auth_context.rb
@@ -1,6 +0,0 @@
1
- if Rails.env.test?
2
- require 'fabrication'
3
- Fabrication.configure do |config|
4
- config.path_prefix = AutoError::Engine.root
5
- end
6
- end