lib/hanami/commands/new/container.rb in hanami-1.0.0.beta2 vs lib/hanami/commands/new/container.rb in hanami-1.0.0.beta3
- old
+ new
@@ -1,23 +1,29 @@
require 'hanami/commands/generate/app'
require 'hanami/commands/new/abstract'
module Hanami
+ # @api private
module Commands
+ # @api private
class New
+ # @api private
class Container < Abstract
+ # @api private
DEFAULT_APPLICATION_NAME = 'web'.freeze
+ # @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
{
project_name: project_name,
hanami_head: hanami_head?,
code_reloading: code_reloading?,
@@ -28,17 +34,19 @@
hanami_version: hanami_version,
template: template_engine.name
}
end
+ # @api private
def post_process_templates
init_git
generate_app
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')
@@ -46,10 +54,11 @@
add_mapping('config/boot.rb.tt', 'config/boot.rb')
add_mapping('config/environment.rb.tt', 'config/environment.rb')
add_mapping('lib/project.rb.tt', "lib/#{ project_name }.rb")
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')
@@ -60,10 +69,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', 'public/.gitkeep')
add_mapping('.gitkeep', 'config/initializers/.gitkeep')
add_mapping('.gitkeep', "lib/#{ project_name }/entities/.gitkeep")
add_mapping('.gitkeep', "lib/#{ project_name }/repositories/.gitkeep")
@@ -79,23 +89,27 @@
else
add_mapping('.gitkeep', 'db/.gitkeep')
end
end
+ # @api private
def generate_app
Hanami::Commands::Generate::App.new(app_options, app_slice_name).start
end
+ # @api private
def app_options
{
application_base_url: application_base_url
}
end
+ # @api private
def app_slice_name
options.fetch(:application_name, DEFAULT_APPLICATION_NAME)
end
+ # @api private
def template_source_path
Pathname.new(::File.dirname(__FILE__)).join('..', '..', 'generators', 'application', 'container').realpath
end
end
end