rsodx 0.0.1 → 0.0.2

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.
@@ -1,133 +0,0 @@
1
- module Rsodx::Cli
2
- class Scaffold
3
- attr_reader :name
4
-
5
- RUBY_VERSION = "3.4.2".freeze
6
-
7
- # path: "../rsodx"
8
- GEMFILE = <<~GEMFILE.freeze
9
- source "https://rubygems.org"
10
-
11
- gem "rsodx"
12
- gem "pg"
13
- GEMFILE
14
-
15
- BINRSODX = <<~BINRSODX.freeze
16
- #!/usr/bin/env ruby
17
-
18
- require "fileutils"
19
- require "optparse"
20
- require "rsodx"
21
-
22
- if __FILE__ == $0
23
- Rsodx::Cli::Handler.run
24
- end
25
- BINRSODX
26
-
27
- CONSOLE = <<~CONSOLE.freeze
28
- #!/usr/bin/env ruby
29
-
30
- require "irb"
31
- require "irb/completion"
32
-
33
- def reload!
34
- puts "🔄 Reloading..."
35
- load File.expand_path("../config/environment.rb", __dir__)
36
- end
37
-
38
- require_relative "../config/environment"
39
-
40
- puts "🔬 Welcome to Rsodx console (#{ENV['RACK_ENV'] || 'development'})"
41
- puts "Tip: access Rsodx modules, models, interactors, etc."
42
-
43
- IRB.start
44
- CONSOLE
45
-
46
- CONFIGRU = <<~RACK.freeze
47
- require_relative "./app/app"
48
- run App
49
- RACK
50
-
51
- ROUTE = <<~ROUTE.freeze
52
- class Router < Rsodx::Router
53
- get "/healthcheck", Rsodx::Interactors::Healthcheck
54
- end
55
- ROUTE
56
-
57
- APP = <<~APP.freeze
58
- require "rsodx"
59
- require_relative "router"
60
-
61
- class App < Rsodx::Base
62
- use Router
63
- end
64
- APP
65
-
66
- APP_INTERACTOR = <<~APP_INTERACTOR.freeze
67
- class AppInteractor < Rsodx::Interactor
68
- end
69
- APP_INTERACTOR
70
-
71
- RAKEFILE = <<~RAKEFILE.freeze
72
- require_relative "config/environment"
73
- require "rsodx/tasks"
74
- RAKEFILE
75
-
76
- ENVFILE = <<~ENVFILE.freeze
77
- DATABASE_URL=postgres://user:password@localhost:5432/base_development
78
- ENVFILE
79
-
80
- FOLDERS = %w[app/api app/interactors app/models app/presenters
81
- app/serializers config/initializers
82
- config/environments db/migrations spec bin].freeze
83
-
84
- def initialize(name)
85
- @name = name
86
- @app_path = File.join(Dir.pwd, name)
87
- end
88
-
89
- def create
90
- puts "Creating project: #{name}"
91
- create_folders
92
- create_files
93
- puts "✅ Done!"
94
- end
95
-
96
- def create_folders
97
- FOLDERS.each do |path|
98
- FileUtils.mkdir_p(File.join(@app_path, path))
99
- end
100
- end
101
-
102
- def create_files
103
- write("Gemfile", GEMFILE)
104
- write(".ruby-version", RUBY_VERSION)
105
- write(".env", ENVFILE)
106
- write("config/environment.rb", env_loader)
107
- write("Rakefile", RAKEFILE)
108
- write("app/interactors/app_interactor.rb", APP_INTERACTOR)
109
- write("app/app.rb", APP)
110
- write("app/router.rb", ROUTE)
111
- write("config/environments/development.rb", "")
112
- write("config.ru", CONFIGRU)
113
- write("bin/console", CONSOLE)
114
- write("bin/rsodx", BINRSODX)
115
- FileUtils.chmod("+x", File.join(@app_path, "bin/console"))
116
- end
117
-
118
- def write(relative_path, content)
119
- full_path = File.join(@app_path, relative_path)
120
- File.write(full_path, content)
121
- end
122
-
123
- def env_loader
124
- <<~RB
125
- require "rsodx"
126
- Rsodx::Environment.load_dotenv(ENV["RACK_ENV"] || "development")
127
- Rsodx::Connect.connect ENV["DATABASE_URL"]
128
- Rsodx::Environment.load_initializers(File.expand_path("../..", __FILE__))
129
- Rsodx::Boot.load_app_structure(File.expand_path("../..", __FILE__))
130
- RB
131
- end
132
- end
133
- end
@@ -1,12 +0,0 @@
1
- require "rack/handler/puma"
2
- module Rsodx::Cli
3
- class Server
4
- def self.run
5
- pid = spawn("bundle exec rake server")
6
- Process.wait(pid)
7
- puts "🚀 Starting Rsodx server PID: #{pid} at http://localhost:9292"
8
- rescue LoadError => e
9
- abort "❌ Error #{e.message}"
10
- end
11
- end
12
- end
@@ -1,7 +0,0 @@
1
- module Rsodx::Interactors
2
- class Healthcheck < Rsodx::Interactor
3
- def call
4
- context.data = { ok: true }
5
- end
6
- end
7
- end