Skip to content
Configuration schema with calculable but overwriteable defaults
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
README
Rakefile
funfig.gemspec

README

Example
=======

    require 'funfig'
    
    UploadConf = Funfig.new do
      p.root '/services'
      g.nginx   do
        p.folder { File.join(_.root, 'nginx') }
        p.port '8000'
      end
      p.public_ip_port '*:80'
    end
    
    conf = UploadConf.new
    p conf.nginx.folder
    conf.root = "~/MailProject/upload"
    p conf.nginx.folder
    conf.each {|k,v| puts "#{k} #{v}"}
    p conf
    p conf.to_hash()
    p conf.to_hash(true)
    
    Up1Conf = UploadConf.clone do
      g.nginx do
        p.folder { File.join(_.root, 'nganx') }
        p.location '/public'
      end
    end
    
    conf1 = Up1Conf.new
    conf1.update(conf.to_hash())
    p conf1
    conf1.nginx_reset!
    p conf1

TODO
====

1. define array of same kinds

    Conf = Funfig.new do
      p.port 8000
      p.folder '/folder'
      array :servers do
        p.port { _parent.port + _pos }
        p.folder { File.join(_parent.folder, _pos.to_s) }
      end
      a.servers1 do
        p.port { _parent.port + _pos }
        p.folder { File.join(_parent.folder, _pos.to_s) }
      end
    end

2. define hash of same kinds

    Conf = Funfig.new do
      hash :environments do
        p.host 'localhost'
        p.database { "mybase_#{_name}" }
      end
      h.environments1 do
        p.host 'localhost'
        p.database { "mybase_#{_name}" }
      end
    end

3. Correct composition of schemes

    ConfServ = Funfig.new do
      p.port 80
      p.ip   '192.168.168.192'
    end

    ConfApp = Funfig.new do
      p.path '/srv/path'
      g.server ConfServ do
        p.path { _.path }
      end
    end

Something went wrong with that request. Please try again.