Class: RailsAiBridge::Introspectors::GemIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/introspectors/gem_introspector.rb

Overview

Analyzes Gemfile.lock to identify installed gems and map them to known patterns/frameworks the AI should know about.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ GemIntrospector

Returns a new instance of GemIntrospector.



10
11
12
# File 'lib/rails_ai_bridge/introspectors/gem_introspector.rb', line 10

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/rails_ai_bridge/introspectors/gem_introspector.rb', line 8

def app
  @app
end

Instance Method Details

#callHash

Parse +Gemfile.lock+ and classify notable gems.

Returns +{ error: message }+ for any rescued +StandardError+ — including a missing or unreadable lockfile, malformed content, or any other runtime exception — so callers always receive a controlled hash rather than an unhandled exception.

Returns:

  • (Hash)

    gem analysis with +:total_gems+, +:ruby_version+, +:notable_gems+, and +:categories+ on success; or +{ error: String }+ on any rescued +StandardError+



24
25
26
27
28
29
30
31
# File 'lib/rails_ai_bridge/introspectors/gem_introspector.rb', line 24

def call
  lock_path = gemfile_lock_path
  return { error: 'No Gemfile.lock found' } unless File.exist?(lock_path)

  gem_summary(parse_lockfile(lock_path))
rescue StandardError => error
  { error: "GemIntrospector failed: #{error.class}" }
end