Class: HarvesterTools::MetadataObject

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: "urn:local:unidentified_metadata") ⇒ MetadataObject

get a name from the “new” call, or set a default



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/metadata_object.rb', line 5

def initialize(id: "urn:local:unidentified_metadata") # get a name from the "new" call, or set a default
  @id = id
  @hash = {}
  @graph = RDF::Graph.new
  @comments =  []
  @warnings =  []
  @full_response = []
  @links = []
  @guidtype = ""
  @all_uris = []
  @tested_guid = ""
  @score = 0
  @version = '0.0'
  @date = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
  @url_header_hash = Hash.new(false) # the combinarion of URL and the accept headers, sha1 hashed, for quick lookup if it has already been processed
  w = RestClient.get("https://raw.githubusercontent.com/markwilkinson/FAIR-Signposting-Harvester/master/lib/warnings.json")
  #@warn = File.read("./lib/warnings.json")
  @warn = JSON.parse(w)
end

Instance Attribute Details

#all_urisObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def all_uris
  @all_uris
end

#commentsObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def comments
  @comments
end

#dateObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def date
  @date
end

#full_responseObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def full_response
  @full_response
end

#graphObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def graph
  @graph
end

#guidtypeObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def guidtype
  @guidtype
end

#hashObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def hash
  @hash
end

#idObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def id
  @id
end

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def links
  @links
end

#scoreObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def score
  @score
end

#tested_guidObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def tested_guid
  @tested_guid
end

#url_header_hashObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def url_header_hash
  @url_header_hash
end

#versionObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def version
  @version
end

#warningsObject

a hash of metadata # a RDF.rb graph of metadata # an array of comments # the type of GUID that was detected # will be an array of Net::HTTP::Response



3
4
5
# File 'lib/metadata_object.rb', line 3

def warnings
  @warnings
end

Instance Method Details

#add_warning(warning) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/metadata_object.rb', line 39

def add_warning(warning)
  id = warning[0]
  return unless @warn[id]   # if there's a mismatch between code and the warnings in github
  url = warning[1]
  headers = warning[2]
  message = @warn[id]['message']
  linkout = @warn[id]['linkout']
  severity = @warn[id]['severity']
  self.warnings << {"id" => id, "message" => message, "severity" => severity, "linkout" => linkout, "processed_url" => url, "accept_headers": headers}
end

#merge_hash(hash) ⇒ Object



25
26
27
28
# File 'lib/metadata_object.rb', line 25

def merge_hash(hash)
  # warn "\n\n\nIncoming Hash #{hash.inspect}"
  self.hash = self.hash.merge(hash)
end

#merge_rdf(triples) ⇒ Object

incoming list of triples



30
31
32
33
# File 'lib/metadata_object.rb', line 30

def merge_rdf(triples) # incoming list of triples
  graph << triples
  graph
end

#rdfObject



35
36
37
# File 'lib/metadata_object.rb', line 35

def rdf
  graph
end