Class: Hanami::Commands::New::Abstract

Inherits:
Object
  • Object
show all
Includes:
Generators::Generatable
Defined in:
lib/hanami/commands/new/abstract.rb

Overview

Since:

  • 0.1.0

Direct Known Subclasses

App, Container

Constant Summary collapse

DEFAULT_ARCHITECTURE =

Since:

  • 0.1.0

'container'.freeze
DEFAULT_APPLICATION_BASE_URL =

Since:

  • 0.1.0

'/'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Generators::Generatable

#add_mapping, #destroy, #generator, #map_templates, #post_process_templates, #process_templates, #template_options, #template_source_path

Constructor Details

#initialize(options, name) ⇒ Abstract

Returns a new instance of Abstract.

Since:

  • 0.1.0



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hanami/commands/new/abstract.rb', line 20

def initialize(options, name)
  @options = Hanami::Utils::Hash.new(options).symbolize!
  @name = name
  @options[:database] ||= Hanami::Generators::DatabaseConfig::DEFAULT_ENGINE

  assert_options!
  assert_name!
  assert_architecture!

  @hanami_model_version = '~> 0.5'
  @database_config = Hanami::Generators::DatabaseConfig.new(options[:database], app_name)
  @test_framework = Hanami::Generators::TestFramework.new(hanamirc, @options[:test])
end

Instance Attribute Details

#database_configObject (readonly)

Since:

  • 0.1.0



18
19
20
# File 'lib/hanami/commands/new/abstract.rb', line 18

def database_config
  @database_config
end

#optionsObject (readonly)

Since:

  • 0.1.0



18
19
20
# File 'lib/hanami/commands/new/abstract.rb', line 18

def options
  @options
end

#target_pathObject (readonly)

Since:

  • 0.1.0



18
19
20
# File 'lib/hanami/commands/new/abstract.rb', line 18

def target_path
  @target_path
end

#test_frameworkObject (readonly)

Since:

  • 0.1.0



18
19
20
# File 'lib/hanami/commands/new/abstract.rb', line 18

def test_framework
  @test_framework
end

Instance Method Details

#startObject

Since:

  • 0.1.0



34
35
36
37
38
39
40
41
# File 'lib/hanami/commands/new/abstract.rb', line 34

def start
  FileUtils.mkdir_p(@name)
  Dir.chdir(@name) do
    @target_path = Pathname.pwd

    super
  end
end