R
Rebhan, Gilbert
Hi,
i have a script that is configured via yaml file :
---script-----------
require 'yaml'=20
require 'highline/import'
require 'win32/registry'
config=3DYAML.load_file("cvs_login.yaml")
[ ... ]
def filesed!(pattern, replaceString, filename)
regexPattern =3D Regexp.compile(pattern)
tmpFilename =3D "#{filename}.#{Time.now.usec}"
tmpFile =3D File.new(tmpFilename, "w")
srcFile =3D File.open(filename)
srcFile.each_line do |line|
tmpFile.print line.gsub(regexPattern) {|match|
replaceString
}
end
tmpFile.close
srcFile .close
File.rename(tmpFilename, filename)
end
if config['targetdirs']
Win32::Registry::HKEY_CURRENT_USER.open('Software\Cvsnt\cvspass') do
|reg|
@cvsreg =3D
reg["server:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test"]
end
config['targetdirs'].each do |dir|
Dir.chdir(dir)
puts "\n\n"
Dir.glob(config['targetfilepattern']).each do |file|
puts "... processing "<<File.expand_path("#{file}")
puts 'bla'<<@cvsreg
puts 'replaceto =3D=3D '<<config['replaceto']
=20
#filesed!("<Passwort>.*<\/Passwort>","<Passwort><![CDATA[@cvsreg]]><\/Pa
sswort>","#{file}")
filesed!(config['replacefrom'],config['replaceto'],"#{file}")
end
end
puts "\n\nDone !!"
sleep 1
else
puts "\n\nDone !!"
sleep 1
end
---script-----------
--yaml-------------
cvs_login.yaml looks like =3D
targetdirs:
- Y:/tempwork
targetfilepattern: "Scm*.xml"
replacefrom: "<Passwort>.*<\/Passwort>"
replaceto: "<Passwort><![CDATA[#{@cvsreg}]><\/Passwort>"
--yaml--------------
Question =3D
If i write :
puts 'replaceto =3D=3D '<<"<Passwort><![CDATA[#{@cvsreg}]]><\/Passwort>"
direct into the script it's echoed correct, but it doesn't work via yaml
file;
when running via yaml the line in my xml file get's replaced to =3D
<Passwort><![CDATA[#{@cvsreg}]><\/Passwort>
Where's the failure ??
Regards, Gilbert
i have a script that is configured via yaml file :
---script-----------
require 'yaml'=20
require 'highline/import'
require 'win32/registry'
config=3DYAML.load_file("cvs_login.yaml")
[ ... ]
def filesed!(pattern, replaceString, filename)
regexPattern =3D Regexp.compile(pattern)
tmpFilename =3D "#{filename}.#{Time.now.usec}"
tmpFile =3D File.new(tmpFilename, "w")
srcFile =3D File.open(filename)
srcFile.each_line do |line|
tmpFile.print line.gsub(regexPattern) {|match|
replaceString
}
end
tmpFile.close
srcFile .close
File.rename(tmpFilename, filename)
end
if config['targetdirs']
Win32::Registry::HKEY_CURRENT_USER.open('Software\Cvsnt\cvspass') do
|reg|
@cvsreg =3D
reg["server:#{ENV["USERNAME"]}@cvsprod:d:/cvsrepos/test"]
end
config['targetdirs'].each do |dir|
Dir.chdir(dir)
puts "\n\n"
Dir.glob(config['targetfilepattern']).each do |file|
puts "... processing "<<File.expand_path("#{file}")
puts 'bla'<<@cvsreg
puts 'replaceto =3D=3D '<<config['replaceto']
=20
#filesed!("<Passwort>.*<\/Passwort>","<Passwort><![CDATA[@cvsreg]]><\/Pa
sswort>","#{file}")
filesed!(config['replacefrom'],config['replaceto'],"#{file}")
end
end
puts "\n\nDone !!"
sleep 1
else
puts "\n\nDone !!"
sleep 1
end
---script-----------
--yaml-------------
cvs_login.yaml looks like =3D
targetdirs:
- Y:/tempwork
targetfilepattern: "Scm*.xml"
replacefrom: "<Passwort>.*<\/Passwort>"
replaceto: "<Passwort><![CDATA[#{@cvsreg}]><\/Passwort>"
--yaml--------------
Question =3D
If i write :
puts 'replaceto =3D=3D '<<"<Passwort><![CDATA[#{@cvsreg}]]><\/Passwort>"
direct into the script it's echoed correct, but it doesn't work via yaml
file;
when running via yaml the line in my xml file get's replaced to =3D
<Passwort><![CDATA[#{@cvsreg}]><\/Passwort>
Where's the failure ??
Regards, Gilbert