Class: ForestLiana::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#installObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/forest_liana/install_generator.rb', line 9

def install
  route "mount ForestLiana::Engine => '/forest'"

  initializer 'forest_liana.rb' do
    "ForestLiana.env_secret = Rails.application.secrets.forest_env_secret" +
    "\nForestLiana.auth_secret = Rails.application.secrets.forest_auth_secret"
  end

  auth_secret = SecureRandom.urlsafe_base64

  puts "\nForest generated a random authentication secret to secure the " +
    "data access of your local project.\nYou can change it at any time in " +
    "your config/secrets.yml file.\n\n"

  inject_into_file 'config/secrets.yml', after: "development:\n" do
    "  forest_env_secret: #{env_secret}\n" +
    "  forest_auth_secret: #{auth_secret}\n"
  end

  inject_into_file 'config/secrets.yml', after: "staging:\n", force: true do
    "  forest_env_secret: <%= ENV[\"FOREST_ENV_SECRET\"] %>\n" +
    "  forest_auth_secret: <%= ENV[\"FOREST_AUTH_SECRET\"] %>\n"
  end

  inject_into_file 'config/secrets.yml', after: "production:\n", force: true do
    "  forest_env_secret: <%= ENV[\"FOREST_ENV_SECRET\"] %>\n" +
    "  forest_auth_secret: <%= ENV[\"FOREST_AUTH_SECRET\"] %>\n"
  end
end