tora 0.0.3 → 0.0.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 +4 -4
- data/lib/tora/controller.rb +13 -0
- data/lib/tora/error_controller.rb +15 -0
- data/lib/tora/routing.rb +17 -0
- data/lib/tora/version.rb +1 -1
- data/lib/tora.rb +17 -2
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 689ff41df26782feb0ba8e8f27b129316dd4979830e2f5a0783337f299942de2
|
4
|
+
data.tar.gz: 98236f2eaab79e2f0aea8bbbb986a40fd85aafa3d6b96b946b199040100e99db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ea136f1e91f3fa224e979d1b4e397b07998913dae07849501b9c2640718aeb548aa8238e2e1da031ca1e7a09c8c79383948a2b808517d9537817b7ef8b32b5
|
7
|
+
data.tar.gz: 4e71c3064cb9e4cdd0ba3895c75a718243c923fb7590782dd5648a0059fa0573e5b4a190e2da62cd1b60f21034a17cfe1760989421d5236aad3e51f94398d8a0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "pp"
|
2
|
+
|
3
|
+
module Tora
|
4
|
+
class ErrorController < Tora::Controller
|
5
|
+
def error
|
6
|
+
"<h1>Tora Runtime Error</h1>" +
|
7
|
+
"<p>Here follows the insight:</p>" +
|
8
|
+
"<hr/>" +
|
9
|
+
"<div>" +
|
10
|
+
"<pre>#{@env.to_s.gsub('", ', '".<br>')}</pre>" +
|
11
|
+
"</div>" +
|
12
|
+
"<hr/>"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/tora/routing.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "tora/controller"
|
4
|
+
|
5
|
+
module Tora
|
6
|
+
class Application
|
7
|
+
# this function will compose a magical name for the class of the component ant will try to instantiate
|
8
|
+
# the object that has that name and returns which action it should respond to. this is obtained via the
|
9
|
+
# part of the route we obtain
|
10
|
+
def get_controller_and_action(env)
|
11
|
+
_, controller_name, action, after = env["PATH_INFO"].split("/", 4)
|
12
|
+
controller_name = controller_name.capitalize + "Controller"
|
13
|
+
|
14
|
+
[Object.const_get(controller_name), action]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/tora/version.rb
CHANGED
data/lib/tora.rb
CHANGED
@@ -1,12 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require "tora/version"
|
4
|
+
require "tora/controller"
|
5
|
+
require "tora/routing"
|
6
|
+
|
7
|
+
# helper classes or modules
|
8
|
+
require "tora/error_controller"
|
4
9
|
|
5
10
|
module Tora
|
6
11
|
class Error < StandardError; end
|
12
|
+
|
7
13
|
class Application
|
8
14
|
def call(env)
|
9
|
-
|
15
|
+
begin
|
16
|
+
controller_class, controller_action = get_controller_and_action(env)
|
17
|
+
controller = controller_class.new(env)
|
18
|
+
response = controller.send(controller_action)
|
19
|
+
rescue
|
20
|
+
controller = Tora::ErrorController.new(env)
|
21
|
+
response = controller.send('error')
|
22
|
+
end
|
23
|
+
|
24
|
+
[200, { "Content-Type" => "text/html"}, [response]]
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Tapadas Alves
|
@@ -66,6 +66,9 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- lib/array.rb
|
68
68
|
- lib/tora.rb
|
69
|
+
- lib/tora/controller.rb
|
70
|
+
- lib/tora/error_controller.rb
|
71
|
+
- lib/tora/routing.rb
|
69
72
|
- lib/tora/version.rb
|
70
73
|
- rebuild_gem.sh
|
71
74
|
- sig/tora.rbs
|