Class: Testdata::Base
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
-
#initialize(s, options = {}) ⇒ Base
constructor
A new instance of Base.
- #run(raw_x = nil, debug2 = nil) ⇒ Object
Constructor Details
#initialize(s, options = {}) ⇒ Base
Returns a new instance of Base.
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/testdata.rb', line 24 def initialize(s, ={}) super() @params = {} @success = [] # used by summary @debug = false # open the testdata document procs = { String: proc {|x| if x.strip[/^</] then x elsif x[/https?:\/\//] then read_url x else read_file x end }, Polyrex: proc {|x| x.to_xml} } buffer = procs[s.class.to_s.to_sym].call(s) @doc = Rexle.new(buffer) o = {log: false}.merge() @log = o[:log] == true ? Rexle.new(tests) : nil end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
22 23 24 |
# File 'lib/testdata.rb', line 22 def debug @debug end |
Instance Method Details
#run(raw_x = nil, debug2 = nil) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/testdata.rb', line 57 def run(raw_x=nil, debug2=nil) # verify the document has unique path numbers a = @doc.root.xpath('records/test/summary/path/text()') duplicates = a.select{ |e| a.count(e) > 1 }.uniq if duplicates.any? then raise 'Duplicate path found. Path: ' + duplicates.inspect end @debug2 = debug2 ? true : false @success = [] x = if raw_x and raw_x[/\d+\.\.\d+/] then x, y = raw_x.split('..').map(&:to_i) id = Range.new(x,y) else raw_x end procs = {NilClass: :test_all, Range: :test_range, String: :test_id, Integer: :test_id, Fixnum: :test_id} method(procs[x.class.to_s.to_sym]).call(x) summary() end |