Class: DarwinCore::Generator
- Inherits:
-
Object
- Object
- DarwinCore::Generator
- Defined in:
- lib/dwc_archive/generator.rb,
lib/dwc_archive/generator_eml_xml.rb,
lib/dwc_archive/generator_meta_xml.rb
Overview
Creates csv files for core and extensions
Defined Under Namespace
Instance Attribute Summary collapse
-
#eml_xml_data ⇒ Object
readonly
Returns the value of attribute eml_xml_data.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #add_core(data, file_name, keep_headers = true) ⇒ Object
- #add_eml_xml(data) ⇒ Object
- #add_extension(data, file_name, keep_headers = true, row_type = 'http://rs.tdwg.org/dwc/terms/Taxon') ⇒ Object
- #add_meta_xml ⇒ Object
- #clean ⇒ Object
- #files ⇒ Object
-
#initialize(dwc_path, tmp_dir = DEFAULT_TMP_DIR) ⇒ Generator
constructor
A new instance of Generator.
- #pack ⇒ Object
Constructor Details
#initialize(dwc_path, tmp_dir = DEFAULT_TMP_DIR) ⇒ Generator
Returns a new instance of Generator.
8 9 10 11 12 13 14 15 16 |
# File 'lib/dwc_archive/generator.rb', line 8 def initialize(dwc_path, tmp_dir = DEFAULT_TMP_DIR) @dwc_path = dwc_path @path = DarwinCore.random_path(tmp_dir) FileUtils.mkdir(@path) @meta_xml_data = { extensions: [] } @eml_xml_data = { id: nil, title: nil, authors: [], abstrac: nil, citation: nil, url: nil } @write = 'w:utf-8' end |
Instance Attribute Details
#eml_xml_data ⇒ Object (readonly)
Returns the value of attribute eml_xml_data.
6 7 8 |
# File 'lib/dwc_archive/generator.rb', line 6 def eml_xml_data @eml_xml_data end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/dwc_archive/generator.rb', line 6 def path @path end |
Instance Method Details
#add_core(data, file_name, keep_headers = true) ⇒ Object
22 23 24 25 26 |
# File 'lib/dwc_archive/generator.rb', line 22 def add_core(data, file_name, keep_headers = true) opts = { type: 'core', data: data, file_name: file_name, keep_headers: keep_headers } prepare_csv_file(opts) end |
#add_eml_xml(data) ⇒ Object
40 41 42 43 44 |
# File 'lib/dwc_archive/generator.rb', line 40 def add_eml_xml(data) @eml_xml_data = data eml = DarwinCore::Generator::EmlXml.new(@eml_xml_data, @path) eml.create end |
#add_extension(data, file_name, keep_headers = true, row_type = 'http://rs.tdwg.org/dwc/terms/Taxon') ⇒ Object
28 29 30 31 32 33 |
# File 'lib/dwc_archive/generator.rb', line 28 def add_extension(data, file_name, keep_headers = true, row_type = 'http://rs.tdwg.org/dwc/terms/Taxon') opts = { type: 'extension', data: data, file_name: file_name, keep_headers: keep_headers, row_type: row_type } prepare_csv_file(opts) end |
#add_meta_xml ⇒ Object
35 36 37 38 |
# File 'lib/dwc_archive/generator.rb', line 35 def = DarwinCore::Generator::MetaXml.new(@meta_xml_data, @path) .create end |
#clean ⇒ Object
18 19 20 |
# File 'lib/dwc_archive/generator.rb', line 18 def clean DarwinCore.clean(@path) end |
#files ⇒ Object
46 47 48 |
# File 'lib/dwc_archive/generator.rb', line 46 def files DarwinCore.files(@path) end |
#pack ⇒ Object
50 51 52 53 |
# File 'lib/dwc_archive/generator.rb', line 50 def pack a = "cd #{@path}; tar -zcf #{@dwc_path} *" system(a) end |