raithon-cli 0.1.0 → 0.1.1

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: d42d3361021adfa43ff5c8c43b053061cc9071e41fe5ec489783c49f7f19924d
4
- data.tar.gz: f57edfd3012c06316567bbc1704635a5ea817bb34bf066fa006685ebc7ace432
3
+ metadata.gz: 6c8b0af64eca4c6a4af305c562ce02a32dd645628d2943296d0794879657ef67
4
+ data.tar.gz: a11298bf045ef9f7eb5c1fb0d126f79298027f198a71911640ebac8cfb8e4d40
5
5
  SHA512:
6
- metadata.gz: 24ab0ec74ffa00c1f4f42059f3dc501e8727b85f54c52d29d84dc50b669e554abdd6bc359aca7e7ca83c1a17d8a8c257b7a92a45c0fcedd126804d38ced1d605
7
- data.tar.gz: c3c8db6d4d27e58768a94e0a40ed7d3c4ee8de1f0e49448074c6435ab754f26374a7b7e7149cbc294de24bb257dc985bcc3fa3dbea6157ba80d9fa9d69c3bd65
6
+ metadata.gz: 540ae5d4699a6bbf13e8e9d83d1d221fc1c7b4344659cd177468fca12c727c02d9de6bbd9ff4bc8cd8363938a44a11f54a6a52d06fdf20dc69148f52de213410
7
+ data.tar.gz: 0b36b7d5694e5d214d789da7870f9340b11279490bd296aea3587fe508a6d9390128c50b874a9811ca0be647a791384c4b97d1fa2d17b82f356e2c8d7ba73ef2
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Raithon
4
4
  module CLI
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -0,0 +1,137 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require "fileutils"
5
+ require "raithon-core"
6
+
7
+ module Raithon
8
+ class CLI < Thor
9
+ desc "new APP_NAME", "Create a new Raithon application"
10
+ def new(app_name)
11
+ @app_name = app_name
12
+
13
+ say "Creating Raithon app: #{app_name}"
14
+ create_structure
15
+ say "Application #{app_name} created successfully."
16
+ end
17
+
18
+ private
19
+
20
+ def app_path(*paths)
21
+ File.join(@app_name, *paths)
22
+ end
23
+
24
+ def create_structure
25
+ create_root
26
+ create_app_folders
27
+ create_config_files
28
+ create_lib_file
29
+ create_gitignore
30
+ create_gemfile
31
+ end
32
+
33
+ def create_root
34
+ FileUtils.mkdir_p(@app_name)
35
+ end
36
+
37
+ def create_app_folders
38
+ %w[
39
+ app/controllers
40
+ app/models
41
+ app/views
42
+ config
43
+ lib
44
+ ].each do |path|
45
+ FileUtils.mkdir_p(app_path(path))
46
+ end
47
+
48
+ File.write(
49
+ app_path("app/controllers/application_controller.rb"),
50
+ <<~RUBY
51
+ # frozen_string_literal: true
52
+
53
+ class ApplicationController
54
+ def index
55
+ "Welcome to Raithon!"
56
+ end
57
+ end
58
+ RUBY
59
+ )
60
+ end
61
+
62
+ def create_config_files
63
+ File.write(
64
+ app_path("config/application.rb"),
65
+ <<~RUBY
66
+ # frozen_string_literal: true
67
+
68
+ require "raithon-core"
69
+
70
+ module #{camelize(@app_name)}
71
+ class Application < Raithon::Core::Application
72
+ def boot
73
+ puts "Booting \#{self.class.name}..."
74
+ end
75
+ end
76
+ end
77
+ RUBY
78
+ )
79
+
80
+ File.write(
81
+ app_path("config/routes.rb"),
82
+ <<~RUBY
83
+ # frozen_string_literal: true
84
+
85
+ # Define your routes here
86
+ #
87
+ # Example:
88
+ # get "/", to: "application#index"
89
+ RUBY
90
+ )
91
+ end
92
+
93
+ def create_lib_file
94
+ File.write(
95
+ app_path("lib/#{@app_name}.rb"),
96
+ <<~RUBY
97
+ # frozen_string_literal: true
98
+
99
+ module #{camelize(@app_name)}
100
+ # Your Raithon app code goes here
101
+ end
102
+ RUBY
103
+ )
104
+ end
105
+
106
+ def create_gitignore
107
+ File.write(
108
+ app_path(".gitignore"),
109
+ <<~TXT
110
+ /log/*
111
+ /tmp/*
112
+ .env
113
+ TXT
114
+ )
115
+ end
116
+
117
+ def create_gemfile
118
+ File.write(
119
+ app_path("Gemfile"),
120
+ <<~RUBY
121
+ # frozen_string_literal: true
122
+
123
+ source "https://rubygems.org"
124
+
125
+ gem "raithon-core", "~> 0.1.0"
126
+ RUBY
127
+ )
128
+ end
129
+
130
+ # ----------------------------
131
+ # Helpers
132
+ # ----------------------------
133
+ def camelize(str)
134
+ str.split("_").map(&:capitalize).join
135
+ end
136
+ end
137
+ end
data/lib/raithon.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "raithon/cli"
3
+ require "raithon"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raithon-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensei James
@@ -50,6 +50,7 @@ files:
50
50
  - bin/raithon
51
51
  - lib/raithon-cli.rb
52
52
  - lib/raithon.rb
53
+ - lib/raithon/cli.rb
53
54
  - lib/raithon/cli/cli.rb
54
55
  - lib/raithon/cli/version.rb
55
56
  homepage: https://rubygems.org/gems/raithon-cli