Class: Reeve::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/reeve/install/install_generator.rb

Overview

bin/rails generate reeve:install — step two of the three-step adoption path (Constitution VI). Writes an initializer and the ledger migration, and nothing else.

The initializer deliberately ships with principal_resolver unset: it is the one thing only the host can answer, and a plausible-looking guess would be worse than a TODO, because the library fails closed until it is filled in.

Instance Method Summary collapse

Instance Method Details

#create_initializerObject



21
22
23
# File 'lib/generators/reeve/install/install_generator.rb', line 21

def create_initializer
  template "initializer.rb.tt", "config/initializers/reeve.rb"
end

#create_migration_fileObject



25
26
27
28
29
30
# File 'lib/generators/reeve/install/install_generator.rb', line 25

def create_migration_file
  migration_template(
    "create_audit_entries.rb.tt",
    "db/migrate/create_reeve_audit_entries.rb"
  )
end

#report_next_stepObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/generators/reeve/install/install_generator.rb', line 32

def report_next_step
  say <<~NEXT

    reeve is installed. Two things left:

      1. Fill in `principal_resolver` in config/initializers/reeve.rb.
         Until you do, every guarded call denies with `no_principal`.
      2. Run `bin/rails db:migrate` to create the audit ledger.

    Then add `guard_with SomePolicy` to a tool.
  NEXT
end