Class: Packs::Specification::Configuration

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packs/specification/configuration.rb

Constant Summary collapse

CONFIGURATION_PATHNAME =
T.let(Pathname.new('packs.yml'), Pathname)
DEFAULT_PACK_PATHS =
T.let([
  'packs/*',
  'packs/*/*'
], T::Array[String])

Class Method Summary collapse

Class Method Details

.fetchObject



17
18
19
20
21
22
23
# File 'lib/packs/specification/configuration.rb', line 17

def self.fetch
  config_hash = CONFIGURATION_PATHNAME.exist? ? YAML.load_file(CONFIGURATION_PATHNAME) : {}

  new(
    pack_paths: pack_paths(config_hash)
  )
end

.pack_paths(config_hash) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/packs/specification/configuration.rb', line 26

def self.pack_paths(config_hash)
  specified_pack_paths = config_hash['pack_paths']
  if specified_pack_paths.nil?
    DEFAULT_PACK_PATHS.dup
  else
    Array(specified_pack_paths)
  end
end