init.rb in rwdshell-0.98 vs init.rb in rwdshell-0.99
- old
+ new
@@ -22,256 +22,256 @@
#***********************************************************************/
require "ev/rwd"
require 'fileutils'
require 'extras/rconftool'
-
+
$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
-
+$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
+
# integrate the new configuration files
MAINconfignew = "rwdconfig.cnf"
MAINconfigdist = "rwdconfig.dist"
Rconftool::install(MAINconfigdist,MAINconfignew)
#load main config file
load 'rwdconfig.cnf'
- 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
+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)
+ # 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
+ # 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
+ # END of configuration reading
- # 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|
- #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
+ Dir.chdir($progdir) # change back to top program directory
-
- #writes the contents of doc into the languagehashvariable
+ # 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|
+ #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
+
+
+ #writes the contents of doc into the languagehashvariable
languagehashvariable = languagehashvariable + $tempdoc + "} ; langmessage.each { |kk, vv| Message[kk] = vv }"
-
- # END of en Lang building
+
+ # 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)
- #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
-
- #writes the contents of doc into the variable
+ # build the local Language hash file from the parts
+ startlangdir = File.join(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
+
+
+ #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 )
- $tempdoc = " "
+ $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
+ Dir.chdir($progdir) # change back to top program directory
+ temp = eval( languagehashvariable )
-# load the program file
- tempcoderesult = eval( $tempdoc )
+ $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
- 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
+ # 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
- # gui variable is done
- guiRWD = $tempdoc
-
- require 'socket' # Network stuff
- host = "127.0.0.1"
- port = $port
-
- # Create a socket to listen on and bind it to the host and port
- freeportfound = false
- until freeportfound
- begin
- @socket = UDPSocket::new()
- @socket.bind(host, port)
- freeportfound = true
-$port = port
- # Rescue the "Address in use" error
- rescue Errno::EADDRINUSE
- puts "RWD Startup: Port #{port} on host #{host} is already in use."
- port=port +1
- puts "trying port: #{port}"
- # Rescue the "Address not available' error
- rescue Errno::EADDRNOTAVAIL
- puts "RWD Startup: Address #{host} is not available to bind."
- port =port + 1
- puts "trying port: #{port}"
- # Rescue "permission denied errors
- rescue Errno::EACCES
- puts "RWD Startup: Access denied when binding interface addresses. ?"
- port =port + 1
- puts "trying port: #{port}"
- # Rescue all other errors
- rescue
- puts "RWD Startup: An error occured."
- port =port + 1
- puts "trying port: #{port}"
- # Rescue all other errors
- end
-end
+ # 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
+ 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)
-RwdTinker.new( guiRWD).serve(port) # start the main class and program
+ else #it is a directory...
+ loadguifile(x + "/**")
+ end
+ end
+
+ # gui variable is done
+ guiRWD = $tempdoc
+
+ require 'socket' # Network stuff
+ host = "127.0.0.1"
+ port = $port
+
+ # Create a socket to listen on and bind it to the host and port
+ freeportfound = false
+ until freeportfound
+ begin
+ @socket = UDPSocket::new()
+ @socket.bind(host, port)
+ freeportfound = true
+ $port = port
+ # Rescue the "Address in use" error
+ rescue Errno::EADDRINUSE
+ puts "RWD Startup: Port #{port} on host #{host} is already in use."
+ port=port +1
+ puts "trying port: #{port}"
+ # Rescue the "Address not available' error
+ rescue Errno::EADDRNOTAVAIL
+ puts "RWD Startup: Address #{host} is not available to bind."
+ port =port + 1
+ puts "trying port: #{port}"
+ # Rescue "permission denied errors
+ rescue Errno::EACCES
+ puts "RWD Startup: Access denied when binding interface addresses. ?"
+ port =port + 1
+ puts "trying port: #{port}"
+ # Rescue all other errors
+ rescue
+ puts "RWD Startup: An error occured."
+ port =port + 1
+ puts "trying port: #{port}"
+ # Rescue all other errors
+ end
+
+ end
+
+
+ RwdTinker.new( guiRWD).serve(port) # start the main class and program