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 =

Returns Directory names excluded from consistency checking.

Returns:

  • (Array)

    Directory names excluded from consistency checking.

['vendor', 'tmp', 'coverage', '.git', '.bundle'].freeze
EXCLUDED_FILES =

Returns Filenames excluded from consistency checking.

Returns:

  • (Array)

    Filenames excluded from consistency checking.

['.ruby-version', 'CHANGELOG.md', 'Gemfile.lock',
'Gemfile.integration.lock',
'spec/rosett_ai/version_consistency_checker_spec.rb'].freeze
EXCLUDED_PREFIXES =

Returns Filename prefixes excluded from consistency checking.

Returns:

  • (Array)

    Filename prefixes excluded from consistency checking.

['doc/changes/', 'doc/claude-sessions/', 'doc/INCIDENT_REPORT',
'doc/PACKAGING', 'doc/issues/', 'doc/context/', 'conf/design/'].freeze
EXCLUDED_EXTENSIONS =

Returns File extensions excluded from consistency checking.

Returns:

  • (Array)

    File extensions excluded from consistency checking.

['.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.



31
32
33
34
# File 'lib/rosett_ai/version_consistency_checker.rb', line 31

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.



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

def results
  @results
end

Instance Method Details

#checkHash

Run the check and return results.

Returns:

  • (Hash)


38
39
40
41
42
43
44
45
46
47
# File 'lib/rosett_ai/version_consistency_checker.rb', line 38

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)


49
50
51
52
# File 'lib/rosett_ai/version_consistency_checker.rb', line 49

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