Posted By

gtcaz on 02/14/07


Tagged

ruby config yaml


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

webstic
trevorhartman
stephanepericat


YAML Config File Example


 / Published in: Ruby
 

  1. #!/usr/bin/ruby -w
  2. require 'yaml'
  3.  
  4. config = {"pass" => "mybigsecret123", "dir"=>"/cygdrive/c/tmp/", "user"=>"gtcaz", "url"=>"http://snipplr.com"}
  5. p config.to_yaml
  6. open('/cygdrive/c/tmp/config.yml', 'w') {|f| YAML.dump(config, f)}
  7. open('/cygdrive/c/tmp/config.yml') {|f| puts f.read}
  8. conf2 = open('/cygdrive/c/tmp/config.yml') {|f| YAML.load(f) }
  9. conf2.each{ |k, v| puts "#{k} => #{v}" }

Report this snippet  

You need to login to post a comment.