error_pages 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in error_pages.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "error_pages/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "error_pages"
7
+ s.version = ErrorPages::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Javier Vidal"]
10
+ s.email = ["zanaguara@gmail.com"]
11
+ s.homepage = "https://github.com/javiervidal/error_pages"
12
+ s.summary = %q{Generate error pages with layout and internationalization in your Rails application}
13
+ s.description = %q{Generate error pages with layout and internationalization in your Rails application}
14
+
15
+ s.rubyforge_project = "error_pages"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,3 @@
1
+ module ErrorPages
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,3 @@
1
+ module ErrorPages
2
+ require 'error_pages/railtie' if defined?(Rails)
3
+ end
data/lib/railitie.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'error_pages'
2
+ require 'rails'
3
+ module ErrorPages
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :error_pages
6
+
7
+ rake_tasks do
8
+ load "lib/tasks/error_pages.rake"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ LOCAL_DOMAIN = 'localhost:3001'
2
+
3
+ require 'open-uri'
4
+
5
+ namespace :error_pages do
6
+ def write_error_page(status, locale = nil)
7
+
8
+ include Rails.application.routes.url_helpers
9
+ default_url_options[:host] = LOCAL_DOMAIN
10
+
11
+ dest_filename = [status.to_s, locale, "html"].compact.join(".")
12
+ File.open(File.join(Rails.root, "public", dest_filename), "w") do |file|
13
+ I18n.locale = locale
14
+ url = Rails.application.send("error_pages_#{status}_url".to_sym)
15
+ puts "#{url} => #{file.path}"
16
+ file.write open(url).read
17
+ end
18
+ end
19
+
20
+ desc 'Write public/404.html and public/500.html error pages'
21
+ task :write => :environment do
22
+ [500, 404].each do |status|
23
+ I18n.available_locales.each do |locale|
24
+ write_error_page(status, locale)
25
+ # We need a default error page for when Rails doesn't work
26
+ write_error_page(status) if locale.to_sym == I18n.default_locale
27
+ end
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: error_pages
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Javier Vidal
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-15 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Generate error pages with layout and internationalization in your Rails application
23
+ email:
24
+ - zanaguara@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - error_pages.gemspec
36
+ - lib/error_pages.rb
37
+ - lib/error_pages/version.rb
38
+ - lib/railitie.rb
39
+ - lib/tasks/error_pages.rake
40
+ has_rdoc: true
41
+ homepage: https://github.com/javiervidal/error_pages
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: error_pages
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Generate error pages with layout and internationalization in your Rails application
74
+ test_files: []
75
+