Class: Karst::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/karst/install/install_generator.rb

Overview

bin/rails generate karst:install

Scaffolds a compact initializer plus the development-only probe identity controller/routes a custom (non-Devise) identity configuration can drive. See the generated files themselves for what each seam is responsible for.

This generator does not need to detect Devise/Warden itself: that detection happens at runtime, from Devise's own routing metadata (see Karst::Identity::DeviseSupport), not at generation time. A conventional single-model Devise application needs nothing from this generator. The initializer, identity controller, and routes exist only for applications that fall back to a custom config.assume_identity / config.clear_identity pair.

This generator is convenience/scaffolding only. Karst remains fully configurable by hand (see README.md); nothing at runtime requires this generator to have been run, and an application that already configures Karst manually has no need to run it.

Idempotent: running it again only touches files whose content actually changed, via Thor's own file-collision handling, and the routes insertion is a no-op once the exact same route block is already present.

Instance Method Summary collapse

Instance Method Details

#add_development_routesObject



71
72
73
74
75
76
77
78
# File 'lib/generators/karst/install/install_generator.rb', line 71

def add_development_routes
  # `route` (a Rails::Generators::Actions helper) injects this exact
  # string once via Thor's own force: false collision handling: a
  # second run whose routes.rb already contains this text is a no-op,
  # so this stays safe to run more than once without duplicating
  # routes or requiring bespoke parsing of config/routes.rb.
  route(DEVELOPMENT_ROUTES.chomp)
end

#copy_identity_controllerObject



67
68
69
# File 'lib/generators/karst/install/install_generator.rb', line 67

def copy_identity_controller
  copy_file "karst_identity_controller.rb", "app/controllers/karst_identity_controller.rb"
end

#copy_initializerObject



63
64
65
# File 'lib/generators/karst/install/install_generator.rb', line 63

def copy_initializer
  copy_file "karst_initializer.rb", "config/initializers/karst.rb"
end

#post_install_messageObject



80
81
82
83
84
85
# File 'lib/generators/karst/install/install_generator.rb', line 80

def post_install_message
  say ""
  say "Karst custom-authentication scaffold created.", :green
  say NEXT_STEPS
  say "Complete the TODOs with this application's real identity semantics.", :yellow
end