init.rb in rwddemo-0.90 vs init.rb in rwddemo-0.91

- old
+ new

@@ -21,10 +21,11 @@ #* at "steven@superant.com". #***********************************************************************/ require "ev/rwd" require 'fileutils' +require 'extras/rconftool' $progdir = File::expand_path( File.dirname(__FILE__)) $tempdoc = " " @@ -49,32 +50,52 @@ a.each do |x| #adjust the filters to the files you want to see... if(!test(?d,x)) # only rwd files if x =~ /rb|rwd|txt/ - load x #opens the file thats in fileName and reads it - $tempdoc += $rwdguivar # adds the file into the doc string + + load x #opens the file thats in fileName and reads it + $tempdoc += $rwdguivar # adds the file into the doc string end end end end +# integrate the new configuration files +MAINconfignew = "rwdconfig.cnf" +MAINconfigdist = "rwdconfig.dist" +Rconftool::install(MAINconfigdist,MAINconfignew) + + Dir.chdir("configuration") #changes the current working directory + + fileList = Dir.new(".").entries.sort.reverse.delete_if { |x| ! (x =~ /dist$/) } #creates an Array separated with \n + @doc = "" + fileList.length.times{ #opening of a block + configdist =fileList.pop #pops the first item out of the Array +tempconfigfile = configdist.gsub(/\.dist$/, "") +confignew = tempconfigfile + ".cnf" +Rconftool::install(configdist,confignew) #integrates new file with old + } #closing block + # END of configuration integration +Dir.chdir($progdir) + # Read in the configuration files - Dir.chdir("configuration") #changes the current working directory fileList = Dir.new(".").entries.sort.reverse.delete_if { |x| ! (x =~ /cnf$/) } #creates an Array separated with \n @doc = "" fileList.length.times{ #opening of a block fileName=fileList.pop #pops the first item out of the Array load fileName #loads the the config file thats in fileName } #closing block # END of configuration reading - + Dir.chdir($progdir) # change back to top program directory # build the English Language hash file from the parts + languagehashvariable = 'Message = Hash.new { |hh, kk| hh[kk] = "ERROR: Message not found: #{kk.inspect}."; hh[kk] } + langmessage = {' + "\n" startlangdir = File.join(LangDir,"en") #get a list of the files and subdirectories on the starting directory only alanghash = Array.new(Dir[startlangdir].entries.sort) #loop through the list, ignore the files and add all new directories found alanghash.each do |x| @@ -98,14 +119,15 @@ else #it is a directory... findfiles(x + "/**") end end - fileLangHash=File.open(TempLangHashFile,"w") #deletes and opens a the file in fileName - fileLangHash.write($tempdoc) #writes the contents of doc into the file - fileLangHash.close - # END of Lang building + + #writes the contents of doc into the languagehashvariable + languagehashvariable = languagehashvariable + $tempdoc + "} ; langmessage.each { |kk, vv| Message[kk] = vv }" + + # END of en Lang building $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # build the local Language hash file from the parts startlangdir = File.join(LangDir,$lang) @@ -133,36 +155,21 @@ else #it is a directory... findfiles(x + "/**") end end - filelocalLangHash=File.open(LocalLangHashFile,"w") #deletes and opens a the file in fileName - filelocalLangHash.write($tempdoc) #writes the contents of doc into the file - filelocalLangHash.close + + #writes the contents of doc into the variable + languagehashvariable = languagehashvariable + " ; Message.update(" + $tempdoc + ' :rwdtinker => "Rwdtinker" ) ' + $tempdoc = " " Dir.chdir($progdir) # change back to top program directory + + temp = eval( languagehashvariable ) - # build the language hash constant object from the lang parts - #get a list of the files in lang directory only - alangfile = Dir.new(LangDir).entries.sort.reverse.delete_if { |x| ! (x =~ /rb$/) } - alangfile.length.times{ - fileName = alangfile.pop - Dir.chdir($progdir) - Dir.chdir(LangDir) - fileLangA=File.open("#{fileName}","r") #opens the file thats in fileName as read only - $tempdoc += fileLangA.read #reads the file into the doc string - fileLangA.close - } - -Dir.chdir($progdir) - fileLangB=File.open(LangNameFile,"w") #deletes and opens a the file in fileName - fileLangB.write($tempdoc) #writes the contents of doc into the file - fileLangB.close - load LangNameFile # load the file - $tempdoc = " " # build the actual program from the code parts #get a list of the files and subdirectories on the starting directory only a = Array.new(Dir[CodeDir].entries.sort) @@ -188,15 +195,14 @@ else #it is a directory... findfiles(x + "/**") end end - fileB=File.open(CodeNameFile,"w") #deletes and opens a the file in fileName - fileB.write($tempdoc) #writes the contents of doc into the file - fileB.close - require CodeName # load the program file +# load the program file + tempcoderesult = eval( $tempdoc ) + # build the actual GUI from the gui parts $tempdoc = " " #get a list of the files and subdirectories on the starting directory only a = Array.new(Dir[GuiDir].entries.sort) #loop through the list, ignore the files and add all new directories found @@ -222,13 +228,12 @@ else #it is a directory... loadguifile(x + "/**") end end - fileB=File.open(RWDFile,"w") #deletes and opens a the file in fileName - fileB.write($tempdoc) #writes the contents of doc into the file - fileB.close + # gui variable is done + guiRWD = $tempdoc require 'socket' # Network stuff host = "127.0.0.1" port = $port @@ -264,6 +269,6 @@ end end -RwdTinker.file(RWDFile).serve(port) # start the main class and program +RwdTinker.new( guiRWD).serve(port) # start the main class and program