jetski 0.3.1 → 0.3.3

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: d01eb3967fa2528047cd44f6febbce3812545582bfd41578bc80c75dcd88d198
4
+ data.tar.gz: 787d378ad536c27338201f829f51e3727aa87f9f54e7090d18104087f2e63f91
5
5
  SHA512:
6
- metadata.gz: 3186f1f38ab5fd20ddbd24f6c3e9958f34e44161269333c83b1ae42208e64d4016ed03354458c4a7540c4e38784120a9ff8e971279465b2d66156d9909c0a7c3
7
- data.tar.gz: 1b6674aaffba2a6054bd0d07e9923d5c0bf43df333572e4b81f9474c2d671d01c3ad63b987d0625a794012c227003b831c97ce3b956e7e3b655985f35677400c
6
+ metadata.gz: c35e892800c34e6c3f4bcad62b96d98d547f9380564e363b954df9719c33af9f22626f22a008c6d47135b047d8c5a317605471672bff142f4fa0515c1aa167a3
7
+ data.tar.gz: a2b9a659f588215404a3435688dd250917c179b7aecade731bd56efc5863fe6ca694abd257dd569b2746cd374f05c2d8b18980cb7dac7667a4f2c080eb509b44
data/bin/jetski CHANGED
@@ -12,6 +12,8 @@ class JetskiCLI < Thor
12
12
  FileUtils.mkdir_p(name)
13
13
  say "Creating #{name} app with Jetski!"
14
14
  directory "base", "#{name}"
15
+ gsub_file "#{name}/app/views/layouts/application.html", /APP_NAME/, name.capitalize
16
+ gsub_file "#{name}/app/views/pages/home.html", /APP_NAME/, name.capitalize
15
17
  run "cd #{name} && bundle install"
16
18
  say "Your app #{name} has been generated!"
17
19
  say "Start you're app fast with this command"
@@ -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
@@ -73,10 +75,10 @@ module Jetski
73
75
 
74
76
  def host_images
75
77
  # TODO: Expand this to support more types of images.
76
-
77
- image_files = Dir[
78
- File.join(Jetski.app_root, 'app/assets/images/*.jpg')
79
- ]
78
+ file_ext_types = ["png", "jpg"]
79
+ image_files = Dir.glob(
80
+ file_ext_types.map { |ext| File.join(Jetski.app_root, "app/assets/images/*.#{ext}") }
81
+ )
80
82
  image_files.each do |file_path|
81
83
  filename = file_path.split("/").last
82
84
  asset_url = "/#{filename}"
@@ -1,3 +1,3 @@
1
1
  module Jetski
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -0,0 +1,16 @@
1
+ .home-page {
2
+ --primary-color: hsl(240, 63%, 45%);
3
+ --secondary-color: hsl(202, 66%, 40%);
4
+
5
+ min-height: 100vh;
6
+ width: 100%;
7
+ background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
8
+ display: flex;
9
+ justify-content: center;
10
+ align-items: center;
11
+
12
+ .header {
13
+ font-size: 64px;
14
+ color: hsl(from var(--primary-color) h s calc(l + 50))
15
+ }
16
+ }
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title> Jetski app </title>
6
+ <title> APP_NAME </title>
7
7
  <link rel="stylesheet" href="/application.css">
8
8
  <link rel="icon" type="image/x-icon" href="/jetski-logo.png">
9
9
  DYNAMIC_CSS
@@ -1 +1,3 @@
1
- <h1> Welcome to your first jetski app! </h1>
1
+ <div class="home-page">
2
+ <h1 class="header"> APP_NAME </h1>
3
+ </div>
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indigo Tech Tutorials
@@ -55,6 +55,7 @@ files:
55
55
  - templates/base/Gemfile
56
56
  - templates/base/app/assets/images/jetski-logo.png
57
57
  - templates/base/app/assets/stylesheets/application.css
58
+ - templates/base/app/assets/stylesheets/pages.css
58
59
  - templates/base/app/controllers/pages_controller.rb
59
60
  - templates/base/app/views/layouts/application.html
60
61
  - templates/base/app/views/pages/home.html