Class: LcpRuby::I18nCheck::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/i18n_check/runner.rb

Overview

Glues ‘RegistryWalker` and `Reporter` together for the rake task.

The lint is a single boot-time pass: walk the loaded metadata registry and check that every labeled element resolves in every configured locale via ‘I18n.exists?`. No AST scan, no separate YAML walker — see Phase 9 in `docs/design/i18n_consistency_check.md` for the simplification rationale.

Resolves the output format with precedence:

explicit `format:` arg → ENV["LCP_I18N_FORMAT"] → config default.

‘run` returns a process exit code (0 = clean / only warnings, 1 = at least one error-severity offense). The rake task forwards it to `exit`.

Instance Method Summary collapse

Constructor Details

#initialize(config: Configuration.new, root: Dir.pwd, loader: nil) ⇒ Runner

Returns a new instance of Runner.



23
24
25
26
27
# File 'lib/lcp_ruby/i18n_check/runner.rb', line 23

def initialize(config: Configuration.new, root: Dir.pwd, loader: nil)
  @config = config
  @root   = root
  @loader = loader
end

Instance Method Details

#run(format: nil, io: $stdout) ⇒ Object



29
30
31
32
33
# File 'lib/lcp_ruby/i18n_check/runner.rb', line 29

def run(format: nil, io: $stdout)
  resolved_format = (format || ENV["LCP_I18N_FORMAT"] || @config.format).to_sym
  offenses = registry_walker.run
  Reporter.new.report(offenses, format: resolved_format, io: io)
end