puree 0.14.0 → 0.15.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 +25 -1
- data/README.md +16 -339
- data/lib/puree.rb +15 -2
- data/lib/puree/collection.rb +161 -32
- data/lib/puree/configuration.rb +1 -5
- data/lib/puree/dataset.rb +95 -88
- data/lib/puree/download.rb +170 -12
- data/lib/puree/event.rb +16 -11
- data/lib/puree/journal.rb +5 -2
- data/lib/puree/map.rb +13 -2
- data/lib/puree/organisation.rb +16 -15
- data/lib/puree/person.rb +38 -16
- data/lib/puree/project.rb +163 -3
- data/lib/puree/publication.rb +132 -15
- data/lib/puree/publisher.rb +6 -2
- data/lib/puree/resource.rb +95 -70
- data/lib/puree/server.rb +147 -0
- data/lib/puree/version.rb +1 -1
- data/puree.gemspec +2 -2
- data/spec/collection.rb +15 -6
- data/spec/dataset.rb +25 -24
- data/spec/spec_helper.rb +14 -2
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b99d2257bc1a5acc9a02e0518d722e741f75953d
|
4
|
+
data.tar.gz: f29a0057bcd27d84c01b90c2a1316986765442a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a043447e965f65c4ef360cd2cb8eaf7eff0043bf252c232207f2d55428573c915e8989150053e4a2cb0640e4d1976c0a73041fbcd9a711819853c0ec9b4d0d3
|
7
|
+
data.tar.gz: 09cde7525b2d29e54529b4a1710ff02fa8774aca8e051ebf5fefa3e223dc75324c8ffae2e5c68d46e9695a0b2aba52c6691aae053f82109ee5b7c641d16fa90f
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,31 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
5
|
## Unreleased
|
6
|
-
|
6
|
+
Metadata :journal, publisher
|
7
|
+
Factory to make resource objects?
|
8
|
+
|
9
|
+
## 0.15.0 - 2016-06-22
|
10
|
+
### Added
|
11
|
+
- Person (email).
|
12
|
+
- Server metadata (version).
|
13
|
+
- Download statistics.
|
14
|
+
- Collection - metadata fetch.
|
15
|
+
- Collection - returns uuids or metadata, depending upon parameter.
|
16
|
+
- Project metadata (acronym, description, owner, status, temporal, title, type, url).
|
17
|
+
- Collection and resource types - optional basic authentication.
|
18
|
+
- Replaced request library.
|
19
|
+
- Publication - category, event, organisation, page, person, status, type.
|
20
|
+
- Project - organisation, person.
|
21
|
+
- Dataset - organisation, person.
|
22
|
+
- Server and download - optional basic authentication.
|
23
|
+
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
- Dataset - organisation becomes owner.
|
27
|
+
- Global configuration namespace simplified.
|
28
|
+
- Person (affiliation - uuid added to name in a hash).
|
29
|
+
- Collection - parameter renamed to resource, in keeping with class structure.
|
30
|
+
- Resource types return metadata rather than HTTP response object.
|
7
31
|
|
8
32
|
## 0.14.0 - 2016-06-10
|
9
33
|
### Added
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Purée [![Gem Version](https://badge.fury.io/rb/puree.svg)](https://badge.fury.io/rb/puree)
|
2
|
-
|
3
|
-
|
2
|
+
Purée consumes the Pure Research Information System API and puts the metadata into simple data structures.
|
4
3
|
|
5
4
|
## Installation
|
6
5
|
|
@@ -16,359 +15,37 @@ Or install it yourself as:
|
|
16
15
|
|
17
16
|
$ gem install puree
|
18
17
|
|
19
|
-
## Usage
|
20
|
-
Authentication
|
21
|
-
|
22
|
-
```ruby
|
23
|
-
|
24
|
-
# Global settings together
|
25
|
-
Puree::Configuration.configure do |c|
|
26
|
-
c.endpoint = ENV['PURE_ENDPOINT']
|
27
|
-
c.username = ENV['PURE_USERNAME']
|
28
|
-
c.password = ENV['PURE_PASSWORD']
|
29
|
-
end
|
30
|
-
|
31
|
-
# Global settings individually
|
32
|
-
Puree::Configuration.endpoint = ENV['PURE_ENDPOINT']
|
33
|
-
Puree::Configuration.username = ENV['PURE_USERNAME']
|
34
|
-
Puree::Configuration.password = ENV['PURE_PASSWORD']
|
35
|
-
|
36
|
-
# Use global settings
|
37
|
-
d = Puree::Dataset.new
|
38
|
-
|
39
|
-
# Override one or more global settings in an instance
|
40
|
-
d = Puree::Dataset.new endpoint: 'http://example.com/ws/rest',
|
41
|
-
username: 'another_username',
|
42
|
-
password: 'another_password'
|
43
|
-
```
|
44
18
|
|
19
|
+
## Usage
|
20
|
+
The following examples are for the Dataset resource type.
|
45
21
|
|
46
|
-
|
22
|
+
### Single resource
|
23
|
+
Tell Purée what you are looking for...
|
47
24
|
|
48
25
|
```ruby
|
49
|
-
|
50
26
|
d = Puree::Dataset.new
|
51
|
-
|
52
|
-
# Get metadata using ID
|
53
|
-
d.find id: 12345678
|
54
|
-
|
55
|
-
# Reuse instance
|
56
|
-
d.find id: 87654321
|
57
|
-
|
58
|
-
# Get metadata using UUID
|
59
|
-
d.find uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
60
|
-
|
61
|
-
# Filter metadata into simple data structures
|
62
|
-
d.access
|
63
|
-
d.associated
|
64
|
-
d.available
|
65
|
-
d.created
|
66
|
-
d.description
|
67
|
-
d.doi
|
68
|
-
d.file
|
69
|
-
d.geographical
|
70
|
-
d.keyword
|
71
|
-
d.link
|
72
|
-
d.modified
|
73
|
-
d.organisation
|
74
|
-
d.person
|
75
|
-
d.production
|
76
|
-
d.project
|
77
|
-
d.publication
|
78
|
-
d.publisher
|
79
|
-
d.temporal
|
80
|
-
d.title
|
81
|
-
|
82
|
-
# Combine metadata into one simple data structure
|
83
|
-
d.metadata
|
84
|
-
|
85
|
-
# Access HTTParty functionality
|
86
|
-
d.response # HTTParty object
|
87
|
-
d.response.body # XML
|
88
|
-
d.response.code
|
89
|
-
d.response.message
|
90
|
-
d.response.headers # hash
|
91
|
-
```
|
92
|
-
|
93
|
-
Collection
|
94
|
-
|
95
|
-
```ruby
|
96
|
-
c = Puree::Collection.new api: :dataset
|
97
|
-
|
98
|
-
# Get three minimal datasets, starting at record ten, created and modified in January 2016.
|
99
|
-
c.find limit: 3, # optional, default 20
|
100
|
-
offset: 10, # optional, default 0
|
101
|
-
created_start: '2016-01-01', # optional
|
102
|
-
created_end: '2016-01-31', # optional
|
103
|
-
modified_start: '2016-01-01', # optional
|
104
|
-
modified_end: '2016-01-31' # optional
|
105
|
-
|
106
|
-
# Get UUIDs for datasets
|
107
|
-
uuids = c.uuid
|
108
|
-
|
109
|
-
# Get metadata using UUID
|
110
|
-
datasets = []
|
111
|
-
uuids.each do |uuid|
|
112
|
-
d = Puree::Dataset.new
|
113
|
-
d.find uuid: uuid
|
114
|
-
datasets << d.metadata
|
115
|
-
end
|
116
|
-
```
|
117
|
-
|
118
|
-
## Data structures
|
119
|
-
|
120
|
-
### Dataset
|
121
|
-
|
122
|
-
#### available
|
123
|
-
Date made available. If year is present, month and day will have data or an empty string.
|
124
|
-
|
125
|
-
```ruby
|
126
|
-
{
|
127
|
-
"year" => "2016",
|
128
|
-
"month" => "2",
|
129
|
-
"day" => "4"
|
130
|
-
}
|
131
|
-
```
|
132
|
-
|
133
|
-
#### file
|
134
|
-
An array of files.
|
135
|
-
|
136
|
-
```ruby
|
137
|
-
[
|
138
|
-
{
|
139
|
-
"name" => "foo.csv",
|
140
|
-
"mime" => "application/octet-stream",
|
141
|
-
"size" => "1616665158",
|
142
|
-
"url" => "http://example.com/ws/rest/files/12345678/foo.csv",
|
143
|
-
"title" => "foo.csv",
|
144
|
-
"license" => {
|
145
|
-
"name" => "CC BY-NC",
|
146
|
-
"url" => "http://creativecommons.org/licenses/by-nc/4.0/"
|
147
|
-
}
|
148
|
-
},
|
149
|
-
]
|
150
|
-
```
|
151
|
-
|
152
|
-
#### link
|
153
|
-
An array of links.
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
[
|
157
|
-
{
|
158
|
-
"url" => "http://www.example.com/~abc1234/xyz/",
|
159
|
-
"description" => "An interesting description"
|
160
|
-
},
|
161
|
-
]
|
162
|
-
```
|
163
|
-
|
164
|
-
#### organisation
|
165
|
-
Organisation responsible.
|
166
|
-
|
167
|
-
```ruby
|
168
|
-
{
|
169
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
170
|
-
"name" => "Institute for the Arts",
|
171
|
-
"type" => "Department"
|
172
|
-
}
|
27
|
+
metadata = d.find uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
173
28
|
```
|
174
|
-
|
175
|
-
#### person
|
176
|
-
Contains an array of internal persons, an array of external persons and an array of other persons.
|
177
|
-
|
178
|
-
```ruby
|
179
|
-
{
|
180
|
-
"internal" => [
|
181
|
-
{
|
182
|
-
"name" => {
|
183
|
-
"first" => "Stan",
|
184
|
-
"last" => "Laurel"
|
185
|
-
},
|
186
|
-
"role" => "Creator",
|
187
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
188
|
-
},
|
189
|
-
],
|
190
|
-
"external" => [
|
191
|
-
],
|
192
|
-
"other" => [
|
193
|
-
{
|
194
|
-
"name" => {
|
195
|
-
"first" => "Hal",
|
196
|
-
"last" => "Roach"
|
197
|
-
},
|
198
|
-
"role" => "Contributor",
|
199
|
-
"uuid" => ""
|
200
|
-
},
|
201
|
-
]
|
202
|
-
}
|
203
|
-
```
|
204
|
-
|
205
|
-
#### project
|
206
|
-
An array of projects associated with the dataset.
|
207
|
-
|
208
|
-
```ruby
|
209
|
-
[
|
210
|
-
{
|
211
|
-
"title" => "An interesting project title",
|
212
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
213
|
-
},
|
214
|
-
]
|
215
|
-
```
|
216
|
-
|
217
|
-
#### publication
|
218
|
-
An array of research outputs associated with the dataset.
|
219
|
-
|
220
|
-
```ruby
|
221
|
-
[
|
222
|
-
{
|
223
|
-
"type" => "Journal article",
|
224
|
-
"title" => "An interesting journal article title",
|
225
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
226
|
-
},
|
227
|
-
{
|
228
|
-
"type" => "Conference paper",
|
229
|
-
"title" => "An interesting conference paper title",
|
230
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
231
|
-
},
|
232
|
-
{
|
233
|
-
"type" => "Working paper",
|
234
|
-
"title" => "An interesting working paper title",
|
235
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
236
|
-
},
|
237
|
-
{
|
238
|
-
"type" => "Paper",
|
239
|
-
"title" => "An interesting paper title",
|
240
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
241
|
-
},
|
242
|
-
{
|
243
|
-
"type" => "Dataset",
|
244
|
-
"title" => "An interesting dataset title",
|
245
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
246
|
-
},
|
247
|
-
{
|
248
|
-
"type" => "Chapter",
|
249
|
-
"title" => "An interesting chapter title",
|
250
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
251
|
-
},
|
252
|
-
]
|
253
|
-
```
|
254
|
-
|
255
|
-
#### production, temporal
|
256
|
-
Date range. If year is present, month and day will have data or an empty string.
|
29
|
+
...and get the data from a hash...
|
257
30
|
|
258
31
|
```ruby
|
259
|
-
|
260
|
-
"start" => {
|
261
|
-
"year" => "2005",
|
262
|
-
"month" => "5",
|
263
|
-
"day" => "10"
|
264
|
-
},
|
265
|
-
"end" => {
|
266
|
-
"year" => "2011",
|
267
|
-
"month" => "9",
|
268
|
-
"day" => "18"
|
269
|
-
}
|
270
|
-
}
|
32
|
+
metadata['doi']
|
271
33
|
```
|
272
34
|
|
273
|
-
###
|
274
|
-
|
275
|
-
#### address
|
276
|
-
An array of addresses.
|
35
|
+
### Collection of 50 resources
|
36
|
+
Tell Purée what you are looking for...
|
277
37
|
|
278
38
|
```ruby
|
279
|
-
|
280
|
-
|
281
|
-
"street" => "Lancaster University",
|
282
|
-
"building" => "Bowland North",
|
283
|
-
"postcode" => "LA1 4YN",
|
284
|
-
"city" => "Lancaster",
|
285
|
-
"country" => "United Kingdom"
|
286
|
-
},
|
287
|
-
]
|
39
|
+
c = Puree::Collection.new resource: :dataset
|
40
|
+
metadata = c.find limit: 50
|
288
41
|
```
|
42
|
+
...and get the data from an array of hashes.
|
289
43
|
|
290
|
-
|
291
|
-
|
44
|
+
## Documentation
|
45
|
+
[API in YARD](http://www.rubydoc.info/gems/puree/frames)
|
292
46
|
|
293
|
-
|
294
|
-
{
|
295
|
-
"uuid" => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",
|
296
|
-
"name" => "Institute for the Arts",
|
297
|
-
"type" => "Department"
|
298
|
-
}
|
299
|
-
```
|
47
|
+
[Detailed usage](https://github.com/lulibrary/puree/wiki)
|
300
48
|
|
301
|
-
### Publication
|
302
49
|
|
303
|
-
#### file
|
304
|
-
An array of files.
|
305
50
|
|
306
|
-
```ruby
|
307
|
-
[
|
308
|
-
{
|
309
|
-
"name" => "foo.csv",
|
310
|
-
"mime" => "application/octet-stream",
|
311
|
-
"size" => "1616665158",
|
312
|
-
"url" => "http://example.com/ws/rest/files/12345678/foo.csv",
|
313
|
-
},
|
314
|
-
]
|
315
|
-
```
|
316
|
-
|
317
|
-
## Utilities
|
318
|
-
|
319
|
-
### Convert date to ISO 8601 format.
|
320
51
|
|
321
|
-
```ruby
|
322
|
-
Puree::Date.iso d.available
|
323
|
-
```
|
324
|
-
```ruby
|
325
|
-
{
|
326
|
-
"year" => "2016",
|
327
|
-
"month" => "4",
|
328
|
-
"day" => "18"
|
329
|
-
}
|
330
|
-
```
|
331
|
-
becomes
|
332
|
-
|
333
|
-
```ruby
|
334
|
-
"2016-04-18"
|
335
|
-
```
|
336
|
-
|
337
|
-
|
338
|
-
## API coverage
|
339
|
-
Version
|
340
|
-
|
341
|
-
```ruby
|
342
|
-
5.5.1
|
343
|
-
```
|
344
|
-
|
345
|
-
Resource metadata
|
346
|
-
|
347
|
-
```ruby
|
348
|
-
:dataset
|
349
|
-
:event
|
350
|
-
:organisation
|
351
|
-
:person
|
352
|
-
:publication
|
353
|
-
```
|
354
|
-
|
355
|
-
Resource metadata (system data and single hash only)
|
356
|
-
|
357
|
-
```ruby
|
358
|
-
:journal
|
359
|
-
:project
|
360
|
-
:publisher
|
361
|
-
```
|
362
|
-
|
363
|
-
Collections (for obtaining identifiers)
|
364
|
-
|
365
|
-
```ruby
|
366
|
-
:dataset
|
367
|
-
:event
|
368
|
-
:journal
|
369
|
-
:organisation
|
370
|
-
:person
|
371
|
-
:project
|
372
|
-
:publication
|
373
|
-
:publisher
|
374
|
-
```
|
data/lib/puree.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'http'
|
2
2
|
require 'nokogiri'
|
3
3
|
require 'puree/configuration'
|
4
4
|
require 'puree/date'
|
@@ -12,4 +12,17 @@ require 'puree/person'
|
|
12
12
|
require 'puree/project'
|
13
13
|
require 'puree/publication'
|
14
14
|
require 'puree/publisher'
|
15
|
-
require 'puree/collection'
|
15
|
+
require 'puree/collection'
|
16
|
+
require 'puree/download'
|
17
|
+
require 'puree/server'
|
18
|
+
require 'puree/version'
|
19
|
+
|
20
|
+
module Puree
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
include Puree::Configuration
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|