Analyzer::Crystal::Amber
Inherits Analyzer::Crystal::CrystalEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object
Constants
get "/path" is the same line in Amber, Kemal and Grip — the DSLs are
indistinguishable one line at a time, and this analyzer is handed every
.cr file in the scan. Without a file-level gate it read Kemal's, Grip's
and Lucky's routes as Amber ones (22 phantom endpoints across the Crystal
fixture tree), and swallowed their public_folder declarations on the
way through.
A file that declares Amber routes belongs to an Amber app, so it names
the framework: require "amber" in the fixtures and in an app's entry
point, Amber::Server.configure in a real config/routes.cr, or the
routes :web do pipeline block, which is Amber's DSL and nobody else's.
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
.scan calls per source line.
namespace "/admin" do … end — Amber's DSL scope macro.
Amber's resources macro expands to the seven RESTful routes below
(update is registered for both PUT and PATCH). resource (singular)
shares the same action set; the :id segment is auto-detected as a
path param downstream, so we only emit the verb + URL + action here.
resources "/posts", PostController[, only: …][, except: …].
routes :web, "/admin" do … end — the optional second argument is a
path scope that prefixes every route declared inside the block.
serve_static false / serve_static(false) — checked on every source
line, so the two fixed OR-ed String#includes? substring scans are
precompiled into a single regex union (one PCRE2 JIT scan per line
instead of two naive substring scans).
Class methods
Instance methods
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.