jetski 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9695762a6c63b04e17d8477feff33bd1cf6e44a819a7112c17abed5c9411826b
4
- data.tar.gz: 046a721b230e7fe80c5fe19a95a1a81d64d3e1956caff0163127a4752064a58a
3
+ metadata.gz: 746e669c9cd0109b9c5d11bc04b8eeda814b529f211ea5cf8aafd1531aa651e3
4
+ data.tar.gz: d178172efe91cc4f611d0cf1c5225871d70ea8718af834d21648f7eb51de2324
5
5
  SHA512:
6
- metadata.gz: 3186f1f38ab5fd20ddbd24f6c3e9958f34e44161269333c83b1ae42208e64d4016ed03354458c4a7540c4e38784120a9ff8e971279465b2d66156d9909c0a7c3
7
- data.tar.gz: 1b6674aaffba2a6054bd0d07e9923d5c0bf43df333572e4b81f9474c2d671d01c3ad63b987d0625a794012c227003b831c97ce3b956e7e3b655985f35677400c
6
+ metadata.gz: 7c8b29c0de093d02b4a3c72401210e54c97bd09615ef3894d216f7b2ede33878ee3b30ecd329cfbde8427951709ca983f04a8e152b0c2fe4d91370edae65a8d9
7
+ data.tar.gz: fd259f11692b58f01c5cdf82e462ea573ded074fa71924764d7932bbe42494c1e76861ca87030531f9279f1394daf321abfbe882656b92379b617e2f274810a3
@@ -1,7 +1,7 @@
1
1
  # This is the base controller of the library
2
2
  module Jetski
3
3
  class BaseController
4
- attr_accessor :action_name, :controller_name
4
+ attr_accessor :action_name, :controller_name, :controller_path
5
5
  attr_reader :res
6
6
  attr_reader :performed_render
7
7
 
@@ -50,11 +50,12 @@ module Jetski
50
50
  views_folder = File.join(Jetski.app_root, 'app/views')
51
51
  assets_folder = File.join(Jetski.app_root, 'app/assets/stylesheets')
52
52
  layout_content = File.read(File.join(views_folder, "layouts/application.html"))
53
- page_content = File.read(File.join(views_folder, controller_name, "#{action_name}.html"))
53
+ path_to_controller = controller_path[1..-1]
54
+ page_content = File.read(File.join(views_folder, path_to_controller, "#{action_name}.html"))
54
55
  page_with_layout = layout_content.gsub("YIELD_CONTENT", page_content)
55
- action_css_file = File.join(assets_folder, "#{controller_name}.css")
56
+ action_css_file = File.join(assets_folder, "#{path_to_controller}.css")
56
57
  css_content = if File.exist? action_css_file
57
- "<link rel='stylesheet' href='/#{controller_name}.css'>"
58
+ "<link rel='stylesheet' href='/#{path_to_controller}.css'>"
58
59
  else
59
60
  ''
60
61
  end
@@ -7,9 +7,9 @@ module Jetski
7
7
  controller_file_paths = Dir.glob([File.join(Jetski.app_root, 'app', 'controllers', '**', '*_controller.rb')])
8
8
  controller_file_paths.each do |file_path|
9
9
  controller_file_name = file_path.split('app/controllers')[1]
10
- controller_as_url = controller_file_name.gsub(/_controller.rb/, '')
11
- controller_name = controller_as_url.split("/").last
12
- controller_classname = controller_as_url.split("/").reject(&:empty?).map(&:capitalize).join("::") + "Controller"
10
+ controller_path = controller_file_name.gsub(/_controller.rb/, '')
11
+ controller_name = controller_path.split("/").last
12
+ controller_classname = controller_path.split("/").reject(&:empty?).map(&:capitalize).join("::") + "Controller"
13
13
  controller_file_readlines = File.readlines(file_path)
14
14
  controller_file_readlines.each.with_index do |line, idx|
15
15
  strp_line = line.strip
@@ -18,42 +18,43 @@ module Jetski
18
18
  base_opts = {
19
19
  controller_classname: controller_classname,
20
20
  controller_file_name: controller_file_name,
21
- controller_name: controller_name
21
+ controller_name: controller_name,
22
+ controller_path: controller_path,
22
23
  }
23
24
  case action_name
24
25
  when "new"
25
26
  auto_found_routes << base_opts.merge({
26
- url: controller_as_url + "/new",
27
+ url: controller_path + "/new",
27
28
  method: "GET",
28
29
  action_name: action_name,
29
30
  })
30
31
  when "create"
31
32
  auto_found_routes << base_opts.merge({
32
- url: controller_as_url,
33
+ url: controller_path,
33
34
  method: "POST",
34
35
  action_name: action_name,
35
36
  })
36
37
  when "show"
37
38
  auto_found_routes << base_opts.merge({
38
- url: controller_as_url + "/:id",
39
+ url: controller_path + "/:id",
39
40
  method: "GET",
40
41
  action_name: action_name,
41
42
  })
42
43
  when "edit"
43
44
  auto_found_routes << base_opts.merge({
44
- url: controller_as_url + "/:id/edit",
45
+ url: controller_path + "/:id/edit",
45
46
  method: "GET",
46
47
  action_name: action_name,
47
48
  })
48
49
  when "update"
49
50
  auto_found_routes << base_opts.merge({
50
- url: controller_as_url + "/:id",
51
+ url: controller_path + "/:id",
51
52
  method: "PUT",
52
53
  action_name: action_name,
53
54
  })
54
55
  when "destroy"
55
56
  auto_found_routes << base_opts.merge({
56
- url: controller_as_url + "/:id",
57
+ url: controller_path + "/:id",
57
58
  method: "DELETE",
58
59
  action_name: action_name,
59
60
  })
@@ -74,7 +75,7 @@ module Jetski
74
75
  custom_path_option.split(" ")[1].gsub('"', '')
75
76
  else
76
77
  url_friendly_action_name = action_name.split("_").join("-")
77
- controller_as_url + "/#{url_friendly_action_name}"
78
+ controller_path + "/#{url_friendly_action_name}"
78
79
  end
79
80
  end
80
81
  auto_found_routes << base_opts.merge({
data/lib/jetski/router.rb CHANGED
@@ -19,6 +19,7 @@ module Jetski
19
19
  controller_name = af_route[:controller_name]
20
20
  action_name = af_route[:action_name]
21
21
  controller_file_name = af_route[:controller_file_name]
22
+ controller_path = af_route[:controller_path]
22
23
 
23
24
  server.mount_proc served_url do |req, res|
24
25
  errors = []
@@ -39,6 +40,7 @@ module Jetski
39
40
  controller = controller_class.new(res)
40
41
  controller.action_name = action_name
41
42
  controller.controller_name = controller_name
43
+ controller.controller_path = controller_path
42
44
  controller.send(action_name)
43
45
  if !controller.performed_render && (request_method.upcase == "GET")
44
46
  controller.render
@@ -1,3 +1,3 @@
1
1
  module Jetski
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jetski
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indigo Tech Tutorials