lib/hanami/commands/generate/app.rb in hanami-0.7.3 vs lib/hanami/commands/generate/app.rb in hanami-0.8.0
- old
+ new
@@ -9,11 +9,10 @@
attr_reader :base_path
def initialize(options, application_name)
super(options)
-
assert_application_name!(application_name)
assert_architecture!
@application_name = ApplicationName.new(application_name)
@base_path = Pathname.pwd
@@ -21,11 +20,11 @@
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.erb.tt', 'templates/application.html.erb')
+ 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')
@@ -40,10 +39,11 @@
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
def post_process_templates
add_require_app
@@ -77,10 +77,14 @@
%(#{ upcase_app_name }_SESSIONS_SECRET="#{ SecureRandom.hex(32) }"\n)
end
end
end
+ def hanamirc
+ @hanamirc ||= Hanamirc.new(base_path)
+ end
+
def target_path
base_path.join(application_base_path)
end
def app_name
@@ -98,11 +102,11 @@
def classified_app_name
Utils::String.new(app_name).classify.tr('::', '')
end
def assert_application_name!(value)
- if value.nil? || value.strip.empty?
- raise ArgumentError.new('Application name is nil or empty')
+ if argument_blank?(value)
+ raise ArgumentError.new('Application name is missing')
end
end
def assert_architecture!
if !environment.container?