ru.Bee 2.7.0 → 2.7.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.
- checksums.yaml +4 -4
- data/lib/config.ru +6 -1
- data/lib/db/test.db +0 -0
- data/lib/inits/print_colors.rb +8 -8
- data/lib/rubee/cli/routes.rb +82 -1
- data/lib/rubee/cli/server.rb +4 -4
- data/lib/rubee/configuration.rb +10 -0
- data/lib/rubee.rb +7 -1
- data/readme.md +37 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 856d6debfef7fe3c8770c35cb99649c7ec65d26d473e82f33a9532c55c987f82
|
|
4
|
+
data.tar.gz: '08c1cca3fd9e313d264d8eae3f40049ba5cd0143b478932a020eaa3fc3b6a50e'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a95420adf54d8563220127373127bdd8a73e4da95000346a7ec141a849368fcf0e6c7d97a277d4b1a085c0d2705744a8970812f7080bdd4d0249ae88b12c4ff
|
|
7
|
+
data.tar.gz: '06086984925c218c6878b59ac6f213f34360508278c64fc12e68fbba3ee399cc76147f03dabef3f5c634d53996f78c747467deef9aa9d8f48356dca66c1bb78e'
|
data/lib/config.ru
CHANGED
data/lib/db/test.db
CHANGED
|
Binary file
|
data/lib/inits/print_colors.rb
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
# WARNING: DO NOT EDIT THIS FILE UNLESS YOU FEEL STRONG DESIRE
|
|
3
|
-
# Unpreditable behaviour may happen. Take it as your own risk.
|
|
4
|
-
def color_puts(text, color: :nil, background: :nil, style: :normal)
|
|
1
|
+
def color_puts(text, color: :nil, background: :nil, style: :normal, inline: false)
|
|
5
2
|
colors = {
|
|
6
3
|
black: 30, red: 31, green: 32, yellow: 33,
|
|
7
4
|
blue: 34, magenta: 35, cyan: 36, white: 37,
|
|
8
5
|
gray: 90
|
|
9
6
|
}
|
|
10
|
-
|
|
11
7
|
backgrounds = {
|
|
12
8
|
black: 40, red: 41, green: 42, yellow: 43,
|
|
13
9
|
blue: 44, magenta: 45, cyan: 46, white: 47,
|
|
14
10
|
gray: 100
|
|
15
11
|
}
|
|
16
|
-
|
|
17
12
|
styles = {
|
|
18
13
|
normal: 0, bold: 1, underline: 4, blink: 5
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
color_code = colors[color]
|
|
22
16
|
bg_code = backgrounds[background]
|
|
23
17
|
style_code = styles[style]
|
|
24
18
|
options = [style_code, color_code, bg_code].compact.join(';')
|
|
25
|
-
|
|
19
|
+
|
|
20
|
+
# If inline is true, use print instead of puts
|
|
21
|
+
if inline
|
|
22
|
+
print "\e[#{options}m#{text}\e[0m"
|
|
23
|
+
else
|
|
24
|
+
puts "\e[#{options}m#{text}\e[0m"
|
|
25
|
+
end
|
|
26
26
|
end
|
data/lib/rubee/cli/routes.rb
CHANGED
|
@@ -8,8 +8,89 @@ module Rubee
|
|
|
8
8
|
|
|
9
9
|
def routes(_argv)
|
|
10
10
|
routes = Rubee::Router.instance_variable_get(:@routes)
|
|
11
|
+
format_routes(routes)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def format_routes(routes)
|
|
15
|
+
if routes.nil? || routes.empty?
|
|
16
|
+
color_puts("No routes found", color: :yellow)
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Group routes by controller
|
|
21
|
+
grouped = routes.group_by { |r| r[:controller] }
|
|
22
|
+
|
|
23
|
+
# Calculate the total width
|
|
24
|
+
width = 100
|
|
25
|
+
|
|
26
|
+
puts ""
|
|
27
|
+
color_puts('═' * width, color: :cyan)
|
|
28
|
+
color_puts(" APPLICATION ROUTES", color: :cyan, style: :bold)
|
|
29
|
+
color_puts('═' * width, color: :cyan)
|
|
30
|
+
puts ""
|
|
31
|
+
|
|
32
|
+
grouped.each do |controller, controller_routes|
|
|
33
|
+
# Controller header with dynamic padding
|
|
34
|
+
header_text = "┌─ #{controller.upcase} "
|
|
35
|
+
padding = '─' * (width - header_text.length)
|
|
36
|
+
color_puts(header_text + padding, color: :gray, style: :bold)
|
|
37
|
+
|
|
38
|
+
controller_routes.each do |route|
|
|
39
|
+
print_route(route)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Bottom border
|
|
43
|
+
color_puts("└#{'─' * (width - 1)}", color: :gray)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
puts ""
|
|
47
|
+
color_puts("Total routes: #{routes.count}", color: :cyan, style: :bold)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def print_route(route)
|
|
53
|
+
# Method (GET, POST, etc)
|
|
54
|
+
method = route[:method].to_s.upcase.ljust(7)
|
|
55
|
+
method_color = method_color(route[:method])
|
|
56
|
+
|
|
57
|
+
# Path
|
|
58
|
+
path = route[:path].ljust(50)
|
|
59
|
+
|
|
60
|
+
# Action
|
|
61
|
+
action = route[:action] || '-'
|
|
62
|
+
|
|
63
|
+
# Namespace
|
|
64
|
+
namespace = route[:namespace] ? " [#{route[:namespace]}]" : ""
|
|
65
|
+
|
|
66
|
+
# Model info if present
|
|
67
|
+
model_info = route[:model] ? " (#{route[:model][:name]})" : ""
|
|
68
|
+
|
|
69
|
+
# Build the line with inline colors using color_puts with inline: true
|
|
70
|
+
print " "
|
|
71
|
+
color_puts(method, color: method_color, style: :bold, inline: true)
|
|
72
|
+
print " "
|
|
73
|
+
color_puts(path, color: :white, inline: true)
|
|
74
|
+
print " → "
|
|
75
|
+
color_puts(action, color: :cyan, inline: true)
|
|
76
|
+
color_puts(namespace, color: :gray, inline: true)
|
|
77
|
+
color_puts(model_info, color: :gray, inline: true)
|
|
78
|
+
puts ""
|
|
79
|
+
end
|
|
11
80
|
|
|
12
|
-
|
|
81
|
+
def method_color(method)
|
|
82
|
+
case method.to_s.downcase.to_sym
|
|
83
|
+
when :get
|
|
84
|
+
:green
|
|
85
|
+
when :post
|
|
86
|
+
:cyan
|
|
87
|
+
when :put, :patch
|
|
88
|
+
:yellow
|
|
89
|
+
when :delete
|
|
90
|
+
:red
|
|
91
|
+
else
|
|
92
|
+
:white
|
|
93
|
+
end
|
|
13
94
|
end
|
|
14
95
|
end
|
|
15
96
|
end
|
data/lib/rubee/cli/server.rb
CHANGED
|
@@ -3,10 +3,10 @@ module Rubee
|
|
|
3
3
|
class Server
|
|
4
4
|
LOGO = <<-'LOGO'
|
|
5
5
|
____ _ _ ____ _____
|
|
6
|
-
| _ \| | | || __ )| ____|
|
|
7
|
-
| |_) | | | || _ \| _|
|
|
8
|
-
| _ <| |__| || |_) | |___
|
|
9
|
-
|_| \_\\____/ |____/|_____|
|
|
6
|
+
| _ \| | | || __ )| ____|_
|
|
7
|
+
| |_) | | | || _ \| _| _|
|
|
8
|
+
| _ <| |__| || |_) | |___ _
|
|
9
|
+
|_| \_\\____/ |____/|_____|__|
|
|
10
10
|
Ver: %s ⬡ ⬢ ⬢ rubee ⬢ ⬡
|
|
11
11
|
LOGO
|
|
12
12
|
|
data/lib/rubee/configuration.rb
CHANGED
|
@@ -106,6 +106,16 @@ module Rubee
|
|
|
106
106
|
@configuraiton[args[:app].to_sym][args[:env].to_sym][:pubsub_container] = args[:pubsub_container]
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
+
def middlewares=(args)
|
|
110
|
+
args[:app] ||= :app
|
|
111
|
+
@configuraiton[args[:app].to_sym][args[:env].to_sym][:middlewares] = args[:middlewares]
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def middlewares(**args)
|
|
115
|
+
args[:app] ||= :app
|
|
116
|
+
@configuraiton[args[:app].to_sym][ENV['RACK_ENV']&.to_sym || :development][:middlewares] || []
|
|
117
|
+
end
|
|
118
|
+
|
|
109
119
|
def pubsub_container(**args)
|
|
110
120
|
args[:app] ||= :app
|
|
111
121
|
@configuraiton[args[:app].to_sym][ENV['RACK_ENV']&.to_sym || :development][:pubsub_container] || ::Rubee::PubSub::Redis.instance
|
data/lib/rubee.rb
CHANGED
|
@@ -20,7 +20,7 @@ module Rubee
|
|
|
20
20
|
RUBEE_SUPPORT = { "Rubee::Support::Hash" => Hash, "Rubee::Support::String" => String }
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
VERSION = '2.7.
|
|
23
|
+
VERSION = '2.7.2'
|
|
24
24
|
|
|
25
25
|
require_relative 'rubee/router'
|
|
26
26
|
require_relative 'rubee/logger'
|
|
@@ -63,6 +63,12 @@ module Rubee
|
|
|
63
63
|
controller.send(action)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
def middlewares
|
|
67
|
+
Autoload.call
|
|
68
|
+
|
|
69
|
+
Rubee::Configuration.middlewares
|
|
70
|
+
end
|
|
71
|
+
|
|
66
72
|
private
|
|
67
73
|
|
|
68
74
|
def register_assets_routes
|
data/readme.md
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
<img width="
|
|
8
|
+
<img width="358" height="131" alt="Screen Shot 2026-03-10 at 6 26 04 PM" src="https://github.com/user-attachments/assets/9f156847-590d-43c2-b432-728e6cc2eacc" />
|
|
9
|
+
<br />
|
|
10
|
+
<img width="200" alt="Screenshot 2026-03-11 at 3 42 16 PM" src="https://github.com/user-attachments/assets/f2df9bc7-cda9-4d91-83d5-deedd499999b" />
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
ru.Bee is a Ruby-based web framework designed to streamline the development of modular monolith web applications.
|
|
11
14
|
Under the hood, it leverages the power of Ruby and Rack backed by Puma, offering a clean, efficient, and flexible architecture.
|
|
@@ -92,6 +95,8 @@ The comparison is based on generic and subjective information available on the i
|
|
|
92
95
|
- [Logger](#logger)
|
|
93
96
|
- [WebSocket](#websocket)
|
|
94
97
|
- [Bee assistant](#bee-assistant)
|
|
98
|
+
- [Middleware integration](#middleware-integration)
|
|
99
|
+
|
|
95
100
|
|
|
96
101
|
You can read the full docs on the demo site: [rubee.dedyn.io](https://rubee.dedyn.io/)
|
|
97
102
|
|
|
@@ -1204,6 +1209,13 @@ rubee db run:create_apples # run a specific migration file from /db
|
|
|
1204
1209
|
rubee db structure # generate a migration file for the database structure
|
|
1205
1210
|
```
|
|
1206
1211
|
|
|
1212
|
+
## Info commands
|
|
1213
|
+
|
|
1214
|
+
```bash
|
|
1215
|
+
rubee routes # print the routes table
|
|
1216
|
+
rubee version # print the current framework version
|
|
1217
|
+
```
|
|
1218
|
+
|
|
1207
1219
|
## ru.Bee console
|
|
1208
1220
|
|
|
1209
1221
|
```bash
|
|
@@ -1240,7 +1252,7 @@ gem 'sidekiq'
|
|
|
1240
1252
|
# config/base_configuration.rb
|
|
1241
1253
|
Rubee::Configuration.setup(env = :development) do |config|
|
|
1242
1254
|
config.database_url = { url: "sqlite://db/development.db", env: }
|
|
1243
|
-
config.async_adapter = { async_adapter: SidekiqAsync, env: }
|
|
1255
|
+
config.async_adapter = { async_adapter: Rubee::SidekiqAsync, env: }
|
|
1244
1256
|
end
|
|
1245
1257
|
```
|
|
1246
1258
|
|
|
@@ -1546,6 +1558,29 @@ If you are interested in contributing to ru.Bee, please read the [Contributing](
|
|
|
1546
1558
|
Feel free to open an [issue](https://github.com/nucleom42/rubee/issues) if you spot one.
|
|
1547
1559
|
Have an idea or want to discuss something? Open a [discussion](https://github.com/nucleom42/rubee/discussions).
|
|
1548
1560
|
|
|
1561
|
+
## Middleware integration
|
|
1562
|
+
|
|
1563
|
+
ru.Bee is rack based framework, so you can use register and use middleware for your application.
|
|
1564
|
+
1. Create a middleware
|
|
1565
|
+
```ruby
|
|
1566
|
+
# app/inits/middlewares/my_middleware.rb
|
|
1567
|
+
class MyMiddleware
|
|
1568
|
+
def initialize(app)
|
|
1569
|
+
@app = app
|
|
1570
|
+
end
|
|
1571
|
+
|
|
1572
|
+
def call(env)
|
|
1573
|
+
Logger.info("Middleware called")
|
|
1574
|
+
@app.call(env)
|
|
1575
|
+
end
|
|
1576
|
+
end
|
|
1577
|
+
```
|
|
1578
|
+
2. Register the middleware in the `config/base_configuration.rb`
|
|
1579
|
+
```ruby
|
|
1580
|
+
# config/base_configuration.rb
|
|
1581
|
+
config.middlewares = { middlewares: [MyMiddleware], env: }
|
|
1582
|
+
```
|
|
1583
|
+
|
|
1549
1584
|
## Roadmap
|
|
1550
1585
|
|
|
1551
1586
|
Please refer to the [Roadmap](https://github.com/nucleom42/rubee/blob/main/roadmap.md).
|