class
Analyzer::Javascript::Restify
Defined in:
analyzer/analyzers/javascript/restify.crConstant Summary
-
CLIENT_LIBRARY_RE =
Regex.union("restify-clients", "createJSONClient(", "createStringClient(", "createHttpClient(") -
Precompiled once — a single PCRE2-JIT scan replaces four naive String#includes? substring scans over the whole file content. Regex.union auto-escapes each literal, so this is provably equivalent to the OR-of-includes? it replaces.
-
DOT_METHOD_RES =
HTTP_METHOD_KEYS.map do |m| {m, /\.\s*#{m}\s*\(\s*['"]([^'"]+)['"]/} end.to_h -
HTTP_METHOD_KEYS =
["get", "post", "put", "delete", "patch", "options", "head", "del"] of ::String -
ROUTER_NAME_METHOD_RES =
HTTP_METHOD_KEYS.map do |m| {m, /\b(?:\w+Router)\s*\.\s*#{m}\s*\(\s*['"]([^'"]+)['"]/} end.to_h -
Compiled once — interpolated regex literals would otherwise be rebuilt (full PCRE2 compile) for every method on every line.
-
VERSIONED_PATH_RES =
HTTP_METHOD_KEYS.map do |m| {m, /\.#{m}\s*\(\s*\{\s*path\s*:\s*['"]([^'"]+)['"]/} end.to_h
Instance Method Summary
- #analyze
- #extract_endpoint_var(line : String) : String
- #extract_path(line : String) : String
- #line_to_endpoint(line : String, server_vars = [] of String, router_vars = [] of String) : Endpoint
- #line_to_param(line : String) : Param