http-cat-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 54497b9383f6690bc586dad711065d9bb6bb589583e34e86a44499af4bb2ec49
4
+ data.tar.gz: a8ba1f1381eab9dfc6bc1754320fc79da60f49965b00152e112d2f5e7d4e46a8
5
+ SHA512:
6
+ metadata.gz: 282abceebfe10600ba97fc57c9ae30c300c9c0b5960f6c00ce3b10d2541f1e9a8e4a86d62f4d288ea82f417e0bcd45776b654c3e02f78c6b18a2b2bd5af32652
7
+ data.tar.gz: 03eaa0d98b99bf46ced75a362024a2a7ae4c99f273c5cfa5a2d7d2cc5271b852b6ac4ebf0c5463ba98f52840cdb2f92791745c05aaa3b3024b0b8e522bf3459e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2023 Gamberi Elia
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.md ADDED
@@ -0,0 +1,28 @@
1
+ # Http::Cat::Rails
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "http-cat-rails"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install http-cat-rails
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/setup"
2
+
3
+ load "rails/tasks/statistics.rake"
4
+
5
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ class ErrorsController < ApplicationController
2
+ Http::Cat::Rails.status_codes.each do |code, desc|
3
+ define_method(desc.downcase.gsub(' ', '_')) do
4
+ @code = code
5
+ render 'error', layout: false
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ <body style="margin: 0">
2
+ <div style="width: 100vw; height: 100vh; background: black; display: flex; align-items: center; justify-content: center">
3
+ <%= image_tag "#{Http::Cat::Rails.base_url}#{@code}.jpg", width: "50%" %>
4
+ </div>
5
+ </body>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ Http::Cat::Rails.status_codes.each do |code, desc|
3
+ match "/#{code}", to: "errors##{desc.downcase.gsub(' ', '_')}", via: :all
4
+ end
5
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ module Http
4
+ module Cat
5
+ module Rails
6
+ class << self
7
+ DEFAULTS = {
8
+ status_codes: { '100': 'Continue', '101': 'Switching Protocols', '102': 'Processing', '103': 'Early Hints',
9
+ '200': 'OK', '201': 'Created', '202': 'Accepted', '203': 'Non-Authoritative Information',
10
+ '204': 'No Content', '206': 'Partial Content', '207': 'Multi-Status', '300': 'Multiple Choices',
11
+ '301': 'Moved Permanently', '302': 'Found', '303': 'See Other', '304': 'Not Modified',
12
+ '305': 'Use Proxy', '307': 'Temporary Redirect', '308': 'Permanent Redirect',
13
+ '400': 'Bad Request', '401': 'Unauthorized', '402': 'Payment Required', '403': 'Forbidden',
14
+ '404': 'Not Found', '405': 'Method Not Allowed', '406': 'Not Acceptable',
15
+ '407': 'Proxy Authentication Required', '408': 'Request Timeout', '409': 'Conflict',
16
+ '410': 'Gone', '411': 'Length Required', '412': 'Precondition Failed', '413': 'Payload Too Large',
17
+ '414': 'Request-URI Too Long', '415': 'Unsupported Media Type',
18
+ '416': 'Request Range Not Satisfiable', '417': 'Expectation Failed',
19
+ '418': 'I’m a teapot', '420': 'Enhance Your Calm', '421': 'Misdirected Request',
20
+ '422': 'Unprocessable Entity', '423': 'Locked', '424': 'Failed Dependency',
21
+ '425': 'Too Early', '426': 'Upgrade Required', '428': 'Precondition Required',
22
+ '429': 'Too Many Requests', '431': 'Request Header Fields Too Large', '444': 'No Response',
23
+ '450': 'Blocked by Windows Parental Controls', '451': 'Unavailable For Legal Reasons',
24
+ '497': 'HTTP Request Sent to HTTPS Port', '498': 'Token expired/invalid',
25
+ '499': 'Client Closed Request', '500': 'Internal Server Error', '501': 'Not Implemented',
26
+ '502': 'Bad Gateway', '503': 'Service Unavailable', '504': 'Gateway Timeout',
27
+ '506': 'Variant Also Negotiates', '507': 'Insufficient Storage', '508': 'Loop Detected',
28
+ '509': 'Bandwidth Limit Exceeded', '510': 'Not Extended', '511': 'Network Authentication Required',
29
+ '521': 'Web Server Is Down', '522': 'Connection Timed Out', '523': 'Origin Is Unreachable',
30
+ '525': 'SSL Handshake Failed', '530': 'Site Frozen', '599': 'Network Connect Timeout Error' },
31
+ base_url: "https://http.cat/"
32
+ }.freeze
33
+
34
+ attr_writer :status_codes, :base_url
35
+
36
+ def configure
37
+ yield self
38
+ end
39
+
40
+ def status_codes
41
+ @status_codes || DEFAULTS[:status_codes]
42
+ end
43
+
44
+ def base_url
45
+ @base_url || DEFAULTS[:base_url]
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ module Http
2
+ module Cat
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ config.exceptions_app = self.routes
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Http
2
+ module Cat
3
+ module Rails
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require "http/cat/rails/version"
2
+ require "http/cat/rails/engine"
3
+ require_relative "configuration"
4
+
5
+ module Http
6
+ module Cat
7
+ module Rails
8
+
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :http_cat_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: http-cat-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gamberi Elia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.0
27
+ description: Configurable Ruby gem that replaces error pages with http.cat image
28
+ email:
29
+ - me@gimbaro.dev
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - app/controllers/errors_controller.rb
38
+ - app/views/errors/error.html.erb
39
+ - config/routes.rb
40
+ - lib/http/cat/configuration.rb
41
+ - lib/http/cat/rails.rb
42
+ - lib/http/cat/rails/engine.rb
43
+ - lib/http/cat/rails/version.rb
44
+ - lib/tasks/http/cat/rails_tasks.rake
45
+ homepage:
46
+ licenses:
47
+ - MIT
48
+ metadata:
49
+ allowed_push_host: https://rubygems.org
50
+ homepage_uri: https://github.com/Gimbardo/http-cat-rails
51
+ source_code_uri: https://github.com/Gimbardo/http-cat-rails
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.3.3
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Configurable Ruby gem that replaces error pages with http.cat image
71
+ test_files: []