Module: SAFT::V2

Defined in:
lib/saft/v2.rb,
lib/saft/v2/html.rb,
lib/saft/v2/parse.rb,
lib/saft/v2/scribe.rb,
lib/saft/v2/xsd_validate.rb

Defined Under Namespace

Modules: HTML, Norway, Parse, Types Classes: Scribe, XsdValidate

Class Method Summary collapse

Class Method Details

.parse(xml_content) ⇒ Object



11
12
13
14
15
# File 'lib/saft/v2.rb', line 11

def self.parse(xml_content)
  doc = Nokogiri::XML(xml_content)
  doc.remove_namespaces!
  Parse.call(doc).then { Types::AuditFile.call(_1) }
end

.scribe(audit_file) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
# File 'lib/saft/v2.rb', line 17

def self.scribe(audit_file)
  rule = Types.Instance(Types::Relaxed::AuditFile) |
    Types.Instance(Types::Strict::AuditFile) |
    Types.Instance(Types::Sliced::AuditFile)

  raise ArgumentError unless rule.valid?(audit_file)

  Scribe.write_xml(audit_file)
end

.to_html(audit_file) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/saft/v2.rb', line 31

def self.to_html(audit_file)
  raise ArgumentError unless audit_file.is_a?(Types::AuditFile)

  HTML.render(audit_file)
end

.validate(xml_content) ⇒ Object



27
28
29
# File 'lib/saft/v2.rb', line 27

def self.validate(xml_content)
  XsdValidate.new(xml_content)
end