Class: DarwinCore::Generator::MetaXml

Inherits:
Object
  • Object
show all
Defined in:
lib/dwc-archive/generator_meta_xml.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, path) ⇒ MetaXml

Returns a new instance of MetaXml.



4
5
6
7
8
# File 'lib/dwc-archive/generator_meta_xml.rb', line 4

def initialize(data, path)
  @data = data
  @path = path
  @write = 'w:utf-8'
end

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dwc-archive/generator_meta_xml.rb', line 10

def create
  schema_uri =  'http://rs.tdwg.org/dwc/terms/xsd/archive/' + 
    ' http://darwincore.googlecode.com/svn/trunk/text/tdwg_dwc_text.xsd'
  builder = Nokogiri::XML::Builder.new do |xml|
    opts = { encoding: 'UTF-8', 
             fieldsTerminatedBy: ',', 
             fieldsEnclosedBy: '"', 
             linesTerminatedBy: "\n", 
             rowType: 'http://rs.tdwg.org/dwc/terms/Taxon' }
    build_archive(xml, opts, schema_uri)
  end
  meta_xml_data = builder.to_xml
  meta_file = open(File.join(@path, 'meta.xml'), @write)
  meta_file.write(meta_xml_data)
  meta_file.close
end