Class: Gloo::WebSvr::Routing::ShowRoutes
- Inherits:
-
Object
- Object
- Gloo::WebSvr::Routing::ShowRoutes
- Defined in:
- lib/gloo/web_svr/routing/show_routes.rb
Constant Summary collapse
- SEGMENT_DIVIDER =
'/'.freeze
- RETURN =
"\n".freeze
Instance Method Summary collapse
-
#add_container_routes(can, route_path) ⇒ Object
Show the routes in the given container.
-
#headers ⇒ Object
Get the table headers.
-
#initialize(engine) ⇒ ShowRoutes
constructor
Set up the web server.
-
#show(page_container) ⇒ Object
Show all available routes.
-
#show_table ⇒ Object
Show the Routes title.
Constructor Details
#initialize(engine) ⇒ ShowRoutes
Set up the web server.
24 25 26 27 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 24 def initialize( engine ) @engine = engine @log = @engine.log end |
Instance Method Details
#add_container_routes(can, route_path) ⇒ Object
Show the routes in the given container. This is a recursive function travese the object tree.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 51 def add_container_routes can, route_path can.children.each do |obj| if obj.class == Gloo::Objs::Container add_container_routes obj, "#{route_path}#{obj.name}#{SEGMENT_DIVIDER}" elsif obj.class == Gloo::Objs::Page route = "#{route_path}#{obj.name}" @found_routes << [ obj.name, obj.pn, route, Gloo::WebSvr::WebMethod::GET ] # If the method is POST, add a route alias for the create. if obj.name.eql? ResourceRouter::POST_ROUTE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::POST ] elsif obj.name.eql? ResourceRouter::UPDATE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::PATCH ] elsif obj.name.eql? ResourceRouter::DELETE @found_routes << [ '', '', route_path, Gloo::WebSvr::WebMethod::DELETE ] end end end end |
#headers ⇒ Object
Get the table headers.
91 92 93 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 91 def headers return [ 'Obj Name', 'Obj Path', 'Route', 'Method' ] end |
#show(page_container) ⇒ Object
Show all available routes.
37 38 39 40 41 42 43 44 45 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 37 def show page_container @log.debug "showing routes" @found_routes = [] @log.debug "building route table" add_container_routes( page_container, SEGMENT_DIVIDER ) show_table end |
#show_table ⇒ Object
Show the Routes title.
79 80 81 82 83 84 85 86 |
# File 'lib/gloo/web_svr/routing/show_routes.rb', line 79 def show_table @log.show "\n\tRoutes in Running Web App\n", :white table = TTY::Table.new( headers, @found_routes ) renderer = TTY::Table::Renderer::Unicode.new( table, padding: [0,1] ) puts renderer.render puts RETURN end |