Class: Jobshop::DummyBuilder

Inherits:
AppBuilder
  • Object
show all
Defined in:
lib/generators/jobshop/dummy/dummy_generator.rb

Instance Method Summary collapse

Methods inherited from AppBuilder

#gemfile, #mount_engine

Instance Method Details

#config_database_ymlObject

Comment out username, password from production group.



11
12
13
14
# File 'lib/generators/jobshop/dummy/dummy_generator.rb', line 11

def config_database_yml
  gsub_file "config/database.yml",
    /^([ ]*[^#])(username: .*|password: .*)$/, '\1# \2'
end

#db_migrateObject

The db/migrate folder isn’t created automatically.



17
18
19
20
21
22
# File 'lib/generators/jobshop/dummy/dummy_generator.rb', line 17

def db_migrate
  unless Dir.exist?("db/migrate")
    say_status :create, "db/migrate"
    Dir.mkdir("db/migrate")
  end
end

#expose_mailer_previewsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/jobshop/dummy/dummy_generator.rb', line 24

def expose_mailer_previews
  # Mailer previews don't really play nice with Engines so in the dummy app we
  # create an initializer to expose them properly.
  initializer "jobshop_expose_mailer_previews.rb", <<~INITIALIZER
    if Rails.env.development? || Rails.env.test?
      Rails.application.configure do
        config.action_mailer.preview_path = "\#{Jobshop::Engine.root}/spec/mailers"
      end
    end
  INITIALIZER
end

#localhost_tld_lengthObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/jobshop/dummy/dummy_generator.rb', line 36

def localhost_tld_length
  # This allows us to easily use the localhost hostname in development.
  initializer "jobshop_tld_length.rb", <<~INITIALIZER
    if Rails.env.development? || Rails.env.test?
      Rails.application.configure do
        config.action_dispatch.tld_length = 0
      end
    end
  INITIALIZER
end

#readmeObject



6
7
8
# File 'lib/generators/jobshop/dummy/dummy_generator.rb', line 6

def readme
  # Do not generate README.md
end