Class: Railsmith::ArchChecks::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/railsmith/arch_checks/cli.rb

Overview

Runs architecture checks driven by ENV and prints a report to output. Returns 0 when the scan is clean or warn-only mode allows violations, and 1 when fail-on is enabled and violations exist.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env:, output:, warn_proc:) ⇒ Cli

Returns a new instance of Cli.



13
14
15
16
17
# File 'lib/railsmith/arch_checks/cli.rb', line 13

def initialize(env:, output:, warn_proc:)
  @env = env
  @output = output
  @warn_proc = warn_proc
end

Class Method Details

.run(env: ENV, output: $stdout, warn_proc: Kernel.method(:warn)) ⇒ Object



9
10
11
# File 'lib/railsmith/arch_checks/cli.rb', line 9

def self.run(env: ENV, output: $stdout, warn_proc: Kernel.method(:warn))
  new(env: env, output: output, warn_proc: warn_proc).run
end

Instance Method Details

#runInteger

Returns 0 or 1.

Returns:

  • (Integer)

    0 or 1



20
21
22
23
24
25
26
27
28
# File 'lib/railsmith/arch_checks/cli.rb', line 20

def run
  format_sym = normalized_format
  paths = paths_list
  fail_on = fail_on_violations?
  checked_files, violations = scan(paths)
  report = arch_report(violations, checked_files, fail_on)
  emit_report(format_sym, report)
  status_for(fail_on, report)
end