Sha256: d5cec24da5663de492c8b43e365c62a006bc9e249c14b69dd922838141fd64b2
Contents?: true
Size: 895 Bytes
Versions: 8
Compression:
Stored size: 895 Bytes
Contents
# frozen_string_literal: true module LB module Project # Configuration class Config < Dry::Struct ERROR_MSG = 'load failed: config class is not a LB::Project::Condig' RequiredString = Types::Strict::String.constrained(min_size: 1) attribute :base_path, Types::Strict::String attribute :image_base_path, Types::Strict::String attribute :public_path, Types::Strict::String attribute :template_path, Types::Strict::String 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 def self.not_found_msg(path) "load failed: config file '#{path}' does not exist!" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems