Class: DwcaHunter::ResourceIPNI

Inherits:
Resource
  • Object
show all
Defined in:
lib/dwca_hunter/resources/ipni.rb

Overview

Resource for FishBase

Instance Attribute Summary collapse

Attributes inherited from Resource

#command, #download_path, #url, #uuid

Instance Method Summary collapse

Methods inherited from Resource

gunzip, #needs_download?, #needs_unpack?, unzip

Constructor Details

#initialize(opts = {}) ⇒ ResourceIPNI

download: false, unpack: false})



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dwca_hunter/resources/ipni.rb', line 7

def initialize(opts = {}) #download: false, unpack: false})
  @command = "ipni"
  @title = "The International Plant Names Index"
  @abbr = "IPNI"
  @url = "https://www.dropbox.com/s/1n0sn80vkdir5nu/ipniWebName.csv.xz"
  @uuid = "6b3905ce-5025-49f3-9697-ddd5bdfb4ff0"
  @download_path = File.join(Dir.tmpdir, "dwca_hunter", "ipni",
                             "ipni.csv.xz")
  @extensions = []
  super
end

Instance Attribute Details

#abbrObject (readonly)

Returns the value of attribute abbr.



6
7
8
# File 'lib/dwca_hunter/resources/ipni.rb', line 6

def abbr
  @abbr
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'lib/dwca_hunter/resources/ipni.rb', line 6

def title
  @title
end

Instance Method Details

#downloadObject



24
25
26
27
28
# File 'lib/dwca_hunter/resources/ipni.rb', line 24

def download
  puts "Downloading cached verion of the file. Get daily updated one from"
  puts "https://storage.cloud.google.com/ipni-data/ipniWebName.csv.xz"
    `curl -s -L #{@url} -o #{@download_path}`
end

#make_dwcaObject



30
31
32
33
# File 'lib/dwca_hunter/resources/ipni.rb', line 30

def make_dwca
  organize_data
  generate_dwca
end

#unpackObject



19
20
21
22
# File 'lib/dwca_hunter/resources/ipni.rb', line 19

def unpack
  puts "Unpacking #{@download_path}"
  XZ.decompress_file(@download_path, @download_path[0...-3] )
end