Class: Lotus::Lotusrc Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/lotusrc.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.

Create and read the .lotusrc 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.

Lotusrc name file

See Also:

  • #path_file

Since:

  • 0.3.0

'.lotusrc'.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
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 lotusrc 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 lotusrc 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 lotusrc file

See Also:

Since:

  • 0.3.0

'template'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(root, options = {}) ⇒ Lotusrc

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 Lotusrc class with application’s root and enviroment options. Create the lotusrc file if it doesn’t exist in the root given.

Parameters:

  • root (Pathname)

    Application’s root

  • options (Hash) (defaults to: {})

    Environment’s options

See Also:

Since:

  • 0.3.0



73
74
75
76
77
78
79
80
# File 'lib/lotus/lotusrc.rb', line 73

def initialize(root, options = {})
  @root    = root
  @options = options

  # NOTE this line is here in order to auto-upgrade applications generated
  # with lotusrb < 0.3.0. Consider to remove it in the future.
  create
end

Instance Method Details

#readLotus::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 lotusrc file and parse it’s values.

Examples:

Default values if file doesn’t exist

Lotus::Lotusrc.new(Pathname.new(Dir.pwd)).read
 # => { architecture: 'container', test: 'minitest', template: 'erb' }

Custom values if file doesn’t exist

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

Returns:

  • (Lotus::Utils::Hash)

    parsed values

Since:

  • 0.3.0



94
95
96
97
98
99
# File 'lib/lotus/lotusrc.rb', line 94

def read
  if exists?
    lotusrc_options = Dotenv.load path_file
    Utils::Hash.new(lotusrc_options).symbolize!
  end
end