class
Analyzer::Crystal::Amber
Defined in:
analyzer/analyzers/crystal/amber.crConstant Summary
-
CONTROLLER_ROUTE_RE =
/(?:^|[^.\w])(get|post|put|delete|patch|head|options|ws)\s*(?:\(\s*)?['"](.+?)['"]\s*,\s*\w+,\s*:\w+/ -
Amber prefers
verb "/path", Controller, :action. One combined PCRE2 scan replaces the previous 8 sequential controller-form scans; on miss, the shared simple-route helper covers the controller-less fallback (another single scan). Was 16 unguarded.scancalls per source line. -
NAMESPACE_PATTERN =
/^(\s*)namespace\s+["']([^"']*)["']\s+do\b/ -
namespace "/admin" do … end— Amber's DSL scope macro. -
RESOURCE_ROUTES =
[{"GET", "", :index}, {"GET", "/new", :new}, {"POST", "", :create}, {"GET", "/:id", :show}, {"GET", "/:id/edit", :edit}, {"PUT", "/:id", :update}, {"PATCH", "/:id", :update}, {"DELETE", "/:id", :destroy}] -
Amber's
resourcesmacro expands to the seven RESTful routes below (update is registered for both PUT and PATCH).resource(singular) shares the same action set; the:idsegment is auto-detected as a path param downstream, so we only emit the verb + URL + action here. -
RESOURCES_PATTERN =
/^\s*resources\s+["']([^"']+)["']\s*,\s*([A-Za-z_]\w*(?:::[A-Za-z_]\w*)*)\s*(.*)$/ -
resources "/posts", PostController[, only: …][, except: …]. -
ROUTES_SCOPE_PATTERN =
/^(\s*)routes\s+:\w+(?:\s*,\s*["']([^"']*)["'])?\s+do\b/ -
routes :web, "/admin" do … end— the optional second argument is a path scope that prefixes every route declared inside the block. -
SERVE_STATIC_DISABLED_RE =
Regex.union("serve_static false", "serve_static(false)") -
serve_static false/serve_static(false)— checked on every source line, so the two fixed OR-edString#includes?substring scans are precompiled into a single regex union (one PCRE2 JIT scan per line instead of two naive substring scans).
Instance Method Summary
- #analyze
- #analyze_file(path : String) : Array(Endpoint)
- #line_to_endpoint(content : String) : Endpoint
- #line_to_param(content : String) : Param