gloo 3.1.1 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/VERSION +1 -1
- data/lib/VERSION_NOTES +6 -0
- data/lib/gloo/app/log.rb +46 -6
- data/lib/gloo/app/running_app.rb +42 -1
- data/lib/gloo/core/obj.rb +34 -1
- data/lib/gloo/exec/exec_env.rb +4 -0
- data/lib/gloo/exec/script.rb +9 -1
- data/lib/gloo/objs/basic/container.rb +18 -2
- data/lib/gloo/objs/cli/menu.rb +9 -3
- data/lib/gloo/objs/data/mysql.rb +35 -7
- data/lib/gloo/objs/data/pg.rb +8 -0
- data/lib/gloo/objs/data/query.rb +66 -11
- data/lib/gloo/objs/data/query_result.rb +22 -1
- data/lib/gloo/objs/data/sqlite.rb +17 -2
- data/lib/gloo/objs/data/table.rb +143 -4
- data/lib/gloo/objs/web/json.rb +2 -0
- data/lib/gloo/objs/web_svr/element.rb +13 -5
- data/lib/gloo/objs/web_svr/page.rb +41 -3
- data/lib/gloo/objs/web_svr/partial.rb +7 -2
- data/lib/gloo/objs/web_svr/svr.rb +71 -4
- data/lib/gloo/verbs/break.rb +44 -0
- data/lib/gloo/verbs/create.rb +6 -0
- data/lib/gloo/verbs/log.rb +26 -5
- data/lib/gloo/verbs/redirect.rb +54 -6
- data/lib/gloo/web_svr/asset.rb +28 -0
- data/lib/gloo/web_svr/handler.rb +4 -2
- data/lib/gloo/web_svr/request.rb +35 -2
- data/lib/gloo/web_svr/routing/resource_router.rb +47 -0
- data/lib/gloo/web_svr/routing/router.rb +218 -0
- data/lib/gloo/web_svr/routing/show_routes.rb +98 -0
- data/lib/gloo/web_svr/server.rb +10 -2
- data/lib/gloo/web_svr/table_renderer.rb +147 -0
- data/lib/gloo/web_svr/web_method.rb +54 -0
- metadata +9 -4
- data/lib/gloo/web_svr/router.rb +0 -179
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -431,6 +431,7 @@ files:
|
|
431
431
|
- lib/gloo/utils/words.rb
|
432
432
|
- lib/gloo/verbs/alert.rb
|
433
433
|
- lib/gloo/verbs/beep.rb
|
434
|
+
- lib/gloo/verbs/break.rb
|
434
435
|
- lib/gloo/verbs/cls.rb
|
435
436
|
- lib/gloo/verbs/context.rb
|
436
437
|
- lib/gloo/verbs/create.rb
|
@@ -461,8 +462,12 @@ files:
|
|
461
462
|
- lib/gloo/web_svr/request.rb
|
462
463
|
- lib/gloo/web_svr/response.rb
|
463
464
|
- lib/gloo/web_svr/response_code.rb
|
464
|
-
- lib/gloo/web_svr/
|
465
|
+
- lib/gloo/web_svr/routing/resource_router.rb
|
466
|
+
- lib/gloo/web_svr/routing/router.rb
|
467
|
+
- lib/gloo/web_svr/routing/show_routes.rb
|
465
468
|
- lib/gloo/web_svr/server.rb
|
469
|
+
- lib/gloo/web_svr/table_renderer.rb
|
470
|
+
- lib/gloo/web_svr/web_method.rb
|
466
471
|
- lib/run.rb
|
467
472
|
homepage: http://github.com/ecrane/gloo
|
468
473
|
licenses:
|
@@ -483,7 +488,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
483
488
|
- !ruby/object:Gem::Version
|
484
489
|
version: '0'
|
485
490
|
requirements: []
|
486
|
-
rubygems_version: 3.
|
491
|
+
rubygems_version: 3.5.6
|
487
492
|
signing_key:
|
488
493
|
specification_version: 4
|
489
494
|
summary: Gloo scripting language. A scripting language built on ruby.
|
data/lib/gloo/web_svr/router.rb
DELETED
@@ -1,179 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 20124 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# A helper class for page routing.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module WebSvr
|
9
|
-
class Router
|
10
|
-
|
11
|
-
PAGE_CONTAINER = 'page'.freeze
|
12
|
-
INDEX = 'index'.freeze
|
13
|
-
SEGMENT_DIVIDER = '/'.freeze
|
14
|
-
|
15
|
-
attr_reader :route_segments
|
16
|
-
|
17
|
-
|
18
|
-
# ---------------------------------------------------------------------
|
19
|
-
# Initialization
|
20
|
-
# ---------------------------------------------------------------------
|
21
|
-
|
22
|
-
#
|
23
|
-
# Set up the web server.
|
24
|
-
#
|
25
|
-
def initialize( engine, web_svr_obj )
|
26
|
-
@engine = engine
|
27
|
-
@log = @engine.log
|
28
|
-
|
29
|
-
@web_svr_obj = web_svr_obj
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
# ---------------------------------------------------------------------
|
34
|
-
# Routing
|
35
|
-
# ---------------------------------------------------------------------
|
36
|
-
|
37
|
-
#
|
38
|
-
# Find and return the page for the given route.
|
39
|
-
#
|
40
|
-
def page_for_route path
|
41
|
-
@engine.log.info "routing to #{path}"
|
42
|
-
detect_segments path
|
43
|
-
|
44
|
-
return @web_svr_obj.home_page if is_root_path?
|
45
|
-
|
46
|
-
pages = @web_svr_obj.pages_container
|
47
|
-
return find_route_segment( pages.children ) if pages
|
48
|
-
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
# ---------------------------------------------------------------------
|
54
|
-
# Dynamic Add Page Routes
|
55
|
-
# ---------------------------------------------------------------------
|
56
|
-
|
57
|
-
#
|
58
|
-
# Get the root level page container.
|
59
|
-
#
|
60
|
-
def page_container
|
61
|
-
pn = Gloo::Core::Pn.new( @engine, PAGE_CONTAINER )
|
62
|
-
return pn.resolve
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# Add all page routes to the web server pages (routes).
|
67
|
-
#
|
68
|
-
def add_page_routes
|
69
|
-
can = page_container
|
70
|
-
return unless can
|
71
|
-
|
72
|
-
@log.debug 'Adding page routes to web server…'
|
73
|
-
@factory = @engine.factory
|
74
|
-
|
75
|
-
add_pages can, @web_svr_obj.pages_container
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Add the pages to the web server pages.
|
80
|
-
# This is a recursive function that will add all
|
81
|
-
# pages in the folder and subfolders.
|
82
|
-
#
|
83
|
-
def add_pages can, parent
|
84
|
-
# for each file in the page container
|
85
|
-
# create a page object and add it to the routes
|
86
|
-
can.children.each do |obj|
|
87
|
-
if obj.class == Gloo::Objs::Container
|
88
|
-
child_can = parent.find_add_child( obj.name, 'container' )
|
89
|
-
add_pages( obj, child_can )
|
90
|
-
elsif obj.class == Gloo::Objs::Page
|
91
|
-
add_route_alias( parent, obj.name, obj.pn )
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
#
|
97
|
-
# Add route alias to the page.
|
98
|
-
#
|
99
|
-
def add_route_alias( parent, name, pn )
|
100
|
-
name = name.gsub( '.', '_' )
|
101
|
-
|
102
|
-
# First make sure the child doesn't already exist.
|
103
|
-
child = parent.find_child( name )
|
104
|
-
return if child
|
105
|
-
|
106
|
-
@factory.create_alias( name, pn, parent )
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
# ---------------------------------------------------------------------
|
111
|
-
# Helper funcions
|
112
|
-
# ---------------------------------------------------------------------
|
113
|
-
|
114
|
-
#
|
115
|
-
# Find the route segment in the object container.
|
116
|
-
#
|
117
|
-
def find_route_segment objs
|
118
|
-
this_segment = next_segment
|
119
|
-
|
120
|
-
this_segment = INDEX if this_segment.blank?
|
121
|
-
|
122
|
-
objs.each do |o|
|
123
|
-
o = Gloo::Objs::Alias.resolve_alias( @engine, o )
|
124
|
-
|
125
|
-
if o.name == this_segment
|
126
|
-
if o.class == Gloo::Objs::Page
|
127
|
-
@engine.log.debug "found page for route: #{o.pn}"
|
128
|
-
return o
|
129
|
-
elsif o.class == Gloo::Objs::FileHandle
|
130
|
-
@engine.log.debug "found static file for route: #{o.pn}"
|
131
|
-
return o
|
132
|
-
else
|
133
|
-
return nil unless o.child_count > 0
|
134
|
-
|
135
|
-
return find_route_segment( o.children )
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
return nil
|
141
|
-
end
|
142
|
-
|
143
|
-
#
|
144
|
-
# Get the next segment in the route.
|
145
|
-
#
|
146
|
-
def next_segment
|
147
|
-
this_segment = @route_segments.shift
|
148
|
-
return nil if this_segment.nil?
|
149
|
-
|
150
|
-
# A URL might include a dot in a name, but we can't do that
|
151
|
-
# because dot is a reserve path thing. So we replace it with
|
152
|
-
# an underscore.
|
153
|
-
this_segment = this_segment.gsub( '.', '_' )
|
154
|
-
|
155
|
-
return this_segment
|
156
|
-
end
|
157
|
-
|
158
|
-
#
|
159
|
-
# Is this the root path?
|
160
|
-
def is_root_path?
|
161
|
-
return @route_segments.count == 0
|
162
|
-
end
|
163
|
-
|
164
|
-
#
|
165
|
-
# Create a list of path segments.
|
166
|
-
#
|
167
|
-
def detect_segments path
|
168
|
-
# Split the path into segments.
|
169
|
-
@route_segments = path.split SEGMENT_DIVIDER
|
170
|
-
|
171
|
-
# Remove the first segment if it is empty.
|
172
|
-
@route_segments.shift if @route_segments.first.blank?
|
173
|
-
|
174
|
-
return @route_segments
|
175
|
-
end
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|