Class: RailsAiBridge::Introspectors::GemIntrospector
- Inherits:
-
Object
- Object
- RailsAiBridge::Introspectors::GemIntrospector
- 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
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#call ⇒ Hash
Parse +Gemfile.lock+ and classify notable gems.
-
#initialize(app) ⇒ GemIntrospector
constructor
A new instance of GemIntrospector.
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
#app ⇒ Object (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
#call ⇒ Hash
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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rails_ai_bridge/introspectors/gem_introspector.rb', line 24 def call lock_path = File.join(app.root, 'Gemfile.lock') return { error: 'No Gemfile.lock found' } unless File.exist?(lock_path) specs = parse_lockfile(lock_path) notable = detect_notable_gems(specs) { total_gems: specs.size, ruby_version: specs['ruby']&.first, notable_gems: notable, categories: GemRegistry.categorize(notable) } rescue StandardError => error { error: "GemIntrospector failed: #{error.class}" } end |