jetski 0.2.6 → 0.2.7
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/jetski/base_controller.rb +18 -1
- data/lib/jetski/router.rb +5 -1
- data/lib/jetski.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 357bfb82fcc61cf00861ecc1eae23837e62650788714473c98efa2423a982eae
|
|
4
|
+
data.tar.gz: 5548ed79761c0e03d05d2b34173d8c47377a44f6062429e281182a62db885b00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8fd0699bbbf6e90b28644e3c2511f279644ad928a30e023a12b87eb1360d795f7af9b5bc9d8876614b8f02eab1eacfeaca2da54542e83df84ee093b03ed7818d
|
|
7
|
+
data.tar.gz: 3c455bda8f1ac6074b10a4e6f7801be94dc7065f492bd52e4cde3ac2331d5dfc4abb1828688e2f8fa91f3ad3c429d3f7abd92ddc81b9c4ddcac6db1c824527bd
|
|
@@ -9,7 +9,23 @@ module Jetski
|
|
|
9
9
|
|
|
10
10
|
# Method to render matching view with controller_name/action_name
|
|
11
11
|
|
|
12
|
-
def render
|
|
12
|
+
def render(**args)
|
|
13
|
+
if args[:text]
|
|
14
|
+
res.content_type = "text/plain"
|
|
15
|
+
res.body = "#{args[:text]}\n"
|
|
16
|
+
return
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
if args[:json]
|
|
20
|
+
res.content_type = "application/json"
|
|
21
|
+
res.body = args[:json].to_json
|
|
22
|
+
return
|
|
23
|
+
end
|
|
24
|
+
render_template_file
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
def render_template_file
|
|
13
29
|
views_folder = File.join(Jetski.app_root, 'app/views')
|
|
14
30
|
assets_folder = File.join(Jetski.app_root, 'app/assets/stylesheets')
|
|
15
31
|
layout_content = File.read(File.join(views_folder, "layouts/application.html"))
|
|
@@ -22,6 +38,7 @@ module Jetski
|
|
|
22
38
|
''
|
|
23
39
|
end
|
|
24
40
|
page_with_css = page_with_layout.gsub("DYNAMIC_CSS", css_content)
|
|
41
|
+
res.content_type = "text/html"
|
|
25
42
|
res.body = page_with_css
|
|
26
43
|
end
|
|
27
44
|
end
|
data/lib/jetski/router.rb
CHANGED
|
@@ -24,7 +24,8 @@ module Jetski
|
|
|
24
24
|
# Theres no way to return. We need to organize into case statement or if/else type
|
|
25
25
|
|
|
26
26
|
if errors.empty?
|
|
27
|
-
|
|
27
|
+
controller_name_formatted = controller_name.split("/").map(&:capitalize).join("::")
|
|
28
|
+
constantized_controller = "#{controller_name_formatted}Controller"
|
|
28
29
|
path_to_defined_controller = File.join(Jetski.app_root, "app/controllers/#{controller_name}_controller.rb")
|
|
29
30
|
require_relative path_to_defined_controller
|
|
30
31
|
begin
|
|
@@ -41,11 +42,14 @@ module Jetski
|
|
|
41
42
|
controller.send(action_name)
|
|
42
43
|
# Render matching HTML template for GET requests only
|
|
43
44
|
controller.render if route_action.upcase == "GET"
|
|
45
|
+
# TODO: Need to setup redirects for other request types. POST/PUT/DELETE
|
|
44
46
|
end
|
|
45
47
|
|
|
46
48
|
if errors.any?
|
|
47
49
|
res.body = errors.join(", ")
|
|
48
50
|
end
|
|
51
|
+
|
|
52
|
+
# TODO: Set response content/type and status when rendering/redirecting or head
|
|
49
53
|
end
|
|
50
54
|
end
|
|
51
55
|
end
|
data/lib/jetski.rb
CHANGED