Class: RailsAiContext::Introspectors::EnvConfigIntrospector

Inherits:
Object
  • Object
show all
Extended by:
StaticTier
Defined in:
lib/rails_ai_context/introspectors/env_config_introspector.rb

Overview

Parses config/environments/*.rb - the one config surface no other introspector covers. Captures, per environment file, which config keys are assigned and the values of the toggles AI most often needs to compare across environments (force_ssl, eager_load, caching, logging, queue adapter, mailer delivery).

Not EnvIntrospector, which reads environment variables and ENV usage. This one reads the environment config files; that one reads the process environment.

Constant Summary collapse

NOTABLE_KEYS =

Assignments whose values are lifted into the per-env notable hash. Keys are the config path relative to config. (one or two levels).

%w[
  force_ssl eager_load cache_classes consider_all_requests_local
  log_level cache_store action_controller.perform_caching
  active_job.queue_adapter action_mailer.delivery_method
  action_mailer.raise_delivery_errors active_storage.service
  action_cable.mount_path i18n.fallbacks
].freeze

Constants included from StaticTier

StaticTier::ALTERNATE_SOURCE, StaticTier::FILES_ONLY, StaticTier::KINDS, StaticTier::RUNTIME_ONLY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StaticTier

answers_statically?, static_tier, static_tier_declared?, unavailable_reason, validate_static_tier!

Constructor Details

#initialize(app) ⇒ EnvConfigIntrospector

Returns a new instance of EnvConfigIntrospector.



30
31
32
# File 'lib/rails_ai_context/introspectors/env_config_introspector.rb', line 30

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



18
19
20
# File 'lib/rails_ai_context/introspectors/env_config_introspector.rb', line 18

def app
  @app
end

Instance Method Details

#callHash

Returns per-environment config summary.

Returns:

  • (Hash)

    per-environment config summary



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rails_ai_context/introspectors/env_config_introspector.rb', line 35

def call
  files = Dir.glob(File.join(root, "config", "environments", "*.rb")).sort.filter_map do |path|
    summarize(path)
  end

  {
    current: current_environment,
    count: files.size,
    environments: files
  }
rescue => e
  $stderr.puts "[rails-ai-context] EnvConfigIntrospector#call failed: #{e.message}" if ENV["DEBUG"]
  { error: e.message }
end