Class: LB::Project::Config

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/lb/project/config.rb

Overview

Configuration

Constant Summary collapse

ERROR_MSG =
'load failed: config class is not a LB::Project::Condig'
RequiredString =
Types::Strict::String.constrained(min_size: 1)

Class Method Summary collapse

Class Method Details

.load(path, klass = LB::Project::Config) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
# File 'lib/lb/project/config.rb', line 15

def self.load(path, klass = LB::Project::Config)
  raise ArgumentError, ERROR_MSG unless klass <= LB::Project::Config

  raise ArgumentError, not_found_msg(path) unless File.exist?(path)

  yaml = YAML.load_file(path)
  klass.new(yaml.transform_keys!(&:to_sym))
end

.not_found_msg(path) ⇒ Object



24
25
26
# File 'lib/lb/project/config.rb', line 24

def self.not_found_msg(path)
  "load failed: config file '#{path}' does not exist!"
end