moon-stack 0.1.0 → 0.2.0

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: f95e318fbf5552586d120374e8bed6a12e08e61a9a8241c0df3b20586d5ca2b5
4
- data.tar.gz: 76dc4f7e66adc6df37274a899d23fa7901038c2a9471f06925a6b61f8a5d4c95
3
+ metadata.gz: 909650753167a9e90d97cf1c58f7d05cbda06c5f1abf1dd7905f1bb6785c6ae3
4
+ data.tar.gz: 681de4937bc0d896d57913948f5e237b32863ab039c482b45c0cfa951c5b8c54
5
5
  SHA512:
6
- metadata.gz: e1a242928911758ef3e9974db8269c8c8dd22aef8fe37898bbe34fac2f29ff3224109051b9a207f9f878b675fa87556a0960138687072eb93634113996b269ca
7
- data.tar.gz: cbe3ec06f7117ba8728d7625907e7ae813122ea2cb50d06fbbdb8aa5ff0d3cdf10dd85e28373841060f1071803fa3756a52a905b226063fa99e004ce6c184e84
6
+ metadata.gz: e10492ebd5a291ff9dbb57d167cf8c2afa4ce50b349a83d441f5292635d65189e62606fc49ae73102eb9adb26c7d22e1a74d06f4ad92ff75a51884ec9e246bdb
7
+ data.tar.gz: 5ae7265e49402ca17343f2b99c4e9e1e0de57df267d5c3fa61431c51043357ca0c1c79e4d7226a98fe63f89db6c55da42b6278823580b607c9cf6d10f4e3b9d2
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
- Copyright (c) 2026 tsuki
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2026 tsuki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,55 +1,55 @@
1
- # Moon Stack 🌙
2
-
3
- Moon Stack is a stack, not a framework.
4
-
5
- It doesn't reinvent routing, databases, styling, or HTTP.
6
-
7
- It brings together tools that already do those jobs well and provides a convenient starting point for Ruby web apps.
8
-
9
- Use what you want. Replace what you don't.
10
-
11
- Happy hacking under the moon 🌙
12
-
13
- ## Stack
14
-
15
- - Ruby
16
- - Sinatra
17
- - Rack
18
- - Puma
19
- - Sequel
20
- - SQLite
21
- - ERB
22
- - htmx
23
- - Tailwind CSS
24
-
25
- ## Install
26
-
27
- ```bash
28
- gem install moon-stack
29
- ```
30
-
31
- ## Create an app
32
-
33
- ```bash
34
- moon new myapp
35
- cd myapp
36
- bundle install
37
- bundle exec puma
38
- ```
39
-
40
- Then open:
41
-
42
- ```text
43
- http://localhost:6767
44
- ```
45
-
46
- ## Philosophy
47
-
48
- Moon Stack generates normal Ruby files.
49
-
50
- There is no Moon runtime.
51
-
52
- Once your app has been generated, Moon Stack is no longer required.
53
-
54
- Replace anything you want.
55
-
1
+ # Moon Stack 🌙
2
+
3
+ Moon Stack is a stack, not a framework.
4
+
5
+ It doesn't reinvent routing, databases, styling, or HTTP.
6
+
7
+ It brings together tools that already do those jobs well and provides a convenient starting point for Ruby web apps.
8
+
9
+ Use what you want. Replace what you don't.
10
+
11
+ Happy hacking under the moon 🌙
12
+
13
+ ## Stack
14
+
15
+ - Ruby
16
+ - Sinatra
17
+ - Rack
18
+ - Puma
19
+ - Sequel
20
+ - SQLite
21
+ - ERB
22
+ - htmx
23
+ - Tailwind CSS
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ gem install moon-stack
29
+ ```
30
+
31
+ ## Create an app
32
+
33
+ ```bash
34
+ moon new myapp
35
+ cd myapp
36
+ bundle install
37
+ bundle exec puma
38
+ ```
39
+
40
+ Then open:
41
+
42
+ ```text
43
+ http://localhost:6767
44
+ ```
45
+
46
+ ## Philosophy
47
+
48
+ Moon Stack generates normal Ruby files.
49
+
50
+ There is no Moon runtime.
51
+
52
+ Once your app has been generated, Moon Stack is no longer required.
53
+
54
+ Replace anything you want.
55
+
data/bin/moon CHANGED
@@ -1,27 +1,56 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'moon_stack'
4
-
5
- command = ARGV.shift
6
-
7
- case command
8
- when 'new'
9
- name = ARGV.shift
10
-
11
- abort 'Usage: moon new APP_NAME' unless name
12
-
13
- MoonStack::Generator.new(name).run
14
- when '--version', '-v'
15
- puts "Moon Stack #{MoonStack::VERSION}"
16
- when '--help', '-h', nil
17
- puts <<~HELP
18
- Moon Stack 🌙
19
-
20
- Usage:
21
- moon new APP_NAME
22
- moon --version
23
- moon --help
24
- HELP
25
- else
26
- abort "Unknown command: #{command}"
27
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'moon_stack'
4
+
5
+ VALID_DATABASES = %w[sqlite postgresql mysql].freeze
6
+ DEFAULT_DATABASE = 'sqlite'.freeze
7
+
8
+ def parse_database_option(args)
9
+ flag = args.find { |arg| arg.start_with?('--database=') }
10
+ return DEFAULT_DATABASE unless flag
11
+
12
+ db = flag.split('=', 2).last.to_s.downcase
13
+ unless VALID_DATABASES.include?(db)
14
+ abort <<~MSG
15
+ Unknown database: #{db}
16
+ Supported: #{VALID_DATABASES.join(', ')}
17
+ MSG
18
+ end
19
+ db
20
+ end
21
+
22
+ command = ARGV.shift
23
+
24
+ case command
25
+ when 'new'
26
+ name = ARGV.shift
27
+
28
+ abort 'Usage: moon new APP_NAME [--database=sqlite|postgresql|mysql]' unless name
29
+
30
+ database = parse_database_option(ARGV)
31
+
32
+ MoonStack::Generator.new(name, database: database).run
33
+ when '--version', '-v'
34
+ puts "Moon Stack #{MoonStack::VERSION}"
35
+ when '--help', '-h', nil
36
+ puts <<~HELP
37
+ Moon Stack 🌙
38
+
39
+ Usage:
40
+ moon new APP_NAME [--database=DATABASE]
41
+ moon --version
42
+ moon --help
43
+
44
+ Databases:
45
+ sqlite (default)
46
+ postgresql
47
+ mysql
48
+
49
+ Examples:
50
+ moon new blog
51
+ moon new blog --database=postgresql
52
+ moon new shop --database=mysql
53
+ HELP
54
+ else
55
+ abort "Unknown command: #{command}"
56
+ end
@@ -1,63 +1,108 @@
1
- require 'fileutils'
2
-
3
- module MoonStack
4
- class Generator
5
- TEMPLATE_DIR = File.expand_path('../../templates', __dir__)
6
-
7
- def initialize(name)
8
- @name = name
9
- @destination = File.expand_path(name)
10
- end
11
-
12
- def run
13
- abort "Directory already exists: #{@name}" if Dir.exist?(@destination)
14
-
15
- puts
16
- puts "🌙 Creating #{@name}..."
17
- puts
18
-
19
- create_directories
20
- copy_templates
21
-
22
- puts
23
- puts 'Moon app ready 🌙'
24
- puts
25
- puts 'Run:'
26
- puts
27
- puts " cd #{@name}"
28
- puts ' bundle install'
29
- puts ' bundle exec puma'
30
- puts
31
- end
32
-
33
- private
34
-
35
- def create_directories
36
- FileUtils.mkdir_p(@destination)
37
- FileUtils.mkdir_p(File.join(@destination, 'views'))
38
- FileUtils.mkdir_p(File.join(@destination, 'public'))
39
- FileUtils.mkdir_p(File.join(@destination, 'config'))
40
- end
41
-
42
- def copy_templates
43
- files = [
44
- '.gitignore',
45
- 'Gemfile',
46
- 'app.rb',
47
- 'config.ru',
48
- 'db.rb',
49
- 'views/layout.erb',
50
- 'views/index.erb',
51
- 'config/puma.rb'
52
- ]
53
- files.each do |file|
54
- source = File.join(TEMPLATE_DIR, file)
55
- destination = File.join(@destination, file)
56
-
57
- FileUtils.cp(source, destination)
58
-
59
- puts " create #{file}"
60
- end
61
- end
62
- end
63
- end
1
+ require 'fileutils'
2
+
3
+ module MoonStack
4
+ class Generator
5
+ TEMPLATE_DIR = File.expand_path('../../templates', __dir__)
6
+ VALID_DATABASES = %w[sqlite postgresql mysql].freeze
7
+
8
+ def initialize(name, database: 'sqlite')
9
+ @name = name
10
+ @database = database.to_s.downcase
11
+ @destination = File.expand_path(name)
12
+
13
+ unless VALID_DATABASES.include?(@database)
14
+ abort "Invalid database: #{@database}. Supported: #{VALID_DATABASES.join(', ')}"
15
+ end
16
+ end
17
+
18
+ def run
19
+ abort "Directory already exists: #{@name}" if Dir.exist?(@destination)
20
+
21
+ puts
22
+ puts "🌙 Creating #{@name} with #{@database} database..."
23
+ puts
24
+
25
+ create_directories
26
+ copy_templates
27
+ configure_database
28
+
29
+ puts
30
+ puts 'Moon app ready 🌙'
31
+ puts
32
+ puts 'Run:'
33
+ puts
34
+ puts " cd #{@name}"
35
+ puts ' bundle install'
36
+ puts ' bundle exec puma'
37
+ puts
38
+ end
39
+
40
+ private
41
+
42
+ def create_directories
43
+ FileUtils.mkdir_p(@destination)
44
+ FileUtils.mkdir_p(File.join(@destination, 'views'))
45
+ FileUtils.mkdir_p(File.join(@destination, 'public'))
46
+ FileUtils.mkdir_p(File.join(@destination, 'config'))
47
+ end
48
+
49
+ def copy_templates
50
+ files = [
51
+ '.gitignore',
52
+ 'Gemfile',
53
+ 'app.rb',
54
+ 'config.ru',
55
+ 'db.rb',
56
+ 'views/layout.erb',
57
+ 'views/index.erb',
58
+ 'config/puma.rb'
59
+ ]
60
+ files.each do |file|
61
+ source = File.join(TEMPLATE_DIR, file)
62
+ destination = File.join(@destination, file)
63
+
64
+ FileUtils.cp(source, destination)
65
+
66
+ puts " create #{file}"
67
+ end
68
+ end
69
+
70
+ def configure_database
71
+ return if @database == 'sqlite'
72
+
73
+ # Modyfikacja Gemfile
74
+ gemfile_path = File.join(@destination, 'Gemfile')
75
+ gemfile_content = File.read(gemfile_path)
76
+
77
+ case @database
78
+ when 'postgresql'
79
+ gemfile_content.gsub!(/gem ['"]sqlite3['"]/, "gem 'pg'")
80
+ when 'mysql'
81
+ gemfile_content.gsub!(/gem ['"]sqlite3['"]/, "gem 'mysql2'")
82
+ end
83
+
84
+ File.write(gemfile_path, gemfile_content)
85
+ puts " update Gemfile (database: #{@database})"
86
+
87
+ # Modyfikacja db.rb
88
+ db_path = File.join(@destination, 'db.rb')
89
+ db_content = File.read(db_path)
90
+
91
+ case @database
92
+ when 'postgresql'
93
+ db_content.gsub!(
94
+ /Sequel\.sqlite\(['"]app\.db['"]\)/,
95
+ "Sequel.connect(ENV['DATABASE_URL'] || 'postgres://localhost/#{@name}_db')"
96
+ )
97
+ when 'mysql'
98
+ db_content.gsub!(
99
+ /Sequel\.sqlite\(['"]app\.db['"]\)/,
100
+ "Sequel.connect(ENV['DATABASE_URL'] || 'mysql2://localhost/#{@name}_db')"
101
+ )
102
+ end
103
+
104
+ File.write(db_path, db_content)
105
+ puts " update db.rb (database: #{@database})"
106
+ end
107
+ end
108
+ end
@@ -1,3 +1,3 @@
1
- module MoonStack
2
- VERSION = '0.1.0'
3
- end
1
+ module MoonStack
2
+ VERSION = '0.2.0'
3
+ end
data/lib/moon_stack.rb CHANGED
@@ -1,2 +1,2 @@
1
- require_relative 'moon_stack/version'
2
- require_relative 'moon_stack/generator'
1
+ require_relative 'moon_stack/version'
2
+ require_relative 'moon_stack/generator'
data/templates/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
- .env
2
- *.db
3
- .bundle/
4
- vendor/bundle/
1
+ .env
2
+ *.db
3
+ .bundle/
4
+ vendor/bundle/
data/templates/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'puma'
4
- gem 'sequel'
5
- gem 'sinatra'
6
- gem 'sqlite3'
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'puma'
4
+ gem 'sequel'
5
+ gem 'sinatra'
6
+ gem 'sqlite3'
data/templates/app.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'sinatra'
2
- require_relative 'db'
3
-
4
- get '/' do
5
- erb :index
6
- end
1
+ require 'sinatra'
2
+ require_relative 'db'
3
+
4
+ get '/' do
5
+ erb :index
6
+ end
@@ -1 +1 @@
1
- port ENV.fetch('PORT', 6767)
1
+ port ENV.fetch('PORT', 6767)
data/templates/config.ru CHANGED
@@ -1,3 +1,3 @@
1
- require_relative 'app'
2
-
3
- run Sinatra::Application
1
+ require_relative 'app'
2
+
3
+ run Sinatra::Application
data/templates/db.rb CHANGED
@@ -1,3 +1,3 @@
1
- require 'sequel'
2
-
3
- DB = Sequel.sqlite('app.db')
1
+ require 'sequel'
2
+
3
+ DB = Sequel.sqlite('app.db')
@@ -1,7 +1,7 @@
1
- <h1 class="text-3xl font-bold">
2
- Hello from Moon Stack 🌙
3
- </h1>
4
-
5
- <p class="mt-4 text-zinc-400">
6
- Ruby + Sinatra + htmx under the moon.
7
- </p>
1
+ <h1 class="text-3xl font-bold">
2
+ Hello from Moon Stack 🌙
3
+ </h1>
4
+
5
+ <p class="mt-4 text-zinc-400">
6
+ Ruby + Sinatra + htmx under the moon.
7
+ </p>
@@ -1,23 +1,23 @@
1
- <!doctype html>
2
-
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8">
6
-
7
- <meta
8
- name="viewport"
9
- content="width=device-width, initial-scale=1"
10
- >
11
-
12
- <title>Moon App</title>
13
-
14
- <script src="https://unpkg.com/htmx.org"></script>
15
- <script src="https://cdn.tailwindcss.com"></script>
16
- </head>
17
-
18
- <body class="bg-zinc-950 text-zinc-100">
19
- <main class="max-w-4xl mx-auto p-6">
20
- <%= yield %>
21
- </main>
22
- </body>
23
- </html>
1
+ <!doctype html>
2
+
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+
7
+ <meta
8
+ name="viewport"
9
+ content="width=device-width, initial-scale=1"
10
+ >
11
+
12
+ <title>Moon App</title>
13
+
14
+ <script src="https://unpkg.com/htmx.org"></script>
15
+ <script src="https://cdn.tailwindcss.com"></script>
16
+ </head>
17
+
18
+ <body class="bg-zinc-950 text-zinc-100">
19
+ <main class="max-w-4xl mx-auto p-6">
20
+ <%= yield %>
21
+ </main>
22
+ </body>
23
+ </html>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moon-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tsuki
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 4.0.16
49
+ rubygems_version: 4.0.20
50
50
  specification_version: 4
51
51
  summary: A small Ruby web stack starter
52
52
  test_files: []