linked_research_metadata 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c1a8e70e56d0e27192ea504c47611805d45d4b9
4
- data.tar.gz: 496d1fb8a316cc68e05ee2a310bd94a83b9a600e
3
+ metadata.gz: 09fb2c4a097df4a9c607c75f7ec3dcfbb3f74108
4
+ data.tar.gz: 0b4632b0da51c220b5a11f74055966fb1cd282dd
5
5
  SHA512:
6
- metadata.gz: d907f9dd473fe7ea2248c2e28bddd92f66be1fce737da20ae75f5a9a11facc108d9c3ed203ec78b7c11ff0544973398ac6f5ed2c11d705e8f95835b529c8202e
7
- data.tar.gz: b71ef79fbe3cfcf6355991948669119b886b6ab896a60258a86b1d7c3981d7aa6b79e5b2f778e3484d05f5f55626fd313594b9e11077ee1c8b0f978926e465ae
6
+ metadata.gz: e5fca99bc0c6beaf8a33aba4f426c2975245eb9a4a53708052bf1903fb6343eda2142e4399db8be84c876c411ca2f8ffa4c3651971b2cadc2fd9e8d5c24e65af
7
+ data.tar.gz: ec48b1aa65477f340487a9739d2da7fae4c59766f337f4fe3b62774dd3cef4be34e07ab89845a5a6fa9374666b88672f696ba454f2f8e70c356ba0fa14828dce
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.1.1 - 2017-07-03
8
+ ### Fixed
9
+ - Strings become URIs for rdf::type.
10
+
7
11
  ## 0.1.0 - 2017-06-30
8
12
  ### Added
9
13
  - Working product supports datasets.
@@ -18,6 +18,10 @@ module LinkedResearchMetadata
18
18
 
19
19
  private
20
20
 
21
+ def add_triple(subject, predicate, object)
22
+ @graph << [ subject, predicate, object ]
23
+ end
24
+
21
25
  def vocab(v)
22
26
  vocabulary_map =
23
27
  {
@@ -23,7 +23,7 @@ module LinkedResearchMetadata
23
23
  @resource = dataset_extractor.find uuid: uuid
24
24
  raise 'No metadata for ' + uuid if !@resource
25
25
  dataset_uri = mint_uri uuid, :dataset
26
- @resource_uri = RDF::URI.new dataset_uri
26
+ @resource_uri = RDF::URI.new(dataset_uri)
27
27
  build_graph
28
28
  @graph
29
29
  end
@@ -31,14 +31,14 @@ module LinkedResearchMetadata
31
31
  private
32
32
 
33
33
  def meta
34
- @graph << [ @resource_uri, RDF.type, "#{vocab(:vivo)}Dataset" ]
34
+ add_triple @resource_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
35
35
  end
36
36
 
37
37
  def available
38
38
  object = @resource.available
39
39
  if object
40
40
  object_literal = RDF::Literal.new(object.strftime("%F"), datatype: RDF::XSD.date)
41
- @graph << [ @resource_uri, RDF::Vocab::DC.available, object_literal ]
41
+ add_triple @resource_uri, RDF::Vocab::DC.available, object_literal
42
42
  end
43
43
  end
44
44
 
@@ -46,98 +46,99 @@ module LinkedResearchMetadata
46
46
  object = @resource.created
47
47
  if object
48
48
  object_literal = RDF::Literal.new(object.strftime("%F"), datatype: RDF::XSD.date)
49
- @graph << [ @resource_uri, RDF::Vocab::DC.created, object_literal ]
49
+ add_triple @resource_uri, RDF::Vocab::DC.created, object_literal
50
50
  end
51
51
  end
52
52
 
53
53
  def doi
54
54
  if @resource.doi
55
- doi_uri = RDF::URI.new @resource.doi
55
+ doi_uri = RDF::URI.new(@resource.doi)
56
56
  doi_predicate_uri = RDF::Vocab::DC.identifier
57
- @graph << [ @resource_uri, doi_predicate_uri, doi_uri ]
57
+ add_triple @resource_uri, doi_predicate_uri, doi_uri
58
58
  end
59
59
  end
60
60
 
61
61
  def description
62
62
  object = @resource.description
63
63
  if object
64
- @graph << [ @resource_uri, RDF::Vocab::DC.description, object ]
64
+ object.tr!('\\','') # remove any backslashes
65
+ add_triple @resource_uri, RDF::Vocab::DC.description, object
65
66
  end
66
67
  end
67
68
 
68
69
  def files
69
70
  @resource.files.each do |i|
70
- file_uri = RDF::URI.new mint_uri(SecureRandom.uuid, :file)
71
+ file_uri = RDF::URI.new(mint_uri(SecureRandom.uuid, :file))
71
72
 
72
- @graph << [ @resource_uri, RDF::Vocab::DC.hasPart, file_uri ]
73
+ add_triple @resource_uri, RDF::Vocab::DC.hasPart, file_uri
73
74
 
74
75
  # license
75
76
  if i.license && i.license.url
76
- uri = RDF::URI.new i.license.url
77
- @graph << [ file_uri, RDF::Vocab::DC.license, uri ]
77
+ uri = RDF::URI.new(i.license.url)
78
+ add_triple file_uri, RDF::Vocab::DC.license, uri
78
79
  end
79
80
 
80
81
  # mime
81
- @graph << [ file_uri, RDF::Vocab::DC.format, i.mime ]
82
+ add_triple file_uri, RDF::Vocab::DC.format, i.mime
82
83
 
83
84
  # size
84
85
  size_predicate = RDF::Vocab::DC.extent
85
- @graph << [ file_uri, size_predicate, i.size ]
86
+ add_triple file_uri, size_predicate, i.size
86
87
 
87
88
  #name
88
- @graph << [ file_uri, RDF::Vocab::DC.title, i.name ]
89
+ add_triple file_uri, RDF::Vocab::DC.title, i.name
89
90
 
90
91
  #type
91
- @graph << [ file_uri, RDF.type, RDF::Vocab::PREMIS.File ]
92
+ add_triple file_uri, RDF.type, RDF::Vocab::PREMIS.File
92
93
  end
93
94
  end
94
95
 
95
96
  def keywords
96
97
  @resource.keywords.each do |i|
97
- @graph << [ @resource_uri, RDF::Vocab::DC.subject, i ]
98
+ add_triple @resource_uri, RDF::Vocab::DC.subject, i
98
99
  end
99
100
  end
100
101
 
101
102
  def person(person_uri, uuid, name)
102
- @graph << [ person_uri, RDF.type, RDF::Vocab::FOAF.Person ]
103
- @graph << [ person_uri, RDF::Vocab::FOAF.name, name ]
103
+ add_triple person_uri, RDF.type, RDF::Vocab::FOAF.Person
104
+ add_triple person_uri, RDF::Vocab::FOAF.name, name
104
105
  person_extractor = Puree::Extractor::Person.new @config
105
106
  person = person_extractor.find uuid: uuid
106
107
  if person
107
108
  person.affiliations.each do |i|
108
- organisation_uri = RDF::URI.new mint_uri(i.uuid, :organisation)
109
- @graph << [ person_uri, RDF::Vocab::MADS.hasAffiliation, organisation_uri ]
110
- @graph << [ organisation_uri, RDF::Vocab::DC.title, i.name ]
111
- @graph << [ organisation_uri, RDF.type, RDF::Vocab::FOAF.Organization ]
109
+ organisation_uri = RDF::URI.new(mint_uri(i.uuid, :organisation))
110
+ add_triple person_uri, RDF::Vocab::MADS.hasAffiliation, organisation_uri
111
+ add_triple organisation_uri, RDF::Vocab::DC.title, i.name
112
+ add_triple organisation_uri, RDF.type, RDF::Vocab::FOAF.Organization
112
113
  end
113
114
  if person.orcid
114
- orcid_uri = RDF::URI.new "http://orcid.org/#{person.orcid}"
115
- orcid_predicate_uri = RDF::URI.new "#{vocab(:vivo)}OrcidId"
116
- @graph << [ person_uri, orcid_predicate_uri, orcid_uri ]
115
+ orcid_uri = RDF::URI.new("http://orcid.org/#{person.orcid}")
116
+ orcid_predicate_uri = RDF::URI.new("#{vocab(:vivo)}OrcidId")
117
+ add_triple person_uri, orcid_predicate_uri, orcid_uri
117
118
  end
118
119
  end
119
120
  end
120
121
 
121
122
  def projects
122
123
  @resource.projects.each do |i|
123
- project_uri = RDF::URI.new mint_uri(i.uuid, :project)
124
- @graph << [ @resource_uri, RDF::Vocab::DC.relation, project_uri ]
125
- @graph << [ project_uri, RDF::Vocab::DC.title, i.title ]
126
- @graph << [ project_uri, RDF.type, "#{vocab(:vivo)}Project" ]
124
+ project_uri = RDF::URI.new(mint_uri(i.uuid, :project))
125
+ add_triple @resource_uri, RDF::Vocab::DC.relation, project_uri
126
+ add_triple project_uri, RDF::Vocab::DC.title, i.title
127
+ add_triple project_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Project")
127
128
  end
128
129
  end
129
130
 
130
131
  def publications
131
132
  @resource.publications.each do |i|
132
133
  if i.type == 'Dataset'
133
- publication_uri = RDF::URI.new mint_uri(i.uuid, :dataset)
134
- @graph << [ publication_uri, RDF.type, "#{vocab(:vivo)}Dataset" ]
134
+ publication_uri = RDF::URI.new(mint_uri(i.uuid, :dataset))
135
+ add_triple publication_uri, RDF.type, RDF::URI.new("#{vocab(:vivo)}Dataset")
135
136
  else
136
- publication_uri = RDF::URI.new mint_uri(i.uuid, :publication)
137
- @graph << [ publication_uri, RDF.type, "#{vocab(:swpo)}Publication" ]
137
+ publication_uri = RDF::URI.new(mint_uri(i.uuid, :publication))
138
+ add_triple publication_uri, RDF.type, RDF::URI.new("#{vocab(:swpo)}Publication")
138
139
  end
139
- @graph << [ @resource_uri, RDF::Vocab::DC.relation, publication_uri ]
140
- @graph << [ publication_uri, RDF::Vocab::DC.title, i.title ]
140
+ add_triple @resource_uri, RDF::Vocab::DC.relation, publication_uri
141
+ add_triple publication_uri, RDF::Vocab::DC.title, i.title
141
142
  end
142
143
  end
143
144
 
@@ -158,13 +159,13 @@ module LinkedResearchMetadata
158
159
  else
159
160
  uuid = SecureRandom.uuid
160
161
  end
161
- person_uri = RDF::URI.new mint_uri(uuid, :person)
162
+ person_uri = RDF::URI.new(mint_uri(uuid, :person))
162
163
  if i.role == 'Creator'
163
- @graph << [ @resource_uri, RDF::Vocab::DC.creator, person_uri ]
164
+ add_triple @resource_uri, RDF::Vocab::DC.creator, person_uri
164
165
  person person_uri, uuid, name
165
166
  end
166
167
  if i.role == 'Contributor'
167
- @graph << [ @resource_uri, RDF::Vocab::DC.contributor, person_uri ]
168
+ add_triple @resource_uri, RDF::Vocab::DC.contributor, person_uri
168
169
  person person_uri, uuid, name
169
170
  end
170
171
  end
@@ -174,7 +175,7 @@ module LinkedResearchMetadata
174
175
 
175
176
  def spatial
176
177
  @resource.spatial_places.each do |i|
177
- @graph << [ @resource_uri, RDF::Vocab::DC.spatial, i ]
178
+ add_triple @resource_uri, RDF::Vocab::DC.spatial, i
178
179
  end
179
180
  end
180
181
 
@@ -189,7 +190,7 @@ module LinkedResearchMetadata
189
190
  temporal_range << t.end.strftime("%F")
190
191
  end
191
192
  object = temporal_range
192
- @graph << [ @resource_uri, RDF::Vocab::DC.temporal, object ]
193
+ add_triple @resource_uri, RDF::Vocab::DC.temporal, object
193
194
  end
194
195
  end
195
196
  end
@@ -197,7 +198,7 @@ module LinkedResearchMetadata
197
198
  def title
198
199
  object = @resource.title
199
200
  if object
200
- @graph << [ @resource_uri, RDF::Vocab::DC.title, object ]
201
+ add_triple @resource_uri, RDF::Vocab::DC.title, object
201
202
  end
202
203
  end
203
204
 
@@ -1,5 +1,5 @@
1
1
  module LinkedResearchMetadata
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linked_research_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Albin-Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-30 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puree