Sha256: 3600d4e3e5c123be5b70824eb2a060af5b0b51a5051c943a0b3c9aab6d4a8183
Contents?: true
Size: 959 Bytes
Versions: 2
Compression:
Stored size: 959 Bytes
Contents
module Lookbook class TagStore CONFIG_FILE = "config/tags.yml" attr_reader :store delegate :to_h, to: :store def initialize(config = nil) @store = {} config.to_h.each { add_tag(_1, _2) } end def add_tag(name, opts = nil) name = name.to_sym if store.key?(name) raise ConfigError.new("tag with name '#{name}' already exists", scope: "tags.config") else store[name] = build_config(name, opts) end end def get_tag(name) store[name.to_sym] end def self.init_from_config new(default_config) end def self.default_config ConfigLoader.call(CONFIG_FILE) end protected def build_config(name, opts = nil) opts = opts.to_h Store.new({ name: name.to_sym, label: opts[:label] || name.to_s.titleize, yard_parser: opts[:yard_parser]&.to_sym, opts: opts[:opts].to_h }) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lookbook-1.2.1 | lib/lookbook/stores/tag_store.rb |
lookbook-1.2.0 | lib/lookbook/stores/tag_store.rb |