Class: Chew

Inherits:
Object
  • Object
show all
Defined in:
lib/xamplr-pp/toys/chew.rb,
lib/xamplr-pp/toys/chewMultibyte.rb

Overview

require “xampl-pp”

Instance Method Summary collapse

Instance Method Details

#resolve(name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/xamplr-pp/toys/chew.rb', line 7

def resolve(name)
  @resolveRequest = true
#   if not @xpp.standalone then
#     # for the purposes of conformance, accept this since we don't
#     # know if the external subset defines something
#     return "fake it"
#   else
#     return nil
#   end
end

#runObject



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
56
57
58
# File 'lib/xamplr-pp/toys/chew.rb', line 18

def run
  @allFiles = File.new ARGV[1]

  while true do
    fileName = @allFiles.gets
    if nil == fileName then
      break
    end
    fileName.chop!

    @xpp = Xampl_PP.new
    @xpp.input = File.new(fileName)
@xpp.resolver = self
@resolveRequest = false
@xpp.processNamespace = false
@xpp.reportNamespaceAttributes = false
  
    begin
      i = 0
      while not @xpp.endDocument? do
        type = @xpp.nextEvent
        i += 1
      end
      printf("%sPASSED '%s' -- there were %d events\n", (("PASS" == ARGV[0])? " " : "#"), fileName, i)
    rescue RuntimeError => message
      #print message.backtrace.join("\n")
      if @resolveRequest then
        printf("ENTITY [%s] '%s'\n", (("FAIL" == ARGV[0])? " " : "#"), message, fileName)
      else
        printf("%sFAILED [%s] '%s'\n", (("FAIL" == ARGV[0])? " " : "#"), message, fileName)
      end
    rescue Exception => message
      #print message.backtrace.join("\n")
      if @resolveRequest then
        printf("ENTITY [%s] '%s'\n", (("FAIL" == ARGV[0])? " " : "#"), message, fileName)
      else
        printf("%sFAILED [%s] '%s'\n", (("FAIL" == ARGV[0])? " " : "#"), message, fileName)
      end
    end
  end
end