R
Rebhan, Gilbert
Hi,
i have a program where several things are hard coded
for production i need a config file now, must be editable
and readable by hand, so i decided to try with YAML
program with hard coded stuff =3D
require "highline/import"
CVSEXE=3D"//foobar/c$/tools/cvsnt/cvs.exe"
cvsrepos=3D%w[test test1 foo bar foobar]
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
server:#{cvsuser}:#{cvspass}@cvsprod:d:/cvsrepos/#{x} login")
}
puts "Login successful !!"
i tried with YAML, first step =3D
require 'yaml'=20
require "highline/import"
CVSEXE=3D"//foobar/c$/tools/cvsnt/cvs.exe"
cvsrepos=3DYAML.load_file( "config.yaml" )
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
server:#{cvsuser}:#{cvspass}@cvsprod:d:/cvsrepos/#{x} login")
}
puts "Login successful !!"
config.yaml looks like =3D
---
- test
- test1
- foo
- bar
- foobar
works fine, but now i want to get the CVSEXE path also into that
yamlfile, i tried
require 'yaml'=20
require "highline/import"
YAML.load_file( "config.yaml" )
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
server:#{cvsuser}:#{cvspass}@cvsprod:d:/cvsrepos/#{x} login")
}
puts "Login successful !!"
but that didn't work, my config.yaml looks like =3D
---
CVSEXE:"//foobar/c$/tools/cvsnt/cvs.exe"
---
cvsrepos:
- test
- test1
- foo
- bar
- foobar
What't the correct YAML Syntax and how do i access the different
section from my script that loads the yaml file ?
Regards, Gilbert
i have a program where several things are hard coded
for production i need a config file now, must be editable
and readable by hand, so i decided to try with YAML
program with hard coded stuff =3D
require "highline/import"
CVSEXE=3D"//foobar/c$/tools/cvsnt/cvs.exe"
cvsrepos=3D%w[test test1 foo bar foobar]
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
}
puts "Login successful !!"
i tried with YAML, first step =3D
require 'yaml'=20
require "highline/import"
CVSEXE=3D"//foobar/c$/tools/cvsnt/cvs.exe"
cvsrepos=3DYAML.load_file( "config.yaml" )
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
}
puts "Login successful !!"
config.yaml looks like =3D
---
- test
- test1
- foo
- bar
- foobar
works fine, but now i want to get the CVSEXE path also into that
yamlfile, i tried
require 'yaml'=20
require "highline/import"
YAML.load_file( "config.yaml" )
cvsuser =3D ask("Enter CVS User: ") {|q|=20
q.default =3D "#{ENV["USERNAME"]}"
q.echo =3D true}
cvspass =3D ask("Enter your password: ") { |q| q.echo =3D '*' }
cvsrepos.each {|x|
puts "Login CVS Repository >> #{x} ..."=20
IO.popen("#{CVSEXE} -d
}
puts "Login successful !!"
but that didn't work, my config.yaml looks like =3D
---
CVSEXE:"//foobar/c$/tools/cvsnt/cvs.exe"
---
cvsrepos:
- test
- test1
- foo
- bar
- foobar
What't the correct YAML Syntax and how do i access the different
section from my script that loads the yaml file ?
Regards, Gilbert