11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/rsf_services.rb', line 11
def read(args=[], type: :get)
@log.info 'RScript/read: args: ' + args.inspect if @log
threads = []
if args.to_s[/\/\/job:/] then
ajob = []
args.each_index do |i|
if args[i].to_s[/\/\/job:/] then
ajob << "@id='#{$'}' and @type='#{type.to_s}'"; args[i] = nil
end
end
args.compact!
out = read_rsf(args) do |doc|
doc.root.xpath('//job').each do |x|
x.attributes[:type] = type.to_s unless x.attributes[:type]
end
if @log then
@log.info 'RScriptRW/read: code: ' + doc.xml.inspect
end
doc.root.xpath("//job[#{ajob.join(' or ')}]").map do |job|
job.xpath('script').map {|s| read_script(s)}.join("\n")
end.join("\n")
end
raise "job not found" unless out.length > 0
out
else
out = read_rsf(args) {|doc| doc.root.xpath('//script').map {|s| read_script(s)}}.join("\n")
end
@log.info 'RScript/read: code: ' + out.inspect if @log
[out, args]
end
|