Class: Hanami::Commands::Generate::App

Inherits:
Abstract show all
Defined in:
lib/hanami/commands/generate/app.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options

Instance Method Summary collapse

Methods inherited from Abstract

#template_source_path

Methods included from Generators::Generatable

#add_mapping, #argument_blank?, #destroy, #generator, #process_templates, #start, #template_source_path

Methods inherited from Command

inherited

Constructor Details

#initialize(options, application_name) ⇒ App


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hanami/commands/generate/app.rb', line 13

def initialize(options, application_name)
  @environment = Hanami::Environment.new(options)
  @options = Hanami::Utils::Hash.new(options).symbolize!
  assert_options!

  @target_path = Hanami.root
  assert_application_name!(application_name)
  assert_architecture!
  assert_application_base_url!

  @application_name = ApplicationName.new(application_name)
  @base_path = Pathname.pwd
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path


11
12
13
# File 'lib/hanami/commands/generate/app.rb', line 11

def base_path
  @base_path
end

Instance Method Details

#map_templatesObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hanami/commands/generate/app.rb', line 27

def map_templates
  add_mapping('application.rb.tt', 'application.rb')
  add_mapping('config/routes.rb.tt', 'config/routes.rb')
  add_mapping('views/application_layout.rb.tt', 'views/application_layout.rb')
  add_mapping("templates/application.html.#{ template_engine.name }.tt", "templates/application.html.#{ template_engine.name }")
  add_mapping('favicon.ico', 'assets/favicon.ico')

  add_mapping('.gitkeep', 'controllers/.gitkeep')
  add_mapping('.gitkeep', 'assets/images/.gitkeep')
  add_mapping('.gitkeep', 'assets/javascripts/.gitkeep')
  add_mapping('.gitkeep', 'assets/stylesheets/.gitkeep')
  add_mapping('.gitkeep', "../../spec/#{ app_name }/features/.gitkeep")
  add_mapping('.gitkeep', "../../spec/#{ app_name }/controllers/.gitkeep")
  add_mapping('.gitkeep', "../../spec/#{ app_name }/views/.gitkeep")
end

#post_process_templatesObject


54
55
56
57
58
# File 'lib/hanami/commands/generate/app.rb', line 54

def post_process_templates
  add_require_app
  add_mount_app
  add_web_session_secret
end

#template_optionsObject


43
44
45
46
47
48
49
50
51
52
# File 'lib/hanami/commands/generate/app.rb', line 43

def template_options
  {
    app_name:            app_name,
    upcase_app_name:     upcase_app_name,
    classified_app_name: classified_app_name,
    app_base_url:        application_base_url,
    app_base_path:       application_base_path,
    template:            template_engine.name
  }
end