cc-os/plugins/os-backlog/lib/backlog/config.rb

23 lines
635 B
Ruby

require "yaml"
module Backlog
# The parsed contents of a repo's `.cc-os/config` (YAML). Only the
# `board` key matters to the resolver: an explicit board-name override.
# Never touches the filesystem itself — callers read the file and pass
# its contents (or nil, if absent) in.
class Config
def initialize(contents)
@data = contents.to_s.strip.empty? ? {} : (YAML.safe_load(contents) || {})
rescue Psych::SyntaxError
@data = {}
end
# @return [String, nil] the explicit board name override, if configured
def board
@data["board"]
end
def configured? = !board.nil?
end
end