lib/hanami/commands/new/app.rb in hanami-1.0.0.beta2 vs lib/hanami/commands/new/app.rb in hanami-1.0.0.beta3
- old
+ new
@@ -1,24 +1,30 @@
require 'hanami/commands/new/abstract'
module Hanami
+ # @api private
module Commands
+ # @api private
class New
+ # @api private
class App < Abstract
+ # @api private
def initialize(options, name)
super(options, name)
end
+ # @api private
def map_templates
add_application_templates
add_empty_directories
add_test_templates
add_sql_templates
add_git_templates
end
+ # @api private
def template_options
{
app_name: app_name,
upcase_app_name: upcase_app_name,
classified_app_name: classified_app_name,
@@ -31,16 +37,18 @@
hanami_version: hanami_version,
template: template_engine.name
}
end
+ # @api private
def post_process_templates
init_git
end
private
+ # @api private
def add_application_templates
add_mapping('hanamirc.tt', '.hanamirc')
add_mapping('.env.development.tt', '.env.development')
add_mapping('.env.test.tt', '.env.test')
add_mapping('Gemfile.tt', 'Gemfile')
@@ -52,10 +60,11 @@
add_mapping('views/application_layout.rb.tt', 'app/views/application_layout.rb')
add_mapping("templates/application.html.#{ template_engine.name }.tt", "app/templates/application.html.#{ template_engine.name }")
add_mapping('favicon.ico', 'app/assets/favicon.ico')
end
+ # @api private
def add_test_templates
if test_framework.rspec?
add_mapping('Rakefile.rspec.tt', 'Rakefile')
add_mapping('rspec.rspec.tt', '.rspec')
add_mapping('spec_helper.rb.rspec.tt', 'spec/spec_helper.rb')
@@ -66,10 +75,11 @@
add_mapping('spec_helper.rb.minitest.tt', 'spec/spec_helper.rb')
add_mapping('features_helper.rb.minitest.tt', 'spec/features_helper.rb')
end
end
+ # @api private
def add_empty_directories
add_mapping('.gitkeep', 'config/initializers/.gitkeep')
add_mapping('.gitkeep', 'app/controllers/.gitkeep')
add_mapping('.gitkeep', 'app/views/.gitkeep')
add_mapping('.gitkeep', 'app/assets/images/.gitkeep')
@@ -93,21 +103,26 @@
add_mapping('.gitkeep', 'db/migrations/.gitkeep')
else
add_mapping('.gitkeep', 'db/.gitkeep')
end
end
+
+ # @api private
def template_source_path
Pathname.new(::File.dirname(__FILE__)).join('..', '..', 'generators', 'application', 'app').realpath
end
+ # @api private
def upcase_app_name
app_name.to_env_s
end
+ # @api private
def classified_app_name
Utils::String.new(app_name).classify.tr('::', '')
end
+ # @api private
alias app_name project_name
end
end
end
end