Class: Guardrails::Init
- Inherits:
-
Object
- Object
- Guardrails::Init
- Defined in:
- lib/guardrails/init.rb,
lib/guardrails/init/prompter.rb,
lib/guardrails/init/config_writer.rb,
lib/guardrails/init/stack_detector.rb,
lib/guardrails/init/media_query_scaffolder.rb
Defined Under Namespace
Classes: ConfigWriter, MediaQueryScaffolder, Prompter, StackDetector
Constant Summary collapse
- NEAR_MATCH_POLICY_CHOICES =
%w[notify fix leave].freeze
- DEFAULT_SCAN_PATHS =
%w[app/views app/components].freeze
- DEFAULT_IGNORE =
%w[app/views/layouts].freeze
- STRATEGY_LABELS =
{ css_custom_properties: "CSS custom properties", scss_variables: "SCSS variables", raw_hex: "Raw hex literals (no token system detected)", none: "No stylesheets found" }.freeze
Instance Method Summary collapse
-
#initialize(root:, output: $stdout, input: $stdin, force: false) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
Constructor Details
#initialize(root:, output: $stdout, input: $stdin, force: false) ⇒ Init
Returns a new instance of Init.
23 24 25 26 27 28 |
# File 'lib/guardrails/init.rb', line 23 def initialize(root:, output: $stdout, input: $stdin, force: false) @root = Pathname(root) @output = output @input = input @force = force end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/guardrails/init.rb', line 30 def run result = StackDetector.new(@root).detect print_summary(result) # Don't prompt the user if we know we won't write — keeps reruns from # asking questions whose answers will be discarded. overrides = config_writeable? ? collect_overrides : {} written = ConfigWriter.new(@root, output: @output).write(result, overrides: overrides, force: @force) if written scaffold_media_queries else @output.puts "Media queries: skipped (delete guardrails.yml or set FORCE=1 to re-run init)" end result end |