jetski 0.3.3 → 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 +10 -4
- data/bin/jetski_cli_helpers/destroy.rb +15 -0
- data/bin/jetski_cli_helpers/generate.rb +31 -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 +2 -2
- data/lib/jetski/version.rb +1 -1
- metadata +13 -9
- /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/assets/stylesheets/pages.css +0 -0
- /data/{templates → bin/templates}/base/app/controllers/pages_controller.rb +0 -0
- /data/{templates → bin/templates}/base/app/views/layouts/application.html +0 -0
- /data/{templates → bin/templates}/base/app/views/pages/home.html +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
|
|
@@ -15,9 +17,7 @@ class JetskiCLI < Thor
|
|
|
15
17
|
gsub_file "#{name}/app/views/layouts/application.html", /APP_NAME/, name.capitalize
|
|
16
18
|
gsub_file "#{name}/app/views/pages/home.html", /APP_NAME/, name.capitalize
|
|
17
19
|
run "cd #{name} && bundle install"
|
|
18
|
-
say "Your app #{name} has been generated!"
|
|
19
|
-
say "Start you're app fast with this command"
|
|
20
|
-
say "cd #{name} && ruby ./start.rb"
|
|
20
|
+
say "🌊 Your app #{name} has been generated!"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
desc "-v, --version", "show Jetski version"
|
|
@@ -33,9 +33,15 @@ class JetskiCLI < Thor
|
|
|
33
33
|
say "#{route_obj[:method]} #{route_obj[:url]} #{route_obj[:controller_name]}##{route_obj[:action_name]}"
|
|
34
34
|
end
|
|
35
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
|
|
36
42
|
|
|
37
43
|
def self.source_root
|
|
38
|
-
File.join(File.dirname(__FILE__), '
|
|
44
|
+
File.join(File.dirname(__FILE__), 'templates')
|
|
39
45
|
end
|
|
40
46
|
end
|
|
41
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
|
|
@@ -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}"))
|
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,20 +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/assets/stylesheets/pages.css
|
|
59
|
-
- templates/base/app/controllers/pages_controller.rb
|
|
60
|
-
- templates/base/app/views/layouts/application.html
|
|
61
|
-
- templates/base/app/views/pages/home.html
|
|
62
|
-
- templates/base/start.rb
|
|
63
67
|
homepage: https://rubygems.org/gems/jetski
|
|
64
68
|
licenses:
|
|
65
69
|
- MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|