Class: Guardrails::Init::StackDetector
- Inherits:
-
Object
- Object
- Guardrails::Init::StackDetector
- Defined in:
- lib/guardrails/init/stack_detector.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- STYLESHEET_PATTERNS =
[ "app/assets/stylesheets/**/*.{css,scss}", "app/assets/tailwind/**/*.css" ].freeze
- IMPLICIT_IGNORE_SEGMENTS =
Skip third-party / generated subtrees even when they’re nested inside an ‘app/assets/stylesheets/` tree (common Sprockets convention). Match on path components, not prefix.
%w[vendor node_modules tmp public log].freeze
- CUSTOM_PROPERTY_PATTERN =
/--[a-z][\w-]*:\s*[^;]+;/- SCSS_VARIABLE_PATTERN =
/^\s*\$[a-z][\w-]*:/- HEX_LITERAL_PATTERN =
/#[0-9a-fA-F]{3,8}\b/
Instance Method Summary collapse
- #detect ⇒ Object
-
#initialize(root) ⇒ StackDetector
constructor
A new instance of StackDetector.
Constructor Details
#initialize(root) ⇒ StackDetector
Returns a new instance of StackDetector.
24 25 26 |
# File 'lib/guardrails/init/stack_detector.rb', line 24 def initialize(root) @root = Pathname(root) end |
Instance Method Details
#detect ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/guardrails/init/stack_detector.rb', line 28 def detect files = collect_stylesheets return Result.new(strategy: :none, stylesheets: [], evidence: empty_evidence) if files.empty? evidence = analyze(files) Result.new( strategy: choose_strategy(evidence), stylesheets: files, evidence: evidence ) end |