Module: Formatron::Config

Defined in:
lib/formatron/config.rb,
lib/formatron/config/reader.rb

Overview

Processes the config directory

Defined Under Namespace

Modules: Reader

Constant Summary collapse

CONFIG_DIR =
'config'
DEFAULT_CONFIG =
'_default'
DEFAULT_JSON =
'_default.json'

Class Method Summary collapse

Class Method Details

.target(directory:, target:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/formatron/config.rb', line 19

def self.target(directory:, target:)
  Reader.read(
    File.join(directory, CONFIG_DIR, DEFAULT_CONFIG),
    DEFAULT_JSON
  ).deep_merge!(
    Reader.read(
      File.join(directory, CONFIG_DIR, target),
      DEFAULT_JSON
    )
  )
end

.targets(directory:) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/formatron/config.rb', line 11

def self.targets(directory:)
  config = File.join directory, CONFIG_DIR
  Dir.entries(config).select do |entry|
    path = File.join config, entry
    File.directory?(path) && !%W(#{DEFAULT_CONFIG} . ..).include?(entry)
  end
end