Class: Hanami::Hanamirc Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/hanamirc.rb

Overview

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.

Read the .hanamirc file in the root of the application

Since:

  • 0.3.0

Constant Summary collapse

FILE_NAME =

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

Hanamirc name file

See Also:

  • #path_file

Since:

  • 0.3.0

'.hanamirc'.freeze
DEFAULT_ARCHITECTURE =

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

Architecture default value

See Also:

Since:

  • 0.3.0

'container'.freeze
APP_ARCHITECTURE =

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

Application architecture value

Since:

  • 0.6.0

'app'.freeze
ARCHITECTURE_KEY =

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

Architecture key for writing the hanamirc file

See Also:

Since:

  • 0.3.0

'architecture'.freeze
DEFAULT_TEST_SUITE =

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

Test suite default value

See Also:

Since:

  • 0.3.0

'minitest'.freeze
TEST_KEY =

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

Test suite key for writing the hanamirc file

See Also:

Since:

  • 0.3.0

'test'.freeze
DEFAULT_TEMPLATE =

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

Template default value

See Also:

Since:

  • 0.3.0

'erb'.freeze
TEMPLATE_KEY =

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

Template key for writing the hanamirc file

See Also:

Since:

  • 0.3.0

'template'.freeze
DEFAULT_OPTIONS =

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

Default values for writing the hanamirc file

See Also:

Since:

  • 0.5.1

Utils::Hash.new({
  ARCHITECTURE_KEY => DEFAULT_ARCHITECTURE,
  TEST_KEY         => DEFAULT_TEST_SUITE,
  TEMPLATE_KEY     => DEFAULT_TEMPLATE
}).symbolize!.freeze

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Hanamirc

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.

Initialize Hanamirc class with application’s root and environment options.

Parameters:

  • root (Pathname)

    Application’s root

See Also:

Since:

  • 0.3.0



90
91
92
# File 'lib/hanami/hanamirc.rb', line 90

def initialize(root)
  @root = root
end

Instance Method Details

#exists?Boolean

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.

Check if hanamirc file exists

Returns:

  • (Boolean)

    hanamirc file’s path existing

Since:

  • 0.3.0



116
117
118
# File 'lib/hanami/hanamirc.rb', line 116

def exists?
  path_file.exist?
end

#optionsHanami::Utils::Hash

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.

Read hanamirc file (if exists) and parse it’s values or return default.

Examples:

Default values if file doesn’t exist

Hanami::Hanamirc.new(Pathname.new(Dir.pwd)).options
 # => { architecture: 'container', test: 'minitest', template: 'erb' }

Custom values if file doesn’t exist

options = { architect: 'application', test: 'rspec', template: 'slim' }
Hanami::Hanamirc.new(Pathname.new(Dir.pwd), options).options
 # => { architecture: 'application', test: 'rspec', template: 'slim' }

Returns:

  • (Hanami::Utils::Hash)

    parsed values

Since:

  • 0.3.0



106
107
108
# File 'lib/hanami/hanamirc.rb', line 106

def options
  @options ||= symbolize(DEFAULT_OPTIONS.merge(file_options))
end