Class: ActiveFacts::Input::ORM
- Inherits:
-
Object
- Object
- ActiveFacts::Input::ORM
- 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.
Defined Under Namespace
Modules: Gravity
Constant Summary collapse
- DataTypeMapping =
{ "FixedLengthText" => "Char", "VariableLengthText" => "String", "LargeLengthText" => "Text", "SignedIntegerNumeric" => "Signed Integer(32)", "SignedSmallIntegerNumeric" => "Signed Integer(16)", "SignedLargeIntegerNumeric" => "Signed Integer(64)", "UnsignedIntegerNumeric" => "Unsigned Integer(32)", "UnsignedTinyIntegerNumeric" => "Unsigned Integer(8)", "UnsignedSmallIntegerNumeric" => "Unsigned Integer(16)", "UnsignedLargeIntegerNumeric" => "Unsigned Integer(64)", "AutoCounterNumeric" => "Auto Counter", "FloatingPointNumeric" => "Real(64)", "SinglePrecisionFloatingPointNumeric" => "Real(32)", "DoublePrecisionFloatingPointNumeric" => "Real(32)", "DecimalNumeric" => "Decimal", "MoneyNumeric" => "Money", "FixedLengthRawData" => "Blob", "VariableLengthRawData" => "Blob", "LargeLengthRawData" => "Blob", "PictureRawData" => "Image", "OleObjectRawData" => "Blob", "AutoTimestampTemporal" => "Auto Time Stamp", "TimeTemporal" => "Time", "DateTemporal" => "Date", "DateAndTimeTemporal" => "Date Time", "TrueOrFalseLogical" => "Boolean", "YesOrNoLogical" => "Boolean", "RowIdOther" => "Guid", "ObjectIdOther" => "Guid" }
- RESERVED_WORDS =
%w{ and but each each either false if maybe no none not one or some that true where }
Instance Method Summary collapse
-
#read ⇒ Object
:nodoc:.
Instance Method Details
#read ⇒ Object
:nodoc:
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/activefacts/input/orm.rb', line 95 def read #:nodoc: begin @document = Nokogiri::XML(@file) rescue => e puts "Failed to parse XML in #{@filename}: #{e.inspect}" end # Find the Vocabulary and do some setup: root = @document.root #p((root.methods-0.methods).sort.grep(/name/)) if root.name == "ORM2" && root.namespace.prefix == "ormRoot" x_models = root.xpath('orm:ORMModel') throw "No vocabulary found" unless x_models.size == 1 @x_model = x_models[0] elsif root.name == "ORMModel" p @document.children.map(&:name) @x_model = @document.children[0] else throw "NORMA model not found in #{@filename}" end read_vocabulary @vocabulary end |