Class: DwcaHunter::ResourceFreebase

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

Instance Attribute Summary

Attributes inherited from Resource

#abbr, #command, #download_path, #title, #url, #uuid

Instance Method Summary collapse

Methods inherited from Resource

gunzip, #needs_download?, unzip

Constructor Details

#initialize(opts = {}) ⇒ ResourceFreebase

Returns a new instance of ResourceFreebase.



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

def initialize(opts = {})
  @command = "freebase"
  @title = 'Freebase'
  @uuid = 'bacd21f0-44e0-43e2-914c-70929916f257'
  @download_path = File.join(Dir.tmpdir,
                             'dwca_hunter',
                             'freebase',
                             'data.json')
  @data = []
  @all_taxa = {}
  @cleaned_taxa = {}
  @extensions = []
  super
end

Instance Method Details

#downloadObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/dwca_hunter/resources/freebase.rb', line 29

def download
  DwcaHunter::logger_write(self.object_id,
                           'Querying freebase for species information...')
  q = {
    query: [{
      type: '/biology/organism_classification',
      id: nil,
      guid: nil,
      name: nil,
      scientific_name: nil,
      synonym_scientific_name: [],
      higher_classification: {
        id: nil,
        guid: nil,
        scientific_name: nil,
        optional: true,
      },
    }],
    cursor: true,
  }

  run_query(q)

  data = JSON.pretty_generate @data
  f = open(@download_path, 'w:utf-8')
  f.write(data)
  f.close
end

#make_dwcaObject



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

def make_dwca
  organize_data
  generate_dwca
end

#needs_unpack?Boolean

Returns:

  • (Boolean)


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

def needs_unpack?
  false
end