YAML Config File Example

/ Published in: Ruby
Save to your folder(s)

Copy this code and paste it in your HTML
  1. #!/usr/bin/ruby -w
  2. require 'yaml'
  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


RSS Icon Subscribe to comments

You need to login to post a comment.