Sha256: d3eb3f64d5aef43322877c2eeeff6f787769ce8e80274551dba34ae9bb2cf838
Contents?: true
Size: 618 Bytes
Versions: 9
Compression:
Stored size: 618 Bytes
Contents
# frozen_string_literal: true require "yaml" require_relative "config_parser/errors" module ImapMogura module ConfigParser class << self def parse(config_name) config = YAML.safe_load_file(config_name) raise ParseError, "config must be in hash format" unless config.is_a?(Hash) raise ParseError, "\"rules:\" must be defined" unless config.key?("rules") metadata = config["metadata"] rules = config["rules"] [metadata, rules] rescue YAML::SyntaxError => e raise ParseError, "failed to parse yaml: #{e.message}" end end end end
Version data entries
9 entries across 9 versions & 1 rubygems