Class: RosettAi::GemConsistencyChecker
- Inherits:
-
Object
- Object
- RosettAi::GemConsistencyChecker
- 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 =
Returns Directory names excluded from consistency checking.
['vendor', 'tmp', 'coverage', '.git', '.bundle'].freeze
- EXCLUDED_FILES =
Returns Filenames excluded from consistency checking.
['Gemfile.lock', 'Gemfile', 'rosett_ai.gemspec', 'spec/rosett_ai/gem_consistency_checker_spec.rb', 'spec/examples.txt'].freeze
- EXCLUDED_PREFIXES =
Returns Filename prefixes excluded from consistency checking.
['doc/changes/', 'doc/claude-sessions/', 'conf/design/'].freeze
- EXCLUDED_EXTENSIONS =
Returns File extensions excluded from consistency checking.
['.aux', '.toc', '.out', '.ptc', '.log', '.idx', '.ind', '.ilg', '.bbl', '.blg', '.bcf', '.fls', '.json'].freeze
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#check ⇒ Hash
Run the check and return results.
- #consistent? ⇒ Boolean
-
#initialize(project_dir: Dir.pwd) ⇒ GemConsistencyChecker
constructor
A new instance of GemConsistencyChecker.
Constructor Details
#initialize(project_dir: Dir.pwd) ⇒ GemConsistencyChecker
Returns a new instance of GemConsistencyChecker.
30 31 32 33 |
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 30 def initialize(project_dir: Dir.pwd) @project_dir = Pathname.new(project_dir) @results = { gems: [], stale_references: [], consistent: true } end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
28 29 30 |
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 28 def results @results end |
Instance Method Details
#check ⇒ Hash
Run the check and return results.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 37 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
52 53 54 55 |
# File 'lib/rosett_ai/gem_consistency_checker.rb', line 52 def consistent? check if @results[:gems].empty? && @results[:stale_references].empty? @results[:consistent] end |