Re: Config files



I like using Ruby directly for doing stuff like this (if the "configuration file" is under my control).

Example:
module MyConfig
user = 'username'
pass = 'password'
log_file = '/var/log/mylog'
end
=> Store in file 'MyConfig.rb'

test.rb:
require 'MyConfig'

p MyConfig::User
p MyConfig::Pass
p MyConfig::Log_file

BR Phil Meier


BJ Dierkes schrieb:
I prefer using standard *nix style configuration files in the form of 'param = value'. I wrote a class to read this type of configuration file called ParseConfig.

http://rubyforge.org/projects/parseconfig/


It is available via rubygems/rubyforge:

gem install parseconfig


Usage is really simple. Say you have a config file that looks like:

---
user = 'username'
pass = 'password'
log_file = '/var/log/mylog'
---

A quick example to use this config would be:
---
require('rubygems')
require('parseconfig')

config = ParseConfig.new('/path/to/config/file')
user = config.get_value('user')
pass = config.get_value('pass')
log_file = config.get_value('log_file')
---


If you all have any suggestions, etc... you can submit them via the RubyForge Tracker.


On Oct 1, 2007, at 6:21 PM, Lee Jarvis wrote:

I am writing an application that will read and grab values from a
configuration file. I am wondering what peoples opinions are on what to
use. YAML? XML? Does anyone have any preference? Are any better then the
others or is it just down to user preference?

Thanks
--
Posted via http://www.ruby-forum.com/.



.



Relevant Pages

  • Re: Run a web Application with the same "credentials" of a .exe
    ... Add the identity node to the configuration file: ... Optionally do not add the userName and password ... > same "credentials" of a .exe file. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • OMA rejects password and username
    ... just one servere doing the exchange job ... on username user@domain.com (for just username it will ... configuration file required to service this request. ... Source Error: ...
    (microsoft.public.exchange.connectivity)
  • OMA ACCESS
    ... just one servere doing the exchange job ... on username user@domain.com (for just username it will ... configuration file required to service this request. ... Source Error: ...
    (microsoft.public.exchange.admin)
  • Re: Unix directories as lexical scopes?
    ... (It's a version control system, ... can cause it to select a different repository mapping, username, etc.) ...
    (comp.unix.shell)
  • Config files
    ... configuration file. ... I am wondering what peoples opinions are on what to ... YAML? ... others or is it just down to user preference? ...
    (comp.lang.ruby)