Class: RailsAiBridge::Introspectors::SemanticIntrospector
- Inherits:
-
Object
- Object
- RailsAiBridge::Introspectors::SemanticIntrospector
- Defined in:
- lib/rails_ai_bridge/introspectors/semantic_introspector.rb
Overview
Dedicated semantic analysis introspector powered by rubydex.
Analyzes the entire codebase to extract:
- Common implementation patterns
- Semantic relationships between code elements
- Complexity hotspots and frequently referenced areas
- Codebase statistics
Returns an empty hash with an informational message when rubydex is not available or not enabled.
Constant Summary collapse
- MAX_PATTERN_DECLARATIONS =
Maximum declarations to include in pattern detection to avoid huge payloads.
200- MAX_HOTSPOTS =
Maximum complexity hotspots to return.
20
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#call ⇒ Hash
Builds a semantic analysis hash for the Rails application.
-
#initialize(app) ⇒ SemanticIntrospector
constructor
A new instance of SemanticIntrospector.
Constructor Details
#initialize(app) ⇒ SemanticIntrospector
Returns a new instance of SemanticIntrospector.
24 25 26 |
# File 'lib/rails_ai_bridge/introspectors/semantic_introspector.rb', line 24 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
16 17 18 |
# File 'lib/rails_ai_bridge/introspectors/semantic_introspector.rb', line 16 def app @app end |
Instance Method Details
#call ⇒ Hash
Builds a semantic analysis hash for the Rails application.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rails_ai_bridge/introspectors/semantic_introspector.rb', line 31 def call config = RailsAiBridge.configuration unless config.rubydex_available? return { info: 'Rubydex is not available. Install the rubydex gem and set ' \ 'config.rubydex_enabled = true to enable semantic analysis.' } end adapter = RubydexAdapter.instance(app.root.to_s) { codebase_stats: adapter.codebase_stats, patterns: detect_patterns(adapter), relationships: analyze_relationships(adapter), complexity_hotspots: find_complexity_hotspots(adapter) } rescue StandardError => error msg = error. Rails.logger.warn "[rails-ai-bridge] SemanticIntrospector failed: #{msg}" { error: msg } end |