importing config files

D

Derril Lucci

Hi everyone,
I am writing a program for my research that uses configuration files.
I was curious how to import these files into my ruby program. Any help
would be appreciated. If it helps, I am running ruby 1.9.

Cheers,
dlucci
 
G

gf

What kind of configuration files? What format are they in? YAML, XML?

Hi everyone,
=A0 I am writing a program for my research that uses configuration files.
I was curious how to import these files into my ruby program. =A0Any help
would be appreciated. =A0If it helps, I am running ruby 1.9.

Cheers,
=A0 dlucci
scribe?hl=3Den
 
D

Derril Lucci

Well, I am not too educated in configuration files. I was going to just
write it in ruby (thats the language I am working in). The
configuration file is being used to specify intervals in time. My
project is generating a report for SysAdmins and this will allow them to
specify the interval at which they want the reports to be compared.
Getting back to the main problem, I had thought it was either "require"
or "include", but both of those proved fruitless. Hope this info helps.

Cheers,
dlucci
 
M

Mario Antonetti

[Note: parts of this message were removed to make it a legal post.]

If you could include a sample of the files' contents, it would be helpful.
require is used to access ruby libraries. What you are looking for is the
File class.
For example

File.open('config.txt').each do |line|
puts line
end

will spit out each line of a file.
 
R

Robert Klemme

Well, I am not too educated in configuration files. I was going to just
write it in ruby (thats the language I am working in). The
configuration file is being used to specify intervals in time. My
project is generating a report for SysAdmins and this will allow them to
specify the interval at which they want the reports to be compared.
Getting back to the main problem, I had thought it was either "require"
or "include", but both of those proved fruitless. Hope this info helps.

The simples approach is to use "load":

load File.join(ENV['HOME'], '.myconfrc')

file ~/.myconfrc:

$interval = 15

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top