Class: ActiveFacts::Input::ORM

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/input/orm.rb

Overview

Compile a NORMA (.orm) file to an ActiveFacts vocabulary. Invoke as

afgen --<generator> <file>.orm

This parser uses Rexml so it’s very slow.

Instance Method Summary collapse

Instance Method Details

#readObject

:nodoc:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/activefacts/input/orm.rb', line 39

def read          #:nodoc:
  begin
    @document = REXML::Document.new(@file)
  rescue => e
    puts "Failed to parse XML in #{@filename}: #{e.inspect}"
  end

  # Find the Vocabulary and do some setup:
  root = @document.elements[1]
  if root.expanded_name == "ormRoot:ORM2"
    x_models = root.elements.to_a("orm:ORMModel")
    throw "No vocabulary found" unless x_models.size == 1
    @x_model = x_models[0]
  elsif root.name == "ORMModel"
    @x_model = @document.elements[1]
  else
    pp root
    throw "NORMA vocabulary not found in file"
  end

  read_vocabulary
  @vocabulary
end