ru.Bee 2.7.0 → 2.7.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 +4 -4
- 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.rb +1 -1
- data/readme.md +7 -0
- 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: caf6d0df294f7afd884d148b0949352686b23b82c4f9f870fbaddbfc50a57b8b
|
|
4
|
+
data.tar.gz: 5d0de409af07b3f66fd88812834ff931fec088887d8072c7c941ed4a6faaa725
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: caf1433926dc4c7e7f162fe62666dffcf543c13d72084c3a6c806ccb8c90eb797e8e5ea7cdb08f0c49da25c1d063f7f4bf8ab3a17fc47b46d001a27a0ca5910f
|
|
7
|
+
data.tar.gz: 0026ae4837453567fc1c6b6d2a2bf4bbc1f24a4cbe08447597437929fbb326daf4c330f2ee6f1902f8add6e47caa76811e61e3409af97a8e35f646ffd5a4e6c2
|
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.rb
CHANGED
data/readme.md
CHANGED
|
@@ -1204,6 +1204,13 @@ rubee db run:create_apples # run a specific migration file from /db
|
|
|
1204
1204
|
rubee db structure # generate a migration file for the database structure
|
|
1205
1205
|
```
|
|
1206
1206
|
|
|
1207
|
+
## Info commands
|
|
1208
|
+
|
|
1209
|
+
```bash
|
|
1210
|
+
rubee routes # print the routes table
|
|
1211
|
+
rubee version # print the current framework version
|
|
1212
|
+
```
|
|
1213
|
+
|
|
1207
1214
|
## ru.Bee console
|
|
1208
1215
|
|
|
1209
1216
|
```bash
|