Class: FspHarvester::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/fsp_harvester.rb

Class Method Summary collapse

Class Method Details

meta should have already been created by resolve+guid, but maybe not



9
10
11
12
13
14
15
16
17
18
# File 'lib/fsp_harvester.rb', line 9

def self.(links: [], metadata: HarvesterTools::MetadataObject.new) # meta should have already been created by resolve+guid, but maybe not
  @meta = 
  db = []
  links.each do |l|
    db << l if l.relation == 'describedby'
  end
  warn db.length
  HarvesterTools::MetadataHarvester.(links: db, metadata: @meta)  # everything is gathered into the @meta metadata object
  @meta
end

.signpostingcheck(factory:, metadata: HarvesterTools::MetadataObject.new) ⇒ Object



20
21
22
23
24
25
26
27
28
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
57
58
# File 'lib/fsp_harvester.rb', line 20

def self.signpostingcheck(factory:, metadata: HarvesterTools::MetadataObject.new)
  @meta = 
  citeas = Array.new
  describedby = Array.new
  item = Array.new
  types = Array.new

  factory.all_links.each do |l|
    case l.relation
    when 'cite-as'
      citeas << l
    when 'item'
      item << l
    when 'describedby'
      describedby << l
    when 'type'
      types << l
    end
  end

  check_describedby_rules(describedby: describedby, metadata: @meta)
  check_item_rules(item: item, metadata: @meta)

  if citeas.length > 1
    warn "INFO: multiple cite-as links found. Checking for conflicts\n"
    @meta.comments << "INFO: multiple cite-as links found. Checking for conflicts\n"
    citeas = check_for_citeas_conflicts(citeas: citeas, metadata: @meta) # this adds to the metadata objects if there are conflicts, returns the list of unique citeas (SHOULD ONLY BE ONE!)
  end

  unless citeas.length == 1 && describedby.length > 0
    @meta.add_warning(['004', '', ''])
    @meta.comments << "WARN: The resource does not follow the FAIR Signposting standard, which requires exactly one cite-as header, and at least one describedby header\n"
  end

  unless types.length >=1
    @meta.add_warning(['015', '', ''])
    @meta.comments << "WARN: The resource does not follow the FAIR Signposting standard, which requires one or two 'type' link headers\n"
  end
end