Sha256: 8ffcd1eb23b40b60be63e8b884a55011eb7ddad3b480a27902079c9441899c5b
Contents?: true
Size: 791 Bytes
Versions: 4
Compression:
Stored size: 791 Bytes
Contents
# frozen_string_literal: true require 'safe_yaml' module Riserva class Config DEFAULT_PATH = 'config/riserva.yml' def initialize SafeYAML::OPTIONS[:default_mode] = :safe @path = ENV['RISERVA_CONFIG'] || DEFAULT_PATH end def self.read(yaml_path) new.read(yaml_path) end def read(yaml_path) keys = yaml_path.split('.') config.dig(*keys) end def self.folders read('folders').each { |folder| yield Pathname.new(folder) } end def self.storages read('storage').keys.each do |storage| klass = "Riserva::Storage::#{storage.camelize}" yield(klass.safe_constantize.new) unless klass.nil? end end private def config @config ||= YAML.load_file(@path) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
riserva-0.1.3 | lib/riserva/config.rb |
riserva-0.1.2 | lib/riserva/config.rb |
riserva-0.1.1 | lib/riserva/config.rb |
riserva-0.1.0 | lib/riserva/config.rb |