ruh_roh 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +87 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/generate_error/errors.js +2 -0
- data/app/assets/stylesheets/generate_error/application.css +13 -0
- data/app/assets/stylesheets/generate_error/errors.css +4 -0
- data/app/controllers/ruh_roh/application_controller.rb +11 -0
- data/app/controllers/ruh_roh/errors_controller.rb +7 -0
- data/app/helpers/ruh_roh/application_helper.rb +4 -0
- data/app/helpers/ruh_roh/errors_helper.rb +4 -0
- data/app/views/layouts/ruh_roh/application.html.erb +14 -0
- data/app/views/ruh_roh/errors/404.html.erb +2 -0
- data/app/views/ruh_roh/errors/422.html.erb +2 -0
- data/app/views/ruh_roh/errors/500.html.erb +2 -0
- data/config/routes.rb +3 -0
- data/lib/ruh_roh/engine.rb +5 -0
- data/lib/ruh_roh/generator.rb +33 -0
- data/lib/ruh_roh/version.rb +3 -0
- data/lib/ruh_roh.rb +13 -0
- data/lib/tasks/ruh_roh_tasks.rake +6 -0
- metadata +115 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Scott Windsor
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
= RuhRoh
|
2
|
+
|
3
|
+
RuhRoh is a rails plugin that allows you pre-generate error pages with the full rails stack available.
|
4
|
+
|
5
|
+
While rails' default error pages are great, they look totally unprofessional for any real site.
|
6
|
+
RuRoh provides a quick and easy way to have nicely rendered error pages generated from your stack
|
7
|
+
during deployment. This allows you to re-use your existing layouts and customize your error pages
|
8
|
+
without having to re-create them on the fly (which could result in further errors). The pages can
|
9
|
+
be generated via capistrano during deploy, or generated during a post-commit hook similar to asset
|
10
|
+
pipeline resources.
|
11
|
+
|
12
|
+
= Usage
|
13
|
+
|
14
|
+
In your Gemfile, add RuhRoh.
|
15
|
+
|
16
|
+
gem 'ruh_roh'
|
17
|
+
|
18
|
+
In your routes file, mount the engine on the /error path.
|
19
|
+
|
20
|
+
YourApp::Application.routes.draw do
|
21
|
+
mount RuhRoh::Engine => "/error"
|
22
|
+
end
|
23
|
+
|
24
|
+
Now you can render out some error pages!
|
25
|
+
|
26
|
+
rake ruh_roh:generate
|
27
|
+
|
28
|
+
There are default 404, 422 & 500 templates available by default - it will also use your application
|
29
|
+
layout.
|
30
|
+
|
31
|
+
To override the existing templates, just make a new view to override the default.
|
32
|
+
|
33
|
+
in app/views/ruh_roh/errors/404.html.erb
|
34
|
+
|
35
|
+
<h1>Oh noes! Dis page not foundses.</h1>
|
36
|
+
|
37
|
+
# Configuration
|
38
|
+
|
39
|
+
There are a few config options. Make sure these are set in your config, but in an after_initialize
|
40
|
+
block.
|
41
|
+
|
42
|
+
module YourApp
|
43
|
+
class Application < Rails::Application
|
44
|
+
|
45
|
+
config.after_initialize do
|
46
|
+
# Set error layout
|
47
|
+
config.ruh_roh.application_layout = "error"
|
48
|
+
# Set error hostname
|
49
|
+
config.ruh_roh.application_host = "scoobysnacks.com"
|
50
|
+
# Set handled errors
|
51
|
+
config.ruh_roh.handled_errors = %(404 418 500)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
= Deployment
|
57
|
+
|
58
|
+
For deployment, you can add this to your capistrano config:
|
59
|
+
|
60
|
+
namespace :deploy do
|
61
|
+
desc "Generate error pages for production"
|
62
|
+
task :generate_error_pages do
|
63
|
+
run <<-EOF
|
64
|
+
cd #{release_path} && RAILS_ENV='production' bundle exec rake ruh_roh:generate
|
65
|
+
EOF
|
66
|
+
end
|
67
|
+
end
|
68
|
+
after "deploy:update", "deploy:generate_error_pages"
|
69
|
+
|
70
|
+
This should be very similar to your precompile_assets task. If you can't write to public on your production
|
71
|
+
server, you can consider make the rake task a git post-commit hook or just checking in the html files
|
72
|
+
by hand.
|
73
|
+
|
74
|
+
= Misc hacks/notes/etc
|
75
|
+
|
76
|
+
You'll want to sent an application host if you have and urls in your pages. This is a side effect
|
77
|
+
on how pages are rendered via the integration runner - otherwise you'll end up with "example.com"
|
78
|
+
for all of your urls.
|
79
|
+
|
80
|
+
Also, if your layout or views use any routes for your application, you'll have to prepend them with
|
81
|
+
"main_app". For example, "root_url" becomes "main_app.root_url". This is a bit of a side effect
|
82
|
+
of how rails engine's work.
|
83
|
+
|
84
|
+
= License
|
85
|
+
|
86
|
+
This project is released under the MIT License. Have fun, and be excellent to each other.
|
87
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'RuhRoh'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
RSpec::Core::RakeTask.new(:spec)
|
25
|
+
|
26
|
+
# RSpec as default
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>RuhRoh</title>
|
5
|
+
<%= stylesheet_link_tag "ruh_roh/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "ruh_roh/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
module RuhRoh
|
3
|
+
class Generator
|
4
|
+
|
5
|
+
def generate!
|
6
|
+
config.handled_errors.each do |action|
|
7
|
+
app.get "/error/#{action}"
|
8
|
+
if app.response.code == "200"
|
9
|
+
File.open("public/#{action}.html", "w") { |f| f.write app.response.body }
|
10
|
+
else
|
11
|
+
raise app.response.body
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def config
|
19
|
+
Rails.configuration.ruh_roh
|
20
|
+
end
|
21
|
+
|
22
|
+
def app
|
23
|
+
@app ||= (
|
24
|
+
require "rails/console/app"
|
25
|
+
extend Rails::ConsoleMethods
|
26
|
+
|
27
|
+
app.host = config.application_host
|
28
|
+
app
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/ruh_roh.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "ruh_roh/engine"
|
2
|
+
require "ruh_roh/generator"
|
3
|
+
|
4
|
+
module RuhRoh
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
initializer "ruh_roh.some_init_task" do |app|
|
7
|
+
RuhRohConfig = Struct.new(:application_layout, :application_host, :handled_errors)
|
8
|
+
app.config.ruh_roh = RuhRohConfig.new
|
9
|
+
app.config.ruh_roh.application_layout = "application"
|
10
|
+
app.config.ruh_roh.handled_errors = %w(404 422 500)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruh_roh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Scott Windsor
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-03-11 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 23
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 2
|
30
|
+
- 12
|
31
|
+
version: 3.2.12
|
32
|
+
requirement: *id001
|
33
|
+
prerelease: false
|
34
|
+
type: :runtime
|
35
|
+
name: rails
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 0
|
46
|
+
version: "2.0"
|
47
|
+
requirement: *id002
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
name: rspec-rails
|
51
|
+
description: " While rails' default error pages are great, they look totally unprofessional for any real site.\n RuRoh provides a quick and easy way to have nicely rendered error pages generated from your stack\n during deployment. This allows you to re-use your existing layouts and customize your error pages\n without having to re-create them on the fly (which could result in further errors). The pages can\n be generated via capistrano during deploy, or generated during a post-commit hook similar to asset\n pipeline resources.\n"
|
52
|
+
email:
|
53
|
+
- swindsor@gmail.com
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files: []
|
59
|
+
|
60
|
+
files:
|
61
|
+
- app/assets/javascripts/generate_error/errors.js
|
62
|
+
- app/assets/stylesheets/generate_error/application.css
|
63
|
+
- app/assets/stylesheets/generate_error/errors.css
|
64
|
+
- app/controllers/ruh_roh/application_controller.rb
|
65
|
+
- app/controllers/ruh_roh/errors_controller.rb
|
66
|
+
- app/helpers/ruh_roh/application_helper.rb
|
67
|
+
- app/helpers/ruh_roh/errors_helper.rb
|
68
|
+
- app/views/layouts/ruh_roh/application.html.erb
|
69
|
+
- app/views/ruh_roh/errors/404.html.erb
|
70
|
+
- app/views/ruh_roh/errors/422.html.erb
|
71
|
+
- app/views/ruh_roh/errors/500.html.erb
|
72
|
+
- config/routes.rb
|
73
|
+
- lib/ruh_roh/engine.rb
|
74
|
+
- lib/ruh_roh/generator.rb
|
75
|
+
- lib/ruh_roh/version.rb
|
76
|
+
- lib/ruh_roh.rb
|
77
|
+
- lib/tasks/ruh_roh_tasks.rake
|
78
|
+
- MIT-LICENSE
|
79
|
+
- Rakefile
|
80
|
+
- README.rdoc
|
81
|
+
homepage: http://github.com/sentientmonkey/ruh_roh
|
82
|
+
licenses: []
|
83
|
+
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.8.25
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: RuhRoh is a rails plugin that allows you pre-generate error pages with the full rails stack available.
|
114
|
+
test_files: []
|
115
|
+
|