45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/testdata.rb', line 45
def testdata_values(id)
stringify = Proc.new do |x|
r = x.text.to_s.gsub(/^[\n\s]+/,'').length > 0 ? x.text : x.cdatas.join.strip
r
end
node = XPath.first(@doc.root, "records/test[summary/path='#{id}']")
raise "Path error: node title not found" unless node
path_no = node.text('summary/path').to_s
xpath = "records/io/summary[type='input']/*"
input_nodes = XPath.match(node, xpath)[1..-1]
input_values = input_nodes.map(&stringify) + []
input_names = input_nodes.map(&:name)
xpath = "summary/type/text() | summary/description/text()"
type_or_desc = XPath.match(node, xpath).map(&:to_s).find{|x| x != ''}
xpath = "records/io/summary[type='output']/*"
raw_output = XPath.match(node, xpath)
output_values = raw_output.length > 0 ? raw_output[1..-1].map(&stringify) : []
[path_no, input_values, input_names, type_or_desc, output_values]
end
|