Class: Woods::Extractors::BehavioralProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/extractors/behavioral_profile.rb

Overview

BehavioralProfile introspects resolved Rails.application.config values to produce a single ExtractedUnit summarizing the app’s runtime behavioral configuration.

Sections extracted (each independently guarded):

  • Database: adapter, schema_format, belongs_to_required, has_many_inversing

  • Frameworks: ActionCable, ActiveStorage, ActionMailbox, ActionText, Turbo, Stimulus, SolidQueue, SolidCache

  • Behavior flags: api_only, eager_load, time_zone, strong params action, session store, filter params

  • Background processing: active_job queue_adapter

  • Caching: cache_store type

  • Email: delivery_method

Examples:

profile = BehavioralProfile.new
unit = profile.extract
unit.[:database][:adapter] #=> "postgresql"

Constant Summary collapse

FRAMEWORK_CHECKS =

Frameworks to detect via ‘defined?` checks

{
  action_cable: 'ActionCable',
  active_storage: 'ActiveStorage',
  action_mailbox: 'ActionMailbox',
  action_text: 'ActionText',
  turbo: 'Turbo',
  stimulus_reflex: 'StimulusReflex',
  solid_queue: 'SolidQueue',
  solid_cache: 'SolidCache'
}.freeze

Instance Method Summary collapse

Instance Method Details

#extractExtractedUnit?

Extract a behavioral profile from the current Rails application.

Returns:

  • (ExtractedUnit, nil)

    A single configuration unit, or nil on catastrophic failure



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/woods/extractors/behavioral_profile.rb', line 38

def extract
  config = Rails.application.config

  profile = {
    config_type: 'behavioral_profile',
    rails_version: Rails.version,
    ruby_version: RUBY_VERSION,
    database: extract_database(config),
    frameworks_active: extract_frameworks,
    behavior_flags: extract_behavior_flags(config),
    background_processing: extract_background(config),
    caching: extract_caching(config),
    email: extract_email(config)
  }

  build_unit(profile)
rescue StandardError => e
  Rails.logger.error("BehavioralProfile extraction failed: #{e.message}")
  nil
end