Class: DwcaHunter::ResourceITIS
- Defined in:
- lib/dwca_hunter/resources/itis.rb
Instance Attribute Summary
Attributes inherited from Resource
#abbr, #command, #download_path, #title, #url, #uuid
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ ResourceITIS
constructor
A new instance of ResourceITIS.
- #make_dwca ⇒ Object
- #unpack ⇒ Object
Methods inherited from Resource
#download, gunzip, #needs_download?, #needs_unpack?, unzip
Constructor Details
#initialize(opts = {}) ⇒ ResourceITIS
Returns a new instance of ResourceITIS.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dwca_hunter/resources/itis.rb', line 4 def initialize(opts = {}) @command = 'itis' @title = 'ITIS' @url = 'https://www.itis.gov/downloads/itisMySQLTables.tar.gz' @uuid = '5d066e84-e512-4a2f-875c-0a605d3d9f35' @download_path = File.join(Dir.tmpdir, 'dwca_hunter', 'itis', 'data.tar.gz') @ranks = {} @kingdoms = {} @authors = {} @vernaculars = {} @synonyms = {} @synonym_of = {} @names = {} @extensions = [] super(opts) @itis_dir = File.join(@download_dir, 'itis') end |
Instance Method Details
#make_dwca ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dwca_hunter/resources/itis.rb', line 34 def make_dwca DwcaHunter::logger_write(self.object_id, 'Extracting data') get_ranks get_kingdoms get_vernaculars get_synonyms get_names generate_dwca end |
#unpack ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/dwca_hunter/resources/itis.rb', line 25 def unpack unpack_tar dir = Dir.entries(@download_dir).select {|e| e.match(/itisMySQL/)}[0] FileUtils.mv(File.join(@download_dir, dir), @itis_dir) # Create a file with the same name as the directory we extracted. FileUtils.touch(File.join(@itis_dir, 'version_' + dir)) end |