class
Analyzer::Ruby::Grape
- Analyzer::Ruby::Grape
- Analyzer::Ruby::RubyEngine
- Analyzer
- Reference
- Object
Defined in:
analyzer/analyzers/ruby/grape.crConstant Summary
-
GRAPE_CLASS_DEF =
/^\s*class\s+[A-Z][\w:]*\s*<\s*([:\w][\w:]*)/ -
class <Child> < <Super>declaration matcher (single capture: Super). -
GRAPE_CLASS_EDGE =
/^\s*class\s+([A-Z][\w:]*)\s*<\s*([:\w][\w:]*)/ -
Full form capturing both Child and Super for the inheritance graph.
-
GRAPE_MOUNT_DECL =
/^\s*mount\s+([:\w][\w:]*)/ -
GRAPE_PREFIX_DECL =
/^\s*prefix\s+['":]([\w\/]+)['"]?/ -
GRAPE_VERB_BARE_DO =
GRAPE_VERBS.to_h do |verb| {verb, /^#{verb}\s+do\b/} end -
GRAPE_VERB_WITH_PATH =
GRAPE_VERBS.to_h do |verb| {verb, /^#{verb}\b(?:\s+(['":][\w\/\-:]+[\'""]?))?(?:\s*,[^#]*?)?\s*do\b/} end -
Crystal recompiles an interpolated regex literal (
/^#{verb}.../) on every evaluation — ~11000x slower than a precompiled one — so matching the verb DSL inside the per-line loop used to recompile 14 regexes for every line of every Grape file. Build the per-verb patterns once at load time instead._WITH_PATHmatchesget '/users' do(capturing the path literal/symbol);_BARE_DOmatches the path-lessget doform. -
GRAPE_VERBS =
["get", "post", "put", "delete", "patch", "head", "options"] -
GRAPE_VERSION_DECL =
/^\s*version\s+(.+)\busing:\s*:path\b/