research_metadata 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +28 -16
- data/lib/research_metadata/transformer/dataset.rb +115 -82
- data/lib/research_metadata/transformer/publication.rb +216 -0
- data/lib/research_metadata/transformer/transformer.rb +10 -0
- data/lib/research_metadata/version.rb +1 -1
- data/lib/research_metadata.rb +9 -1
- data/research_metadata.gemspec +8 -5
- data/spec/transformer/dataset_spec.rb +14 -16
- metadata +28 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e692013c5a56d618d186d506beaa3e0583bd810
|
4
|
+
data.tar.gz: 2be1115ce7b66209dcb00d1fd668293c4a8f7fa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31990db2506a78d36f992c522df5df8740d3cda29e54e550ae6e6cb0702167c5d97d623f4fc49bc7e2850bf8778ca209a078d39c6f27d0f70a1d6ccc1233f9d
|
7
|
+
data.tar.gz: f48ca4b7eb11ed554a6e14f4b7e7365c7205ff5e4016bc157d7c4f140896532a753637a6a9b3813a1157b0cef6c8650aae26d88b483c037dbc44d213718741aa
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## 1.0.0 2017-03-15
|
8
|
+
### Added
|
9
|
+
- Publications e.g. Doctoral/Master's Thesis.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Configuration style to match Puree v1.0.0.
|
13
|
+
|
7
14
|
## 0.1.0 - 2017-02-03
|
8
15
|
### Added
|
9
16
|
- Working product supports datasets.
|
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
# ResearchMetadata
|
1
|
+
# ResearchMetadata
|
2
2
|
|
3
|
-
|
3
|
+
Metadata extraction from the Pure Research Information System and transformation of the metadata into the DataCite format.
|
4
|
+
|
5
|
+
## Status
|
6
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/research_metadata.svg)](https://badge.fury.io/rb/research_metadata)
|
8
|
+
[![Build Status](https://semaphoreci.com/api/v1/aalbinclark/research_metadata/branches/master/badge.svg)](https://semaphoreci.com/aalbinclark/research_metadata)
|
9
|
+
[![Code Climate](https://codeclimate.com/github/lulibrary/research_metadata/badges/gpa.svg)](https://codeclimate.com/github/lulibrary/research_metadata)
|
10
|
+
[![Dependency Status](https://www.versioneye.com/user/projects/5899d1be1e07ae0048c8e4c6/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/5899d1be1e07ae0048c8e4c6)
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
@@ -19,33 +26,38 @@ Or install it yourself as:
|
|
19
26
|
## Usage
|
20
27
|
|
21
28
|
### Configuration
|
22
|
-
|
29
|
+
|
30
|
+
Create a hash for passing to a transformer.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Pure host with authentication.
|
34
|
+
config = {
|
35
|
+
url: ENV['PURE_URL'],
|
36
|
+
username: ENV['PURE_USERNAME'],
|
37
|
+
password: ENV['PURE_PASSWORD']
|
38
|
+
}
|
39
|
+
```
|
23
40
|
|
24
41
|
```ruby
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
42
|
+
# Pure host without authentication.
|
43
|
+
config = {
|
44
|
+
url: ENV['PURE_URL']
|
45
|
+
}
|
29
46
|
```
|
30
47
|
|
31
48
|
### Transformation
|
32
49
|
|
33
|
-
Create a metadata transformer for a Pure dataset
|
50
|
+
Create a metadata transformer for a Pure dataset.
|
34
51
|
|
35
52
|
```ruby
|
36
|
-
transformer = ResearchMetadata::Transformer::Dataset.new
|
53
|
+
transformer = ResearchMetadata::Transformer::Dataset.new config
|
37
54
|
```
|
38
55
|
|
39
|
-
|
56
|
+
Give it a Pure identifier and a DOI...
|
40
57
|
|
41
58
|
```ruby
|
42
59
|
metadata = transformer.transform uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
|
43
60
|
doi: '10.1234/foo/bar/1'
|
44
61
|
```
|
45
62
|
|
46
|
-
...
|
47
|
-
|
48
|
-
## Documentation
|
49
|
-
[API in YARD](http://www.rubydoc.info/gems/research_metadata)
|
50
|
-
|
51
|
-
[Detailed usage in GitBook](https://aalbinclark.gitbooks.io/research_metadata)
|
63
|
+
...and get DataCite-ready metadata.
|
@@ -1,24 +1,30 @@
|
|
1
|
-
# Extraction (from Pure) and Transformation for Loading by DataCite's API
|
2
|
-
#
|
3
1
|
module ResearchMetadata
|
4
2
|
|
5
|
-
# Transformer
|
6
|
-
#
|
7
3
|
module Transformer
|
8
4
|
|
9
|
-
#
|
5
|
+
# Extracts dataset metadata from the Pure Research Information System and
|
6
|
+
# converts it into the DataCite format.
|
10
7
|
#
|
11
8
|
class Dataset
|
12
9
|
|
10
|
+
# @param config [Hash]
|
11
|
+
# @option config [String] :url The URL of the Pure host.
|
12
|
+
# @option config [String] :username The username of the Pure host account.
|
13
|
+
# @option config [String] :password The password of the Pure host account.
|
14
|
+
def initialize(config)
|
15
|
+
@config = config
|
16
|
+
@dataset_extractor = Puree::Extractor::Dataset.new config
|
17
|
+
end
|
18
|
+
|
13
19
|
# Dataset transformation
|
14
20
|
#
|
15
21
|
# @param id [String]
|
16
22
|
# @param uuid [String]
|
17
23
|
# @param doi [String]
|
18
|
-
# @return [String]
|
24
|
+
# @return [String, nil]
|
19
25
|
def transform(id: nil, uuid: nil, doi: nil)
|
20
26
|
@dataset = extract uuid: uuid, id: id
|
21
|
-
|
27
|
+
return nil if !@dataset
|
22
28
|
person_o = person
|
23
29
|
file_o = file
|
24
30
|
resource = ::Datacite::Mapping::Resource.new(
|
@@ -33,9 +39,9 @@ module ResearchMetadata
|
|
33
39
|
language: language,
|
34
40
|
resource_type: resource_type,
|
35
41
|
related_identifiers: related_identifiers,
|
36
|
-
sizes: file_o
|
37
|
-
formats: file_o
|
38
|
-
rights_list: file_o
|
42
|
+
sizes: sizes(file_o),
|
43
|
+
formats: formats(file_o),
|
44
|
+
rights_list: rights_list(file_o),
|
39
45
|
descriptions: description,
|
40
46
|
geo_locations: spatial
|
41
47
|
)
|
@@ -44,37 +50,63 @@ module ResearchMetadata
|
|
44
50
|
|
45
51
|
private
|
46
52
|
|
53
|
+
def sizes(files)
|
54
|
+
files.map { |i| "#{i.size} B" }
|
55
|
+
end
|
56
|
+
|
57
|
+
def formats(files)
|
58
|
+
files.map { |i| i.mime }
|
59
|
+
end
|
60
|
+
|
61
|
+
def rights_list(files)
|
62
|
+
arr = []
|
63
|
+
files.each do |i|
|
64
|
+
if i.license
|
65
|
+
rights = Datacite::Mapping::Rights.new value: i.license.name
|
66
|
+
arr << rights
|
67
|
+
else
|
68
|
+
arr << 'Not specified'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
arr
|
72
|
+
end
|
73
|
+
|
47
74
|
def affiliations(person)
|
48
|
-
person.
|
75
|
+
person.affiliations.map { |i| i.name }
|
49
76
|
end
|
50
77
|
|
51
78
|
def dates
|
52
79
|
a = []
|
53
|
-
|
54
|
-
|
55
|
-
|
80
|
+
|
81
|
+
available = @dataset.available
|
82
|
+
if available
|
83
|
+
date_made_available = ::Datacite::Mapping::Date.new value: available.strftime("%F"),
|
84
|
+
type: ::Datacite::Mapping::DateType::AVAILABLE
|
85
|
+
a << date_made_available
|
86
|
+
end
|
56
87
|
|
57
88
|
temporal = @dataset.temporal
|
58
89
|
temporal_range = ''
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
90
|
+
if temporal
|
91
|
+
if temporal.start
|
92
|
+
temporal_range << temporal.start.strftime("%F")
|
93
|
+
if temporal.end
|
94
|
+
temporal_range << '/'
|
95
|
+
temporal_range << temporal.end.strftime("%F")
|
96
|
+
end
|
97
|
+
if !temporal_range.empty?
|
98
|
+
collected = ::Datacite::Mapping::Date.new value: temporal_range,
|
99
|
+
type: ::Datacite::Mapping::DateType::COLLECTED
|
100
|
+
a << collected
|
101
|
+
end
|
69
102
|
end
|
70
103
|
end
|
71
|
-
|
72
104
|
a
|
73
105
|
end
|
74
106
|
|
75
107
|
def description
|
76
108
|
desc = @dataset.description
|
77
|
-
if
|
109
|
+
if desc
|
78
110
|
d = ::Datacite::Mapping::Description.new value: desc,
|
79
111
|
type: ::Datacite::Mapping::DescriptionType::ABSTRACT
|
80
112
|
[d]
|
@@ -84,17 +116,15 @@ module ResearchMetadata
|
|
84
116
|
end
|
85
117
|
|
86
118
|
def extract(uuid: nil, id: nil)
|
87
|
-
d = Puree::Dataset.new
|
88
119
|
if !uuid.nil?
|
89
|
-
|
120
|
+
return @dataset_extractor.find uuid: uuid
|
90
121
|
else
|
91
|
-
|
122
|
+
return @dataset_extractor.find id: id
|
92
123
|
end
|
93
|
-
d
|
94
124
|
end
|
95
125
|
|
96
126
|
def file
|
97
|
-
@dataset.
|
127
|
+
@dataset.files
|
98
128
|
end
|
99
129
|
|
100
130
|
def identifier(doi)
|
@@ -107,10 +137,10 @@ module ResearchMetadata
|
|
107
137
|
|
108
138
|
def name_identifier_orcid(person)
|
109
139
|
name_identifier = nil
|
110
|
-
if
|
111
|
-
name_identifier = ::Datacite::Mapping::NameIdentifier.new
|
112
|
-
|
113
|
-
|
140
|
+
if person.orcid
|
141
|
+
name_identifier = ::Datacite::Mapping::NameIdentifier.new scheme: 'ORCID',
|
142
|
+
scheme_uri: URI('http://orcid.org/'),
|
143
|
+
value: person.orcid
|
114
144
|
end
|
115
145
|
name_identifier
|
116
146
|
end
|
@@ -119,46 +149,49 @@ module ResearchMetadata
|
|
119
149
|
o = {}
|
120
150
|
o['creator'] = []
|
121
151
|
o['contributor'] = []
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
152
|
+
all_persons = []
|
153
|
+
all_persons << @dataset.persons_internal
|
154
|
+
all_persons << @dataset.persons_external
|
155
|
+
all_persons << @dataset.persons_other
|
156
|
+
all_persons.each do |person_type|
|
157
|
+
person_type.each do |individual|
|
158
|
+
pure_role =individual.role.gsub(/\s+/, '')
|
159
|
+
name = individual.name.last_first
|
160
|
+
if pure_role == 'Creator'
|
161
|
+
human = ::Datacite::Mapping::Creator.new name: name
|
162
|
+
else
|
163
|
+
pure_role = 'Other' if pure_role === 'Contributor'
|
164
|
+
contributor_type = ::Datacite::Mapping::ContributorType.find_by_value pure_role
|
165
|
+
if contributor_type
|
166
|
+
human = ::Datacite::Mapping::Contributor.new name: name,
|
167
|
+
type: contributor_type
|
136
168
|
end
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
if dataset_person['role'] == 'Creator'
|
150
|
-
o['creator'] << human
|
151
|
-
else
|
152
|
-
o['contributor'] << human
|
169
|
+
end
|
170
|
+
if human
|
171
|
+
if individual.uuid
|
172
|
+
person_extractor = Puree::Extractor::Person.new @config
|
173
|
+
person = person_extractor.find uuid: individual.uuid
|
174
|
+
if person
|
175
|
+
identifier = name_identifier_orcid person
|
176
|
+
human.identifier = identifier if identifier
|
177
|
+
|
178
|
+
affiliation = affiliations person
|
179
|
+
human.affiliations = affiliation if affiliation
|
153
180
|
end
|
154
181
|
end
|
182
|
+
if individual.role == 'Creator'
|
183
|
+
o['creator'] << human
|
184
|
+
else
|
185
|
+
o['contributor'] << human
|
186
|
+
end
|
187
|
+
end
|
155
188
|
end
|
156
189
|
end
|
157
190
|
o
|
158
191
|
end
|
159
192
|
|
160
193
|
def publication_year
|
161
|
-
@dataset.available
|
194
|
+
@dataset.available.year
|
162
195
|
end
|
163
196
|
|
164
197
|
def publisher
|
@@ -166,19 +199,19 @@ module ResearchMetadata
|
|
166
199
|
end
|
167
200
|
|
168
201
|
def related_identifiers
|
169
|
-
publications = @dataset.
|
202
|
+
publications = @dataset.publications
|
170
203
|
data = []
|
171
204
|
publications.each do |i|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
pub.
|
180
|
-
|
181
|
-
if doi
|
205
|
+
# Skip as the relationship cannot currently be determined
|
206
|
+
next if i.type === 'Dataset'
|
207
|
+
|
208
|
+
publication_extractor = Puree::Extractor::Publication.new @config
|
209
|
+
pub = publication_extractor.find uuid: i.uuid
|
210
|
+
|
211
|
+
# Restrict to those with a DOI
|
212
|
+
doi = pub.doi if pub.methods.include? :doi
|
213
|
+
|
214
|
+
if doi
|
182
215
|
doi_part_to_remove = 'http://dx.doi.org/'
|
183
216
|
doi_short = doi.gsub(doi_part_to_remove, '')
|
184
217
|
doi_short.gsub!('/', '-')
|
@@ -205,13 +238,13 @@ module ResearchMetadata
|
|
205
238
|
# be associated with a specific place
|
206
239
|
|
207
240
|
# Place names
|
208
|
-
arr = @dataset.
|
241
|
+
arr = @dataset.spatial_places.map { |i| ::Datacite::Mapping::GeoLocation.new place: i }
|
209
242
|
|
210
243
|
# Lat Long point
|
211
244
|
spatial_point = @dataset.spatial_point
|
212
|
-
if
|
213
|
-
point = ::Datacite::Mapping::GeoLocationPoint.new latitude: spatial_point
|
214
|
-
longitude: spatial_point
|
245
|
+
if spatial_point
|
246
|
+
point = ::Datacite::Mapping::GeoLocationPoint.new latitude: spatial_point.latitude,
|
247
|
+
longitude: spatial_point.longitude
|
215
248
|
geolocation = ::Datacite::Mapping::GeoLocation.new point: point
|
216
249
|
arr << geolocation
|
217
250
|
end
|
@@ -219,7 +252,7 @@ module ResearchMetadata
|
|
219
252
|
end
|
220
253
|
|
221
254
|
def subjects
|
222
|
-
@dataset.
|
255
|
+
@dataset.keywords.map { |i| ::Datacite::Mapping::Subject.new value: i }
|
223
256
|
end
|
224
257
|
|
225
258
|
def title
|
@@ -0,0 +1,216 @@
|
|
1
|
+
module ResearchMetadata
|
2
|
+
|
3
|
+
module Transformer
|
4
|
+
|
5
|
+
# Extracts publication metadata from the Pure Research Information System
|
6
|
+
# and converts it into the DataCite format. Example usage is for theses
|
7
|
+
# (doctoral and master's).
|
8
|
+
#
|
9
|
+
class Publication
|
10
|
+
|
11
|
+
# @param config [Hash]
|
12
|
+
# @option config [String] :url The URL of the Pure host.
|
13
|
+
# @option config [String] :username The username of the Pure host account.
|
14
|
+
# @option config [String] :password The password of the Pure host account.
|
15
|
+
def initialize(config)
|
16
|
+
@config = config
|
17
|
+
@publication_extractor = Puree::Extractor::Publication.new config
|
18
|
+
end
|
19
|
+
|
20
|
+
# Publication transformation
|
21
|
+
#
|
22
|
+
# @param id [String]
|
23
|
+
# @param uuid [String]
|
24
|
+
# @param doi [String]
|
25
|
+
# @return [String, nil]
|
26
|
+
def transform(id: nil, uuid: nil, doi: nil)
|
27
|
+
@publication = extract uuid: uuid, id: id
|
28
|
+
return nil if !@publication
|
29
|
+
return nil if !publication_year
|
30
|
+
person_o = person
|
31
|
+
file_o = file
|
32
|
+
resource = ::Datacite::Mapping::Resource.new(
|
33
|
+
identifier: identifier(doi),
|
34
|
+
creators: person_o['creator'],
|
35
|
+
titles: titles,
|
36
|
+
publication_year: publication_year,
|
37
|
+
publisher: publisher,
|
38
|
+
subjects: subjects,
|
39
|
+
contributors: person_o['contributor'],
|
40
|
+
language: language,
|
41
|
+
resource_type: resource_type,
|
42
|
+
sizes: sizes(file_o),
|
43
|
+
formats: formats(file_o),
|
44
|
+
rights_list: rights_list(file_o),
|
45
|
+
descriptions: description
|
46
|
+
)
|
47
|
+
resource.write_xml
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def pages
|
53
|
+
count = @publication.pages
|
54
|
+
if count > 0
|
55
|
+
return "#{count} pages"
|
56
|
+
else
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def sizes(files)
|
62
|
+
arr = files.map { |i| "#{i.size} B" }
|
63
|
+
arr << pages if pages
|
64
|
+
arr
|
65
|
+
end
|
66
|
+
|
67
|
+
def formats(files)
|
68
|
+
files.map { |i| i.mime }
|
69
|
+
end
|
70
|
+
|
71
|
+
def rights_list(files)
|
72
|
+
arr = []
|
73
|
+
files.each do |i|
|
74
|
+
if i.license
|
75
|
+
rights = Datacite::Mapping::Rights.new value: i.license.name
|
76
|
+
arr << rights
|
77
|
+
else
|
78
|
+
arr << 'License unspecified'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
arr
|
82
|
+
end
|
83
|
+
|
84
|
+
def affiliations(person)
|
85
|
+
person.affiliations.map { |i| i.name }
|
86
|
+
end
|
87
|
+
|
88
|
+
def description
|
89
|
+
desc = @publication.description
|
90
|
+
if desc
|
91
|
+
d = ::Datacite::Mapping::Description.new value: desc,
|
92
|
+
type: ::Datacite::Mapping::DescriptionType::ABSTRACT
|
93
|
+
[d]
|
94
|
+
else
|
95
|
+
[]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def extract(uuid: nil, id: nil)
|
100
|
+
if !uuid.nil?
|
101
|
+
return @publication_extractor.find uuid: uuid
|
102
|
+
else
|
103
|
+
return @publication_extractor.find id: id
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def file
|
108
|
+
@publication.files
|
109
|
+
end
|
110
|
+
|
111
|
+
def identifier(doi)
|
112
|
+
::Datacite::Mapping::Identifier.new(value: doi)
|
113
|
+
end
|
114
|
+
|
115
|
+
def language
|
116
|
+
@publication.locale
|
117
|
+
end
|
118
|
+
|
119
|
+
def name_identifier_orcid(person)
|
120
|
+
name_identifier = nil
|
121
|
+
if person.orcid
|
122
|
+
name_identifier = ::Datacite::Mapping::NameIdentifier.new scheme: 'ORCID',
|
123
|
+
scheme_uri: URI('http://orcid.org/'),
|
124
|
+
value: person.orcid
|
125
|
+
end
|
126
|
+
name_identifier
|
127
|
+
end
|
128
|
+
|
129
|
+
def person
|
130
|
+
o = {}
|
131
|
+
o['creator'] = []
|
132
|
+
o['contributor'] = []
|
133
|
+
all_persons = []
|
134
|
+
all_persons << @publication.persons_internal
|
135
|
+
all_persons << @publication.persons_external
|
136
|
+
all_persons << @publication.persons_other
|
137
|
+
all_persons.each do |person_type|
|
138
|
+
person_type.each do |individual|
|
139
|
+
pure_role =individual.role.gsub(/\s+/, '')
|
140
|
+
role = pure_role
|
141
|
+
name = individual.name.last_first
|
142
|
+
role = 'Creator' if pure_role === 'Author'
|
143
|
+
if role == 'Creator'
|
144
|
+
human = ::Datacite::Mapping::Creator.new name: name
|
145
|
+
else
|
146
|
+
role = 'Other' if pure_role === 'Contributor'
|
147
|
+
contributor_type = ::Datacite::Mapping::ContributorType.find_by_value role
|
148
|
+
if contributor_type
|
149
|
+
human = ::Datacite::Mapping::Contributor.new name: name,
|
150
|
+
type: contributor_type
|
151
|
+
end
|
152
|
+
end
|
153
|
+
if human
|
154
|
+
if individual.uuid
|
155
|
+
person_extractor = Puree::Extractor::Person.new @config
|
156
|
+
person = person_extractor.find uuid: individual.uuid
|
157
|
+
if person
|
158
|
+
identifier = name_identifier_orcid person
|
159
|
+
human.identifier = identifier if identifier
|
160
|
+
|
161
|
+
affiliation = affiliations person
|
162
|
+
human.affiliations = affiliation if affiliation
|
163
|
+
end
|
164
|
+
end
|
165
|
+
if role == 'Creator'
|
166
|
+
o['creator'] << human
|
167
|
+
else
|
168
|
+
o['contributor'] << human
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
o
|
174
|
+
end
|
175
|
+
|
176
|
+
def publication_year
|
177
|
+
@publication.statuses.each do |i|
|
178
|
+
if i.stage === 'Published'
|
179
|
+
return i.date.year
|
180
|
+
end
|
181
|
+
end
|
182
|
+
nil
|
183
|
+
end
|
184
|
+
|
185
|
+
def publisher
|
186
|
+
@publication.publisher || 'Not specified'
|
187
|
+
end
|
188
|
+
|
189
|
+
def resource_type
|
190
|
+
::Datacite::Mapping::ResourceType.new(
|
191
|
+
resource_type_general: ::Datacite::Mapping::ResourceTypeGeneral::TEXT,
|
192
|
+
value: 'Text'
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
196
|
+
def subjects
|
197
|
+
@publication.keywords.map { |i| ::Datacite::Mapping::Subject.new value: i }
|
198
|
+
end
|
199
|
+
|
200
|
+
def titles
|
201
|
+
arr = []
|
202
|
+
title = ::Datacite::Mapping::Title.new value: @publication.title
|
203
|
+
arr << title
|
204
|
+
subtitle = @publication.subtitle
|
205
|
+
if subtitle
|
206
|
+
arr << ::Datacite::Mapping::Title.new(value: subtitle,
|
207
|
+
type: ::Datacite::Mapping::TitleType::SUBTITLE)
|
208
|
+
end
|
209
|
+
arr
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
end
|
data/lib/research_metadata.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
require 'puree'
|
2
2
|
require 'datacite/mapping'
|
3
3
|
require 'research_metadata/transformer/dataset'
|
4
|
-
require 'research_metadata/
|
4
|
+
require 'research_metadata/transformer/publication'
|
5
|
+
require 'research_metadata/version'
|
6
|
+
|
7
|
+
# Metadata extraction from the Pure Research Information System and
|
8
|
+
# transformation of the metadata into the DataCite format.
|
9
|
+
#
|
10
|
+
module ResearchMetadata
|
11
|
+
|
12
|
+
end
|
data/research_metadata.gemspec
CHANGED
@@ -8,9 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ResearchMetadata::VERSION
|
9
9
|
spec.authors = ["Adrian Albin-Clark"]
|
10
10
|
spec.email = ["a.albin-clark@lancaster.ac.uk"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.
|
13
|
-
spec.homepage = "https://aalbinclark.gitbooks.io/research_metadata"
|
11
|
+
spec.summary = %q{Metadata extraction from the Pure Research Information System and transformation of the metadata into the DataCite format.}
|
12
|
+
spec.homepage = "https://github.com/lulibrary/research_metadata"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
15
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -18,6 +17,10 @@ Gem::Specification.new do |spec|
|
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.
|
22
|
-
|
20
|
+
spec.required_ruby_version = '~> 2.1'
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "puree", "~> 1.1.0"
|
23
|
+
spec.add_runtime_dependency "datacite-mapping", "~> 0.2.5"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rspec"
|
23
26
|
end
|
@@ -3,16 +3,18 @@ require 'spec_helper'
|
|
3
3
|
describe 'Dataset' do
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
@config = {
|
7
|
+
url: ENV['PURE_URL'],
|
8
|
+
username: ENV['PURE_USERNAME'],
|
9
|
+
password: ENV['PURE_PASSWORD']
|
10
|
+
}
|
11
|
+
@t = ResearchMetadata::Transformer::Dataset.new @config
|
11
12
|
end
|
12
13
|
|
13
14
|
it '#new' do
|
14
|
-
|
15
|
-
|
15
|
+
setup
|
16
|
+
t = ResearchMetadata::Transformer::Dataset.new @config
|
17
|
+
expect(t).to be_a ResearchMetadata::Transformer::Dataset
|
16
18
|
end
|
17
19
|
|
18
20
|
describe 'data transformation' do
|
@@ -20,20 +22,16 @@ describe 'Dataset' do
|
|
20
22
|
setup
|
21
23
|
end
|
22
24
|
|
23
|
-
it '#transform with
|
24
|
-
|
25
|
+
it '#transform with random UUID' do
|
26
|
+
c = Puree::Extractor::Collection.new resource: :dataset,
|
27
|
+
config: @config
|
28
|
+
res = c.random_resource
|
29
|
+
metadata = @t.transform uuid: res.uuid,
|
25
30
|
doi: '10.1234/foo/bar/1'
|
26
31
|
is_xml = metadata.downcase.start_with?('<resource')
|
27
32
|
expect(is_xml).to match(true)
|
28
33
|
end
|
29
34
|
|
30
|
-
it '#transform with valid ID' do
|
31
|
-
metadata = @t.transform id: ENV['PURE_DATASET_ID'],
|
32
|
-
doi: '10.1234/foo/bar/1'
|
33
|
-
is_xml = metadata.downcase.start_with?('<resource')
|
34
|
-
expect(is_xml).to match(true)
|
35
|
-
end
|
36
|
-
|
37
35
|
end
|
38
36
|
|
39
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: research_metadata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
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-
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puree
|
@@ -16,29 +16,43 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: datacite-mapping
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
|
40
|
+
version: 0.2.5
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
42
56
|
email:
|
43
57
|
- a.albin-clark@lancaster.ac.uk
|
44
58
|
executables: []
|
@@ -53,11 +67,13 @@ files:
|
|
53
67
|
- Rakefile
|
54
68
|
- lib/research_metadata.rb
|
55
69
|
- lib/research_metadata/transformer/dataset.rb
|
70
|
+
- lib/research_metadata/transformer/publication.rb
|
71
|
+
- lib/research_metadata/transformer/transformer.rb
|
56
72
|
- lib/research_metadata/version.rb
|
57
73
|
- research_metadata.gemspec
|
58
74
|
- spec/spec_helper.rb
|
59
75
|
- spec/transformer/dataset_spec.rb
|
60
|
-
homepage: https://
|
76
|
+
homepage: https://github.com/lulibrary/research_metadata
|
61
77
|
licenses:
|
62
78
|
- MIT
|
63
79
|
metadata: {}
|
@@ -67,9 +83,9 @@ require_paths:
|
|
67
83
|
- lib
|
68
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
85
|
requirements:
|
70
|
-
- - "
|
86
|
+
- - "~>"
|
71
87
|
- !ruby/object:Gem::Version
|
72
|
-
version: '
|
88
|
+
version: '2.1'
|
73
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
90
|
requirements:
|
75
91
|
- - ">="
|
@@ -80,8 +96,8 @@ rubyforge_project:
|
|
80
96
|
rubygems_version: 2.2.2
|
81
97
|
signing_key:
|
82
98
|
specification_version: 4
|
83
|
-
summary:
|
99
|
+
summary: Metadata extraction from the Pure Research Information System and transformation
|
100
|
+
of the metadata into the DataCite format.
|
84
101
|
test_files:
|
85
102
|
- spec/spec_helper.rb
|
86
103
|
- spec/transformer/dataset_spec.rb
|
87
|
-
has_rdoc:
|