fsp_harvester 0.1.10 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec_status +53 -53
- data/Gemfile.lock +38 -30
- data/lib/config.conf +8 -0
- data/lib/constants.rb +8 -5
- data/lib/{fsp_metadata_external_tools.rb → external_tools.rb} +17 -15
- data/lib/fsp_harvester/version.rb +1 -1
- data/lib/fsp_harvester.rb +8 -106
- data/lib/harvester.rb +28 -0
- data/lib/harvester_utils.rb +78 -0
- data/lib/{fsp_metadata_harvester.rb → metadata_harvester.rb} +51 -33
- data/lib/metadata_object.rb +4 -3
- data/lib/{fsp_metadata_parser.rb → metadata_parser.rb} +28 -13
- data/lib/signposting_tests.rb +9 -6
- data/lib/warnings.json +33 -24
- data/lib/web_utils.rb +3 -3
- metadata +10 -8
- data/lib/swagger.rb +0 -224
data/lib/swagger.rb
DELETED
@@ -1,224 +0,0 @@
|
|
1
|
-
class Swagger
|
2
|
-
attr_accessor :debug
|
3
|
-
attr_accessor :title
|
4
|
-
attr_accessor :tests_metric
|
5
|
-
attr_accessor :description
|
6
|
-
attr_accessor :applies_to_principle
|
7
|
-
attr_accessor :organization
|
8
|
-
attr_accessor :org_url
|
9
|
-
attr_accessor :responsible_developer
|
10
|
-
attr_accessor :email
|
11
|
-
attr_accessor :developer_ORCiD
|
12
|
-
attr_accessor :protocol
|
13
|
-
attr_accessor :host
|
14
|
-
attr_accessor :basePath
|
15
|
-
attr_accessor :path
|
16
|
-
attr_accessor :response_description
|
17
|
-
attr_accessor :schemas
|
18
|
-
attr_accessor :comments
|
19
|
-
attr_accessor :fairsharing_key_location
|
20
|
-
attr_accessor :score
|
21
|
-
attr_accessor :testedGUID
|
22
|
-
|
23
|
-
def initialize(params = {})
|
24
|
-
@debug = params.fetch(:debug, false)
|
25
|
-
|
26
|
-
@title = params.fetch(:title, 'unnamed')
|
27
|
-
@tests_metric = params.fetch(:tests_metric)
|
28
|
-
@description = params.fetch(:description, 'default_description')
|
29
|
-
@applies_to_principle = params.fetch(:applies_to_principle, 'some principle')
|
30
|
-
@version = params.fetch(:version, "0.1")
|
31
|
-
@organization = params.fetch(:organization, 'Some Organization')
|
32
|
-
@org_url = params.fetch(:org_url)
|
33
|
-
@responsible_develper = params.fetch(:responsible_developer, 'Some Person')
|
34
|
-
@email = params.fetch(:email)
|
35
|
-
@developer_ORCiD = params.fetch(:developer_ORCiD)
|
36
|
-
@host = params.fetch(:host)
|
37
|
-
@protocol = params.fetch(:protocol, "https")
|
38
|
-
@basePath = params.fetch(:basePath)
|
39
|
-
@path = params.fetch(:path)
|
40
|
-
@response_description = params.fetch(:response_description)
|
41
|
-
@schemas = params.fetch(:schemas, [])
|
42
|
-
@comments = params.fetch(:comments, [])
|
43
|
-
@fairsharing_key_location = params.fetch(:fairsharing_key_location)
|
44
|
-
@score = params.fetch(:score, 0)
|
45
|
-
@testedGUID = params.fetch(:testedGUID, "")
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
def fairsharing_key
|
54
|
-
return @fairsharing_key_location
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
def getSwagger
|
60
|
-
|
61
|
-
message = <<"EOF_EOF"
|
62
|
-
swagger: '2.0'
|
63
|
-
info:
|
64
|
-
version: '#{@version}'
|
65
|
-
title: "#{@title}"
|
66
|
-
x-tests_metric: '#{@tests_metric}'
|
67
|
-
description: >-
|
68
|
-
#{@description}
|
69
|
-
x-applies_to_principle: "#{@applies_to_principle}"
|
70
|
-
contact:
|
71
|
-
x-organization: "#{@organization}"
|
72
|
-
url: "#{@org_url}"
|
73
|
-
name: '#{@responsible_develper}'
|
74
|
-
x-role: "responsible developer"
|
75
|
-
email: #{@email}
|
76
|
-
x-id: '#{developer_ORCiD}'
|
77
|
-
host: #{@host}
|
78
|
-
basePath: #{@basePath}
|
79
|
-
schemes:
|
80
|
-
- #{@protocol}
|
81
|
-
paths:
|
82
|
-
#{@path}:
|
83
|
-
post:
|
84
|
-
parameters:
|
85
|
-
- name: content
|
86
|
-
in: body
|
87
|
-
required: true
|
88
|
-
schema:
|
89
|
-
$ref: '#/definitions/schemas'
|
90
|
-
consumes:
|
91
|
-
- application/json
|
92
|
-
produces:
|
93
|
-
- application/json
|
94
|
-
responses:
|
95
|
-
"200":
|
96
|
-
description: >-
|
97
|
-
#{@response_description}
|
98
|
-
definitions:
|
99
|
-
schemas:
|
100
|
-
required:
|
101
|
-
EOF_EOF
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
self.schemas.keys.each do |key|
|
106
|
-
message += " - #{key}\n"
|
107
|
-
end
|
108
|
-
message += " properties:\n"
|
109
|
-
self.schemas.keys.each do |key|
|
110
|
-
message += " #{key}:\n"
|
111
|
-
message += " type: #{self.schemas[key][0]}\n"
|
112
|
-
message += " description: >-\n"
|
113
|
-
message += " #{self.schemas[key][1]}\n"
|
114
|
-
end
|
115
|
-
|
116
|
-
return message
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
# A utility function that SHOULD NOT BE CALLED EXTERNALLY
|
122
|
-
#
|
123
|
-
# @param s - subject node
|
124
|
-
# @param p - predicate node
|
125
|
-
# @param o - object node
|
126
|
-
# @param repo - an RDF::Graph object
|
127
|
-
def triplify(s, p, o, repo)
|
128
|
-
|
129
|
-
if s.class == String
|
130
|
-
s = s.strip
|
131
|
-
end
|
132
|
-
if p.class == String
|
133
|
-
p = p.strip
|
134
|
-
end
|
135
|
-
if o.class == String
|
136
|
-
o = o.strip
|
137
|
-
end
|
138
|
-
|
139
|
-
unless s.respond_to?('uri')
|
140
|
-
|
141
|
-
if s.to_s =~ /^\w+:\/?\/?[^\s]+/
|
142
|
-
s = RDF::URI.new(s.to_s)
|
143
|
-
else
|
144
|
-
self.debug and $stderr.puts "Subject #{s.to_s} must be a URI-compatible thingy"
|
145
|
-
abort "Subject #{s.to_s} must be a URI-compatible thingy"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
unless p.respond_to?('uri')
|
150
|
-
|
151
|
-
if p.to_s =~ /^\w+:\/?\/?[^\s]+/
|
152
|
-
p = RDF::URI.new(p.to_s)
|
153
|
-
else
|
154
|
-
self.debug and $stderr.puts "Predicate #{p.to_s} must be a URI-compatible thingy"
|
155
|
-
abort "Predicate #{p.to_s} must be a URI-compatible thingy"
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
unless o.respond_to?('uri')
|
160
|
-
if o.to_s =~ /\A\w+:\/?\/?\w[^\s]+/
|
161
|
-
o = RDF::URI.new(o.to_s)
|
162
|
-
elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
|
163
|
-
o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.date)
|
164
|
-
elsif o.to_s =~ /^[+-]?\d+\.\d+/
|
165
|
-
o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.float)
|
166
|
-
elsif o.to_s =~ /^[+-]?[0-9]+$/
|
167
|
-
o = RDF::Literal.new(o.to_s, :datatype => RDF::XSD.int)
|
168
|
-
else
|
169
|
-
o = RDF::Literal.new(o.to_s, :language => :en)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
self.debug and $stderr.puts("\n\ninserting #{s.to_s} #{p.to_s} #{o.to_s}\n\n")
|
174
|
-
triple = RDF::Statement(s, p, o)
|
175
|
-
repo.insert(triple)
|
176
|
-
|
177
|
-
return true
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
# A utility function that SHOULD NOT BE CALLED EXTERNALLY
|
182
|
-
#
|
183
|
-
# @param s - subject node
|
184
|
-
# @param p - predicate node
|
185
|
-
# @param o - object node
|
186
|
-
# @param repo - an RDF::Graph object
|
187
|
-
def Swagger.triplify(s, p, o, repo)
|
188
|
-
return triplify(s,p,o,repo)
|
189
|
-
end
|
190
|
-
|
191
|
-
def addComment(newcomment)
|
192
|
-
self.comments << newcomment.to_s
|
193
|
-
#return self.comments
|
194
|
-
end
|
195
|
-
|
196
|
-
def createEvaluationResponse
|
197
|
-
|
198
|
-
g = RDF::Graph.new
|
199
|
-
|
200
|
-
dt = Time.now.iso8601
|
201
|
-
uri = self.testedGUID
|
202
|
-
|
203
|
-
me = self.protocol + "://" + self.host + "/" + self.basePath + self.path
|
204
|
-
|
205
|
-
meURI ="#{me}##{uri}/result-#{dt}"
|
206
|
-
meURI =Addressable::URI.escape(meURI)
|
207
|
-
|
208
|
-
triplify(meURI, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://fairmetrics.org/resources/metric_evaluation_result", g );
|
209
|
-
triplify(meURI, "http://semanticscience.org/resource/SIO_000300", self.score, g )
|
210
|
-
triplify(meURI, "http://purl.obolibrary.org/obo/date", dt, g )
|
211
|
-
triplify(meURI, "http://schema.org/softwareVersion", VERSION, g )
|
212
|
-
triplify(meURI,"http://semanticscience.org/resource/SIO_000332", uri, g)
|
213
|
-
|
214
|
-
comments = "no comments received. "
|
215
|
-
|
216
|
-
comments = self.comments.join("\n") if self.comments.size > 0
|
217
|
-
triplify(meURI, "http://schema.org/comment", comments, g)
|
218
|
-
|
219
|
-
return g.dump(:jsonld)
|
220
|
-
end
|
221
|
-
|
222
|
-
end
|
223
|
-
|
224
|
-
|