Project

comfy_conf

0.0
No commit activity in last 3 years
No release in over 3 years
ComfyConf provides a minimal DSL for parsing YAML config files into a structured and type-checked configuration
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0
 Project Readme

ComfyConf

Provides a basic specification and validation layer for YAML configs.

Install

gem install comfy_conf

Use

  require 'comfy_conf'

  conf = ComfyConf::Parser.new('./config.yml') do
    prop :name, type: String, required: true
    prop :age, type: Numeric # required defaults to false

    # Defaults may be set for props
    prop :favorite_pizza, type: String, default: 'cheeze'

    config :nested_options, required: false do
      prop :nested_option, required: true, type: String
    end
  end

  begin
    $config = conf.data
  rescue ComfyConf::Error => e
    STDERR.puts(e.message)
    exit 1
  end

  puts "Name:       " + $config.name
  puts "Age:        " + $config.age || 'N/A'

  if $config.nested_options
    puts "Nested Opt: " + $config.nested_options.nested_option
  end

Status

This is extracted from some ruby scripts I use for some basic system admin tasks. I don't expect to add much to it but if bugs crop up I'll address them.

As reflected by the version number, this lib is beta-quality at best. That shouldn't matter too much for basic config loading but don't use this anywhere too critical.

Contribute

Just fork and PR.

LICENSE

MIT