Module: Omen::Requirements

Defined in:
lib/omen/requirements.rb

Overview

What an app has to be for this gem to keep its promises, checked as that app boots. Both of these rule an app out rather than inconveniencing it, so neither is worth deferring.

Defined Under Namespace

Classes: Unmet

Constant Summary collapse

ADAPTER =

The one adapter that reports the table a result column came from, and scopes a role to a transaction. Everything else Omen promises rests on one of those two.

'postgresql'
FORMAT =

The one schema format that can be read as a prompt.

:ruby
WRONG_ADAPTER =

Said where the app reaches its database through anything else.

'Omen needs a postgresql database, and this app names the adapter'
WRONG_FORMAT =

Said where the app dumps its schema as SQL, which cannot be shown to Claude.

'Omen shows Claude db/schema.rb, so config.active_record.schema_format ' \
'has to be :ruby, and this app sets'
NO_SCHEMA =

Said where the file is not there at all: a run would fail one question at a time, and a structure.sql copied to that path would leave the reading tables in the prompt.

'Omen shows Claude the schema Rails dumps, and there is no file at'

Class Method Summary collapse

Class Method Details

.met(adapter:, schema_format:, schema:) ⇒ void

This method returns an undefined value.

Parameters:

  • adapter (String, nil) —

    what this app reaches its own database through.

  • schema_format (Symbol, nil) —

    the format it declares, nil where it declares none.

  • schema (Pathname) —

    where the dump is kept.

Raises:



30
31
32
33
34
35
# File 'lib/omen/requirements.rb', line 30

def self.met(adapter:, schema_format:, schema:)
  dumps = schema_format || FORMAT
  raise Unmet, "#{WRONG_ADAPTER} #{adapter.inspect}" unless adapter == ADAPTER
  raise Unmet, "#{WRONG_FORMAT} #{dumps.inspect}" unless dumps == FORMAT
  raise Unmet, "#{NO_SCHEMA} #{schema}" unless File.exist? schema
end