Class: Jobshop::AppBuilder

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/generators/jobshop/app/app_generator.rb

Direct Known Subclasses

DummyBuilder

Instance Method Summary collapse

Instance Method Details

#config_schema_formatObject



19
20
21
22
23
24
# File 'lib/generators/jobshop/app/app_generator.rb', line 19

def config_schema_format
  data = "config.active_record.schema_format = :sql"
  sentinel = /class [a-z_:]+ < Rails::Application/i
  inject_into_file("config/application.rb", "\n    #{data}",
                   after: sentinel, verbose: true)
end

#credentialsObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/generators/jobshop/app/app_generator.rb', line 26

def credentials
  return if options[:pretend] || options[:dummy_app]

  require "active_support/encrypted_configuration"
  credentials = ActiveSupport::EncryptedConfiguration.new(
    config_path: "config/credentials.yml.enc",
    key_path: "config/master.key",
    env_key: "RAILS_MASTER_KEY",
    raise_if_missing_key: true
  )
  credentials_template = <<~YAML
    # aws:
    #   access_key_id: 123
    #   secret_access_key: 345
    # Used the base secret for all MessageVerifiers in Rails, including the one protecting cookies.
    secret_key_base: #{SecureRandom.hex(64)}
  YAML
  credentials.write(credentials_template)
end

#gemfileObject



12
13
14
15
16
17
# File 'lib/generators/jobshop/app/app_generator.rb', line 12

def gemfile
  super
  append_to_file "Gemfile", <<~GEMFILE
    \ngem "jobshop", "~> #{Jobshop.gem_version}"
  GEMFILE
end

#mount_engineObject



46
47
48
# File 'lib/generators/jobshop/app/app_generator.rb', line 46

def mount_engine
  route %Q(mount Jobshop::Engine => "/")
end

#readmeObject



8
9
10
# File 'lib/generators/jobshop/app/app_generator.rb', line 8

def readme
  template "README.md.tt"
end