class Dpl::ConfigFile::ConfigFiles

Public Instance Methods

config() click to toggle source
# File lib/dpl/helper/config_file.rb, line 29
def config
  paths.map { |path| parse(path) }.inject(&:merge) || {}
end
parse(path) click to toggle source
# File lib/dpl/helper/config_file.rb, line 33
def parse(path)
  str = File.exist?(path) ? File.read(path) : ''
  opts = str.lines.select { |line| line.include?('=') }.map(&:strip)
  opts = opts.map { |pair| pair.split('=', 2) }.to_h
  opts.transform_keys { |key| strip_prefix(key).to_sym }
end
strip_prefix(str) click to toggle source
# File lib/dpl/helper/config_file.rb, line 40
def strip_prefix(str)
  opts[:prefix] ? str.sub(/^#{opts[:prefix]}[-_]?/, '') : str
end