Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Stuks When a process ( Slave ) Tries to Recieve a Task...
[simgrid.git] / src / bindings / ruby / RubyXML.rb
1 require 'rubygems'
2 require 'nokogiri'
3 require 'open-uri'
4
5
6
7 class RubyXML 
8   
9     attr_accessor :host, :function, :args, :file, :doc
10     
11     def initialize()
12     
13       @host = Array.new()
14       @function = Array.new()
15       @args = Array.new()
16       
17     end
18   
19 #     Parse Application File
20     
21     def parseApplication(fileName) 
22       @file = File.new(fileName);
23       @doc = Nokogiri::XML(@file)
24       index = 0
25       for process in @doc.root.xpath("//process")
26         
27         @host[index] = process['host']
28         @function[index] = process['function']
29         @args[index] = Array.new()
30         arg_index = 0
31         for arg in process.xpath("./argument")
32           
33           @args[index][arg_index] = arg['value']
34           arg_index += 1
35          end
36         index += 1 
37       end
38       
39       
40       
41        @file.close();
42     end
43
44 #     Print All
45     def printAll()
46       
47 #       puts @host.size
48         for i in 0..@host.size-1
49           puts "> Host :" + @host[i]
50           puts ">> Function :" + @function[i]
51           for j in 0..@args[i].size-1
52             puts ">>> Arguments :" + @args[i][j]
53          end
54         end
55     end
56 end
57
58