jetski 0.3.2 → 0.3.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/bin/jetski +12 -4
- data/bin/jetski_cli_helpers/destroy.rb +15 -0
- data/bin/jetski_cli_helpers/generate.rb +31 -0
- data/bin/templates/base/app/assets/stylesheets/pages.css +16 -0
- data/{templates → bin/templates}/base/app/views/layouts/application.html +1 -1
- data/bin/templates/base/app/views/pages/home.html +3 -0
- data/bin/templates/controllers/example_controller +3 -0
- data/bin/templates/views/example.html +2 -0
- data/lib/jetski/base_controller.rb +5 -0
- data/lib/jetski/router.rb +6 -6
- data/lib/jetski/version.rb +1 -1
- metadata +13 -8
- data/templates/base/app/views/pages/home.html +0 -1
- /data/{templates → bin/templates}/base/Gemfile +0 -0
- /data/{templates → bin/templates}/base/app/assets/images/jetski-logo.png +0 -0
- /data/{templates → bin/templates}/base/app/assets/stylesheets/application.css +0 -0
- /data/{templates → bin/templates}/base/app/controllers/pages_controller.rb +0 -0
- /data/{templates → bin/templates}/base/start.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1746870a727a12ac5a50fcda0a087b09c38c001792c231228171b51daa2157e
|
|
4
|
+
data.tar.gz: 39d1679fde3e431e227e83fd18599c36e81bf6bc4f4bfd8a8c271c54a5f2dc99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5af7934d40d93fcf134268a9ae8a1f8cb868e36f198785c535e133561896684eafb4c8164899fb6fae6a50ddeb4eab60d1623f50da4a82a767b094bb274f020
|
|
7
|
+
data.tar.gz: 6795ff302861de5b124a085060dab9aef87c8fc68debba5d7cf27ae20558d033a9a6a6296d9e39263e48c796e347483e9a254834be86ac9e694ca6705fee3c45
|
data/bin/jetski
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
require 'optparse'
|
|
4
4
|
require 'jetski'
|
|
5
5
|
require 'thor'
|
|
6
|
+
require_relative './jetski_cli_helpers/generate.rb'
|
|
7
|
+
require_relative './jetski_cli_helpers/destroy.rb'
|
|
6
8
|
|
|
7
9
|
class JetskiCLI < Thor
|
|
8
10
|
include Thor::Actions
|
|
@@ -12,10 +14,10 @@ class JetskiCLI < Thor
|
|
|
12
14
|
FileUtils.mkdir_p(name)
|
|
13
15
|
say "Creating #{name} app with Jetski!"
|
|
14
16
|
directory "base", "#{name}"
|
|
17
|
+
gsub_file "#{name}/app/views/layouts/application.html", /APP_NAME/, name.capitalize
|
|
18
|
+
gsub_file "#{name}/app/views/pages/home.html", /APP_NAME/, name.capitalize
|
|
15
19
|
run "cd #{name} && bundle install"
|
|
16
|
-
say "Your app #{name} has been generated!"
|
|
17
|
-
say "Start you're app fast with this command"
|
|
18
|
-
say "cd #{name} && ruby ./start.rb"
|
|
20
|
+
say "🌊 Your app #{name} has been generated!"
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
desc "-v, --version", "show Jetski version"
|
|
@@ -31,9 +33,15 @@ class JetskiCLI < Thor
|
|
|
31
33
|
say "#{route_obj[:method]} #{route_obj[:url]} #{route_obj[:controller_name]}##{route_obj[:action_name]}"
|
|
32
34
|
end
|
|
33
35
|
end
|
|
36
|
+
|
|
37
|
+
desc "generate", "generates resources in your jetski app"
|
|
38
|
+
subcommand "generate", JetskiCLIHelpers::Generate
|
|
39
|
+
|
|
40
|
+
desc "destroy", "destroys a resource in your jetski app"
|
|
41
|
+
subcommand "destroy", JetskiCLIHelpers::Destroy
|
|
34
42
|
|
|
35
43
|
def self.source_root
|
|
36
|
-
File.join(File.dirname(__FILE__), '
|
|
44
|
+
File.join(File.dirname(__FILE__), 'templates')
|
|
37
45
|
end
|
|
38
46
|
end
|
|
39
47
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
module JetskiCLIHelpers
|
|
3
|
+
class Destroy < Thor
|
|
4
|
+
include Thor::Actions
|
|
5
|
+
desc "controller NAME ACTION_NAMES", "Destroys a controller with matching actions"
|
|
6
|
+
def controller(name, *actions)
|
|
7
|
+
controller_file_path = "app/controllers/#{name}_controller.rb"
|
|
8
|
+
remove_file(controller_file_path)
|
|
9
|
+
actions.each do |action_name|
|
|
10
|
+
view_folder = "app/views/#{name}"
|
|
11
|
+
remove_dir(view_folder)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
module JetskiCLIHelpers
|
|
3
|
+
class Generate < Thor
|
|
4
|
+
include Thor::Actions
|
|
5
|
+
desc "controller NAME ACTION_NAMES", "Create a controller with matching actions"
|
|
6
|
+
def controller(name, *actions)
|
|
7
|
+
controller_file_path = "app/controllers/#{name}_controller.rb"
|
|
8
|
+
copy_file("controllers/example_controller", controller_file_path)
|
|
9
|
+
gsub_file(controller_file_path, /CONTROLLER_NAME/, name.capitalize)
|
|
10
|
+
actions.each.with_index do |action_name, idx|
|
|
11
|
+
action_content = "def #{action_name}\n end"
|
|
12
|
+
if actions.size < (idx + 1)
|
|
13
|
+
action_content += "\nACTION_NAME"
|
|
14
|
+
end
|
|
15
|
+
gsub_file(controller_file_path, /ACTION_NAME/, action_content.strip)
|
|
16
|
+
path_to_view = "app/views/#{name}/#{action_name}.html"
|
|
17
|
+
|
|
18
|
+
empty_directory("app/views/#{name}")
|
|
19
|
+
copy_file("views/example.html", path_to_view)
|
|
20
|
+
gsub_file(path_to_view, /CONTROLLER_NAME/, name)
|
|
21
|
+
gsub_file(path_to_view, /ACTION_NAME/, action_name)
|
|
22
|
+
gsub_file(path_to_view, /PATH_TO_VIEW/, path_to_view)
|
|
23
|
+
say "🌊 View your new page at http://localhost:8000/#{name}/#{action_name}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.source_root
|
|
28
|
+
File.join(File.dirname(__FILE__), '..', 'templates')
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
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>
|
|
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
|
|
@@ -45,6 +45,11 @@ module Jetski
|
|
|
45
45
|
render_template_file
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
def redirect_to(url)
|
|
49
|
+
@performed_render = true
|
|
50
|
+
res.set_redirect(WEBrick::HTTPStatus::Found, url)
|
|
51
|
+
end
|
|
52
|
+
|
|
48
53
|
private
|
|
49
54
|
def render_template_file
|
|
50
55
|
views_folder = File.join(Jetski.app_root, 'app/views')
|
data/lib/jetski/router.rb
CHANGED
|
@@ -63,9 +63,9 @@ module Jetski
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def host_css
|
|
66
|
-
css_files = Dir[File.join(Jetski.app_root,'app/assets/stylesheets
|
|
66
|
+
css_files = Dir[File.join(Jetski.app_root,'app/assets/stylesheets/**/*.css')]
|
|
67
67
|
css_files.each do |file_path|
|
|
68
|
-
filename
|
|
68
|
+
filename = file_path.split("app/assets/stylesheets/").last
|
|
69
69
|
asset_url = "/#{filename}"
|
|
70
70
|
server.mount_proc asset_url do |req, res|
|
|
71
71
|
res.body = File.read(File.join(Jetski.app_root,"app/assets/stylesheets/#{filename}"))
|
|
@@ -75,10 +75,10 @@ module Jetski
|
|
|
75
75
|
|
|
76
76
|
def host_images
|
|
77
77
|
# TODO: Expand this to support more types of images.
|
|
78
|
-
|
|
79
|
-
image_files = Dir
|
|
80
|
-
File.join(Jetski.app_root,
|
|
81
|
-
|
|
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
|
+
)
|
|
82
82
|
image_files.each do |file_path|
|
|
83
83
|
filename = file_path.split("/").last
|
|
84
84
|
asset_url = "/#{filename}"
|
data/lib/jetski/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Indigo Tech Tutorials
|
|
@@ -46,19 +46,24 @@ extensions: []
|
|
|
46
46
|
extra_rdoc_files: []
|
|
47
47
|
files:
|
|
48
48
|
- bin/jetski
|
|
49
|
+
- bin/jetski_cli_helpers/destroy.rb
|
|
50
|
+
- bin/jetski_cli_helpers/generate.rb
|
|
51
|
+
- bin/templates/base/Gemfile
|
|
52
|
+
- bin/templates/base/app/assets/images/jetski-logo.png
|
|
53
|
+
- bin/templates/base/app/assets/stylesheets/application.css
|
|
54
|
+
- bin/templates/base/app/assets/stylesheets/pages.css
|
|
55
|
+
- bin/templates/base/app/controllers/pages_controller.rb
|
|
56
|
+
- bin/templates/base/app/views/layouts/application.html
|
|
57
|
+
- bin/templates/base/app/views/pages/home.html
|
|
58
|
+
- bin/templates/base/start.rb
|
|
59
|
+
- bin/templates/controllers/example_controller
|
|
60
|
+
- bin/templates/views/example.html
|
|
49
61
|
- lib/jetski.rb
|
|
50
62
|
- lib/jetski/base_controller.rb
|
|
51
63
|
- lib/jetski/router.rb
|
|
52
64
|
- lib/jetski/router/parser.rb
|
|
53
65
|
- lib/jetski/server.rb
|
|
54
66
|
- lib/jetski/version.rb
|
|
55
|
-
- templates/base/Gemfile
|
|
56
|
-
- templates/base/app/assets/images/jetski-logo.png
|
|
57
|
-
- templates/base/app/assets/stylesheets/application.css
|
|
58
|
-
- templates/base/app/controllers/pages_controller.rb
|
|
59
|
-
- templates/base/app/views/layouts/application.html
|
|
60
|
-
- templates/base/app/views/pages/home.html
|
|
61
|
-
- templates/base/start.rb
|
|
62
67
|
homepage: https://rubygems.org/gems/jetski
|
|
63
68
|
licenses:
|
|
64
69
|
- MIT
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h1> Welcome to your first jetski app! </h1>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|