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

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of App.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hanami/commands/generate/app.rb', line 18

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)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
# File 'lib/hanami/commands/generate/app.rb', line 15

def base_path
  @base_path
end

Instance Method Details

#map_templatesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/hanami/commands/generate/app.rb', line 33

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



62
63
64
65
66
# File 'lib/hanami/commands/generate/app.rb', line 62

def post_process_templates
  add_require_app
  add_mount_app
  add_web_session_secret
end

#template_optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
55
56
57
58
59
# File 'lib/hanami/commands/generate/app.rb', line 50

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