Class: Archimate::FileFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/archimate/file_format.rb

Overview

This File Format class supports reading and parsing from a number of ArchiMate formats

Class Method Summary collapse

Class Method Details

.parse(str) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/archimate/file_format.rb', line 19

def self.parse(str)
  doc = Nokogiri::XML(str)
  case doc.namespaces["xmlns"]
  when "http://www.opengroup.org/xsd/archimate/3.0/",
       "http://www.opengroup.org/xsd/archimate"
    FileFormats::ModelExchangeFileReader.new(str).parse
  else
    FileFormats::ArchiFileReader.new(str).parse
  end
end

.read(filename) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/archimate/file_format.rb', line 8

def self.read(filename)
  case File.extname(filename)
  when ".marshal"
    File.open(filename, "rb") do |marshal_file|
      Marshal.load(marshal_file)
    end
  else
    parse(File.read(filename))
  end
end