Class: RailsMcpInsight::Analyzers::GemAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_mcp_insight/analyzers/gem_analyzer.rb

Overview

Analyzes Gemfile and Gemfile.lock to extract dependency information, identify outdated/abandoned gems, and check for security advisories.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ GemAnalyzer

Returns a new instance of GemAnalyzer.



8
9
10
# File 'lib/rails_mcp_insight/analyzers/gem_analyzer.rb', line 8

def initialize(config)
  @config = config
end

Instance Method Details

#analyzeObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rails_mcp_insight/analyzers/gem_analyzer.rb', line 12

def analyze
  gemfile = @config.gemfile_path
  lockfile = @config.gemfile_lock_path

  return { error: "No Gemfile found" } unless File.exist?(gemfile)

  gems = parse_gemfile(gemfile)
  locked_versions = File.exist?(lockfile) ? parse_lockfile(lockfile) : {}

  {
    total_gems: gems.length,
    gems: gems.map do |gem_info|
      gem_info.merge(locked_version: locked_versions[gem_info[:name]])
    end,
    groups: extract_groups(gemfile),
    ruby_version: extract_ruby_version(gemfile)
  }
end