Class: RosettAi::VersionConsistencyChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/version_consistency_checker.rb

Overview

Checks that all Ruby version references across the codebase are consistent with the canonical version declared in .ruby-version.

Scans non-binary project files for version strings matching the MAJOR.MINOR series (e.g. 3.3.x) and reports any that don't match the expected PATCH level.

Constant Summary collapse

EXCLUDED_DIRS =
['vendor', 'tmp', 'coverage', '.git', '.bundle'].freeze
EXCLUDED_FILES =
['.ruby-version', 'CHANGELOG.md', 'Gemfile.lock',
'Gemfile.integration.lock',
'spec/rosett_ai/version_consistency_checker_spec.rb'].freeze
EXCLUDED_PREFIXES =
['doc/changes/', 'doc/claude-sessions/', 'doc/INCIDENT_REPORT',
'doc/PACKAGING', 'doc/issues/', 'doc/context/', 'conf/design/'].freeze
EXCLUDED_EXTENSIONS =
['.aux', '.toc', '.out', '.ptc', '.log', '.idx', '.ind',
'.ilg', '.bbl', '.blg', '.bcf', '.fls', '.fdb_latexmk',
'.run.xml', '.synctex.gz'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_dir: Dir.pwd) ⇒ VersionConsistencyChecker

Returns a new instance of VersionConsistencyChecker.



27
28
29
30
# File 'lib/rosett_ai/version_consistency_checker.rb', line 27

def initialize(project_dir: Dir.pwd)
  @project_dir = Pathname.new(project_dir)
  @results = { expected_version: nil, references: [], mismatches: [], consistent: true }
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



25
26
27
# File 'lib/rosett_ai/version_consistency_checker.rb', line 25

def results
  @results
end

Instance Method Details

#checkObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/rosett_ai/version_consistency_checker.rb', line 32

def check
  version = read_ruby_version
  @results = { expected_version: version, references: [], mismatches: [], consistent: true }

  pattern = build_version_pattern(version)
  scan_files(version, pattern)

  @results[:consistent] = @results[:mismatches].empty?
  @results
end

#consistent?Boolean

Returns:

  • (Boolean)


43
44
45
46
# File 'lib/rosett_ai/version_consistency_checker.rb', line 43

def consistent?
  check if @results[:expected_version].nil?
  @results[:consistent]
end