Class: RosettAi::GemConsistencyChecker

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

Overview

Checks that gem version references across the codebase are consistent with the resolved versions in Gemfile.lock and the constraints in the gemspec.

Parses Gemfile.lock for resolved runtime dependency versions, compares them against gemspec constraints, and scans project files for stale gem version references.

Constant Summary collapse

EXCLUDED_DIRS =
['vendor', 'tmp', 'coverage', '.git', '.bundle'].freeze
EXCLUDED_FILES =
['Gemfile.lock', 'Gemfile', 'rosett_ai.gemspec',
'spec/rosett_ai/gem_consistency_checker_spec.rb',
'spec/examples.txt'].freeze
EXCLUDED_PREFIXES =
['doc/changes/', 'doc/claude-sessions/', 'conf/design/'].freeze
EXCLUDED_EXTENSIONS =
['.aux', '.toc', '.out', '.ptc', '.log', '.idx', '.ind',
'.ilg', '.bbl', '.blg', '.bcf', '.fls', '.json'].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_dir: Dir.pwd) ⇒ GemConsistencyChecker

Returns a new instance of GemConsistencyChecker.



26
27
28
29
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 26

def initialize(project_dir: Dir.pwd)
  @project_dir = Pathname.new(project_dir)
  @results = { gems: [], stale_references: [], consistent: true }
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



24
25
26
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 24

def results
  @results
end

Instance Method Details

#checkObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 31

def check
  constraints = parse_gemspec_constraints
  locked = parse_lockfile_versions

  gems = build_gem_audit(constraints, locked)
  dependency_versions = locked.select { |name, _| constraints.key?(name) }
  stale = scan_for_stale_references(dependency_versions)

  @results = {
    gems: gems,
    stale_references: stale,
    consistent: gems.all? { |entry| entry[:status] == :ok } && stale.empty?
  }
end

#consistent?Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 46

def consistent?
  check if @results[:gems].empty? && @results[:stale_references].empty?
  @results[:consistent]
end