Class HTML5::TestSupport::TestData
In: lib/feed_tools/vendor/html5/tests/preamble.rb
Parent: Object

Methods

each   new   normaliseOutput  

Included Modules

Enumerable

Public Class methods

[Source]

    # File lib/feed_tools/vendor/html5/tests/preamble.rb, line 40
40:       def initialize(filename, sections)
41:         @f = open(filename)
42:         @sections = sections
43:       end

Public Instance methods

[Source]

    # File lib/feed_tools/vendor/html5/tests/preamble.rb, line 45
45:       def each
46:         data = {}
47:         key = nil
48:         @f.each_line do |line|
49:           if line[0] == ?# and @sections.include?(line[1..-2])
50:             heading = line[1..-2]
51:             if data.any? and heading == @sections[0]
52:               data[key].chomp!  #Remove trailing newline
53:               yield normaliseOutput(data)
54:               data = {}
55:             end
56:             key = heading
57:             data[key]=""
58:           elsif key
59:             data[key] += line
60:           end
61:         end
62:         yield normaliseOutput(data) if data
63:       end

[Source]

    # File lib/feed_tools/vendor/html5/tests/preamble.rb, line 65
65:       def normaliseOutput(data)
66:         #Remove trailing newlines
67:         data.keys.each { |key| data[key].chomp! }
68:         @sections.map {|heading| data[heading]}
69:       end

[Validate]