#*********************************************************************** #* Rwd/Tinker -- A Ruby program for the RudyWebDialog. #* Copyright (c) 2004, 2005 by Steven Gibson. All Rights Reserved. #* #* This library is free software; you can redistribute it and/or #* modify it under the terms of the GNU General Public #* License as published by the Free Software Foundation; either #* . #* #* These files are distributed in the hope that they will be useful, #* but WITHOUT ANY WARRANTY; without even the implied warranty of #* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #* General Public License for more details. #* #* You should have received a copy of the GNU General Public #* License along with these files; if not, write to the Free Software #* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #* #* For further information please contact the author by e-mail #* at "steven@superant.com". #***********************************************************************/ require "ev/rwd" require 'fileutils' $progdir = File::expand_path( File.dirname(__FILE__)) $tempdoc = " " def findfiles(d) a = Array.new(Dir[d].entries.sort) #loop through and get the files names 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/ fileA=File.open("#{x}","r") #opens the file thats in fileName as read only $tempdoc+=fileA.read #reads the file into the doc string fileA.close end end end end def loadguifile(d) a = Array.new(Dir[d].entries.sort) #loop through and get the files names 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 end end end end # 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 startlangdir = @@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| #if a directory... if(test(?d,x)) # add to the original list of directories @@tmproot = x + "/**" #adds the new ones to the array blanghash = Dir[@@tmproot].entries.sort blanghash.each do |x| if(test(?d,x)) alanghash.push(x) #appends to the end of the array... end end end end alanghash.each do |x| #if it is a file... if(!test(?d,x)) alanghash.delete(x) 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 $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # build the local Language hash file from the parts startlangdir = @@langdir +"/" + $lang #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| #if a directory... if(test(?d,x)) # add to the original list of directories @@tmproot = x + "/**" #adds the new ones to the array blanghash = Dir[@@tmproot].entries.sort blanghash.each do |x| if(test(?d,x)) alanghash.push(x) #appends to the end of the array... end end end end alanghash.each do |x| #if it is a file... if(!test(?d,x)) alanghash.delete(x) 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 $tempdoc = " " Dir.chdir($progdir) # change back to top program directory # 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) #loop through the list, ignore the files and add all new directories found a.each do |x| #if a directory... if(test(?d,x)) # add to the original list of directories @@root = x + "/**" #adds the new ones to the array b = Dir[@@root].entries.sort b.each do |x| if(test(?d,x)) a.push(x) #appends to the end of the array... end end end end a.each do |x| #if it is a file... if(!test(?d,x)) a.delete(x) 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 # 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 a.each do |x| #if a directory... if(test(?d,x)) #use this new dir find to add to the original list of directories @@root = x + "/**" #adds the new ones to the array b = Dir[@@root].entries.sort b.each do |x| if(test(?d,x)) a.push(x) #appends to the end of the array... end end end end a.each do |x| #if it is a file... if(!test(?d,x)) a.delete(x) 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 RwdTinker.file(RWDFile).serve($port) # start the main class and program