Class: Sentiero::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/sentiero/rails/generators/sentiero/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



16
17
18
# File 'lib/sentiero/rails/generators/sentiero/install_generator.rb', line 16

def self.next_migration_number(dirname)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#create_initializerObject



25
26
27
# File 'lib/sentiero/rails/generators/sentiero/install_generator.rb', line 25

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

#create_migration_fileObject



20
21
22
23
# File 'lib/sentiero/rails/generators/sentiero/install_generator.rb', line 20

def create_migration_file
  migration_template "create_sentiero_tables.rb.erb",
    "db/migrate/create_sentiero_tables.rb"
end

#show_route_instructionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/sentiero/rails/generators/sentiero/install_generator.rb', line 29

def show_route_instructions
  say ""
  say "Sentiero installed successfully!", :green
  say ""
  say "Next steps:", :yellow
  say "  1. Run migrations:  rails db:migrate"
  say "  2. Mount the Rack apps in config/routes.rb:"
  say ""
  say "    # config/routes.rb"
  say '    mount Sentiero::Web::EventsApp.new, at: "/sentiero/events"'
  say '    mount Sentiero::Web::DashboardApp.new, at: "/sentiero"'
  say ""
  say "  3. Add the script tag to your layout:"
  say "    <%= sentiero_script_tag %>"
  say ""
  password = SecureRandom.urlsafe_base64(12)
  say "Dashboard auth is ENABLED by default (HTTP Basic, user \"admin\").", :yellow
  say "Set this generated password in your environment:"
  say ""
  say "    export SENTIERO_DASHBOARD_PASSWORD=#{password}"
  say ""
  say "The dashboard refuses to load until SENTIERO_DASHBOARD_PASSWORD is set."
  say "To disable auth, comment out config.basic_auth in config/initializers/sentiero.rb."
  say ""
end