puree 2.1.1 → 2.2.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 +4 -0
- data/README.md +17 -7
- data/lib/puree/extractor/conference_paper.rb +5 -4
- data/lib/puree/extractor/dataset.rb +18 -8
- data/lib/puree/extractor/doctoral_thesis.rb +5 -9
- data/lib/puree/extractor/event.rb +18 -8
- data/lib/puree/extractor/external_organisation.rb +18 -8
- data/lib/puree/extractor/journal.rb +18 -8
- data/lib/puree/extractor/journal_article.rb +12 -9
- data/lib/puree/extractor/masters_thesis.rb +5 -9
- data/lib/puree/extractor/organisational_unit.rb +18 -8
- data/lib/puree/extractor/paper.rb +5 -4
- data/lib/puree/extractor/person.rb +18 -3
- data/lib/puree/extractor/project.rb +18 -3
- data/lib/puree/extractor/publisher.rb +18 -3
- data/lib/puree/extractor/research_output.rb +27 -3
- data/lib/puree/extractor/resource.rb +16 -1
- data/lib/puree/extractor/thesis.rb +5 -9
- data/lib/puree/rest/activity.rb +0 -5
- data/lib/puree/rest/application.rb +0 -5
- data/lib/puree/rest/classification_scheme.rb +0 -5
- data/lib/puree/rest/curricula_vitae.rb +0 -5
- data/lib/puree/rest/dataset.rb +0 -5
- data/lib/puree/rest/equipment.rb +0 -5
- data/lib/puree/rest/event.rb +0 -5
- data/lib/puree/rest/external_organisation.rb +0 -5
- data/lib/puree/rest/external_person.rb +0 -5
- data/lib/puree/rest/impact.rb +0 -5
- data/lib/puree/rest/journal.rb +0 -5
- data/lib/puree/rest/organisational_unit.rb +0 -5
- data/lib/puree/rest/person.rb +0 -5
- data/lib/puree/rest/press_media.rb +0 -5
- data/lib/puree/rest/prize.rb +0 -5
- data/lib/puree/rest/project.rb +0 -5
- data/lib/puree/rest/publisher.rb +0 -5
- data/lib/puree/rest/research_output.rb +0 -5
- data/lib/puree/version.rb +1 -1
- data/lib/puree/xml_extractor/collection.rb +14 -0
- data/test/extractor/resource_count_test.rb +68 -0
- data/test/extractor/{resource_test.rb → resource_find_test.rb} +0 -0
- data/test/extractor/resource_random_test.rb +66 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be040161fa2a4bfb0252b864310d90d56e88ac19
|
4
|
+
data.tar.gz: 1b6437a55b0e4d08da2dd59af0bb5b68278d770e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ffe42bacb00c82a8fc81c2c70fec93a30d2cfd01e171d1999b18d878741f91a6ba02769ed079e11c3af0858e84fc9cedf135923e4df2d00af8fcc00c10bd11f
|
7
|
+
data.tar.gz: bca33fed3f5467ed1c62153c2100eb26cb3252f427e66b140934fb38648b449d45dc03da742247048bc6beffc2ea85f1dafb2c3f9e943e0ae27aa26a53242b32
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
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
|
+
## 2.2.0 2018-04-20
|
6
|
+
### Added
|
7
|
+
- Count, random for resource extractors.
|
8
|
+
|
5
9
|
## 2.1.1 2018-04-18
|
6
10
|
### Fixed
|
7
11
|
- Handle missing created and modified.
|
data/README.md
CHANGED
@@ -33,15 +33,25 @@ config = {
|
|
33
33
|
```
|
34
34
|
|
35
35
|
## Extractor module
|
36
|
-
Find a resource by identifier and get Ruby objects.
|
37
|
-
|
38
36
|
```ruby
|
39
|
-
# Configure an extractor
|
37
|
+
# Configure an extractor for a resource
|
40
38
|
extractor = Puree::Extractor::Dataset.new config
|
41
39
|
```
|
42
40
|
|
43
41
|
```ruby
|
44
|
-
#
|
42
|
+
# Find out how many records are available
|
43
|
+
extractor.count
|
44
|
+
#=> 1000
|
45
|
+
```
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# Fetch a random record
|
49
|
+
extractor.random
|
50
|
+
#=> #<Puree::Model::Dataset:0x00c0ffee>
|
51
|
+
```
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# Fetch the metadata for a record with a particular identifier
|
45
55
|
dataset = extractor.find 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
46
56
|
#=> #<Puree::Model::Dataset:0x00c0ffee>
|
47
57
|
```
|
@@ -61,7 +71,7 @@ dataset.persons_internal[0].name.last_initial
|
|
61
71
|
## XMLExtractor module
|
62
72
|
Get Ruby objects from Pure XML.
|
63
73
|
|
64
|
-
### Single
|
74
|
+
### Single record
|
65
75
|
```ruby
|
66
76
|
xml = '<project> ... </project>'
|
67
77
|
```
|
@@ -83,7 +93,7 @@ xml_extractor.model
|
|
83
93
|
#=> #<Puree::Model::Project:0x00c0ffee>
|
84
94
|
```
|
85
95
|
|
86
|
-
### Homogeneous
|
96
|
+
### Homogeneous record collection
|
87
97
|
```ruby
|
88
98
|
xml = '<result>
|
89
99
|
<dataSet> ... </dataSet>
|
@@ -98,7 +108,7 @@ Puree::XMLExtractor::Collection.datasets xml
|
|
98
108
|
#=> [#<Puree::Model::Dataset:0x00c0ffee>, ...]
|
99
109
|
```
|
100
110
|
|
101
|
-
### Heterogeneous
|
111
|
+
### Heterogeneous record collection
|
102
112
|
```ruby
|
103
113
|
xml = '<result>
|
104
114
|
<contributionToJournal> ... </contributionToJournal>
|
@@ -3,13 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Conference paper extractor.
|
5
5
|
#
|
6
|
-
class ConferencePaper < Puree::Extractor::
|
6
|
+
class ConferencePaper < Puree::Extractor::Resource
|
7
7
|
|
8
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::ConferencePaper, nil]
|
9
10
|
def find(id)
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :conference_paper
|
13
14
|
end
|
14
15
|
|
15
16
|
end
|
@@ -6,16 +6,26 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class Dataset < Puree::Extractor::Resource
|
8
8
|
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Dataset, nil]
|
15
11
|
def find(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :dataset,
|
14
|
+
xml_extractor_resource_type: :dataset
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :dataset
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Dataset, nil]
|
27
|
+
def random
|
28
|
+
super :dataset
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
@@ -3,18 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Doctoral thesis extractor.
|
5
5
|
#
|
6
|
-
class DoctoralThesis < Puree::Extractor::
|
7
|
-
|
8
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
9
|
-
def initialize(config)
|
10
|
-
super
|
11
|
-
end
|
6
|
+
class DoctoralThesis < Puree::Extractor::Resource
|
12
7
|
|
13
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::DoctoralThesis, nil]
|
14
10
|
def find(id)
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :doctoral_thesis
|
18
14
|
end
|
19
15
|
|
20
16
|
end
|
@@ -6,16 +6,26 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class Event < Puree::Extractor::Resource
|
8
8
|
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Event, nil]
|
15
11
|
def find(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :event,
|
14
|
+
xml_extractor_resource_type: :event
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :event
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Event, nil]
|
27
|
+
def random
|
28
|
+
super :event
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
@@ -6,16 +6,26 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class ExternalOrganisation < Puree::Extractor::Resource
|
8
8
|
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::ExternalOrganisation, nil]
|
15
11
|
def find(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :external_organisation,
|
14
|
+
xml_extractor_resource_type: :external_organisation
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :external_organisation
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::ExternalOrganisation, nil]
|
27
|
+
def random
|
28
|
+
super :external_organisation
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
@@ -6,16 +6,26 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class Journal < Puree::Extractor::Resource
|
8
8
|
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Journal, nil]
|
15
11
|
def find(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :journal,
|
14
|
+
xml_extractor_resource_type: :journal
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :journal
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Journal, nil]
|
27
|
+
def random
|
28
|
+
super :journal
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
@@ -3,18 +3,21 @@ module Puree
|
|
3
3
|
|
4
4
|
# Journal article extractor.
|
5
5
|
#
|
6
|
-
class JournalArticle < Puree::Extractor::
|
7
|
-
|
8
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
9
|
-
def initialize(config)
|
10
|
-
super
|
11
|
-
end
|
6
|
+
class JournalArticle < Puree::Extractor::Resource
|
12
7
|
|
13
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::JournalArticle, nil]
|
14
10
|
def find(id)
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :journal_article
|
14
|
+
end
|
15
|
+
|
16
|
+
# Random record.
|
17
|
+
#
|
18
|
+
# @return [Puree::Model::JournalArticle, nil]
|
19
|
+
def random
|
20
|
+
record_count :journal_article
|
18
21
|
end
|
19
22
|
|
20
23
|
end
|
@@ -3,18 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Master's thesis extractor.
|
5
5
|
#
|
6
|
-
class MastersThesis < Puree::Extractor::
|
7
|
-
|
8
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
9
|
-
def initialize(config)
|
10
|
-
super
|
11
|
-
end
|
6
|
+
class MastersThesis < Puree::Extractor::Resource
|
12
7
|
|
13
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::MastersThesis, nil]
|
14
10
|
def find(id)
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :masters_thesis
|
18
14
|
end
|
19
15
|
|
20
16
|
end
|
@@ -6,16 +6,26 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class OrganisationalUnit < Puree::Extractor::Resource
|
8
8
|
|
9
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::OrganisationalUnit, nil]
|
15
11
|
def find(id)
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :organisational_unit,
|
14
|
+
xml_extractor_resource_type: :organisational_unit
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :organisational_unit
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::OrganisationalUnit, nil]
|
27
|
+
def random
|
28
|
+
super :organisational_unit
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
@@ -3,13 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Paper extractor.
|
5
5
|
#
|
6
|
-
class Paper < Puree::Extractor::
|
6
|
+
class Paper < Puree::Extractor::Resource
|
7
7
|
|
8
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::Paper, nil]
|
9
10
|
def find(id)
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :paper
|
13
14
|
end
|
14
15
|
|
15
16
|
end
|
@@ -7,10 +7,25 @@ module Puree
|
|
7
7
|
class Person < Puree::Extractor::Resource
|
8
8
|
|
9
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Person, nil]
|
10
11
|
def find(id)
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :person,
|
14
|
+
xml_extractor_resource_type: :person
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :person
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Person, nil]
|
27
|
+
def random
|
28
|
+
super :person
|
14
29
|
end
|
15
30
|
|
16
31
|
end
|
@@ -7,10 +7,25 @@ module Puree
|
|
7
7
|
class Project < Puree::Extractor::Resource
|
8
8
|
|
9
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Project, nil]
|
10
11
|
def find(id)
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :project,
|
14
|
+
xml_extractor_resource_type: :project
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :project
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Project, nil]
|
27
|
+
def random
|
28
|
+
super :project
|
14
29
|
end
|
15
30
|
|
16
31
|
end
|
@@ -7,10 +7,25 @@ module Puree
|
|
7
7
|
class Publisher < Puree::Extractor::Resource
|
8
8
|
|
9
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::Publisher, nil]
|
10
11
|
def find(id)
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :publisher,
|
14
|
+
xml_extractor_resource_type: :publisher
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :publisher
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::Publisher, nil]
|
27
|
+
def random
|
28
|
+
super :publisher
|
14
29
|
end
|
15
30
|
|
16
31
|
end
|
@@ -7,10 +7,34 @@ module Puree
|
|
7
7
|
class ResearchOutput < Puree::Extractor::Resource
|
8
8
|
|
9
9
|
# @param id [String]
|
10
|
+
# @return [Puree::Model::ResearchOutput, nil]
|
10
11
|
def find(id)
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
super id: id,
|
13
|
+
api_resource_type: :research_output,
|
14
|
+
xml_extractor_resource_type: :research_output
|
15
|
+
end
|
16
|
+
|
17
|
+
# Count of records available.
|
18
|
+
#
|
19
|
+
# @return [Fixnum]
|
20
|
+
def count
|
21
|
+
record_count :research_output
|
22
|
+
end
|
23
|
+
|
24
|
+
# Random record. Includes the metadata from Puree::Model::ResearchOutput as a minimum.
|
25
|
+
#
|
26
|
+
# @return [Puree::Model::ResearchOutput or subclass, nil]
|
27
|
+
def random
|
28
|
+
client = Puree::REST::Client.new @config
|
29
|
+
offset = rand(0..count-1)
|
30
|
+
response = client.research_outputs.all params: {size: 1, offset: offset}
|
31
|
+
research_outputs_hash = Puree::XMLExtractor::Collection.research_outputs response.to_s
|
32
|
+
research_outputs_array = []
|
33
|
+
research_outputs_hash.each do |k, v|
|
34
|
+
research_outputs_array += v
|
35
|
+
end
|
36
|
+
return nil if research_outputs_array.empty?
|
37
|
+
research_outputs_array[0]
|
14
38
|
end
|
15
39
|
|
16
40
|
end
|
@@ -20,7 +20,7 @@ module Puree
|
|
20
20
|
# @param id [String]
|
21
21
|
# @param api_resource_type [Symbol]
|
22
22
|
# @param xml_extractor_resource_type [Symbol]
|
23
|
-
def
|
23
|
+
def find(id:, api_resource_type:, xml_extractor_resource_type:)
|
24
24
|
api_resource = make_api_resource api_resource_type
|
25
25
|
response = api_resource.find id: id
|
26
26
|
return unless response.code === 200
|
@@ -38,6 +38,21 @@ module Puree
|
|
38
38
|
Object.const_get(resource_class).new xml
|
39
39
|
end
|
40
40
|
|
41
|
+
def record_count(api_resource_type)
|
42
|
+
api_resource = make_api_resource api_resource_type
|
43
|
+
response = api_resource.all params: {size: 0}
|
44
|
+
return unless response.code === 200
|
45
|
+
Puree::XMLExtractor::Collection.count response.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def random(api_resource_type)
|
49
|
+
offset = rand(0..record_count(api_resource_type)-1)
|
50
|
+
api_resource = make_api_resource api_resource_type
|
51
|
+
response = api_resource.all params: {size: 1, offset: offset}
|
52
|
+
models = Puree::XMLExtractor::Collection.send "#{api_resource_type}s", response.to_s
|
53
|
+
return nil if models.empty?
|
54
|
+
models[0]
|
55
|
+
end
|
41
56
|
|
42
57
|
end
|
43
58
|
|
@@ -3,18 +3,14 @@ module Puree
|
|
3
3
|
|
4
4
|
# Thesis extractor.
|
5
5
|
#
|
6
|
-
class Thesis < Puree::Extractor::
|
7
|
-
|
8
|
-
# @option (see Puree::Extractor::Resource#initialize)
|
9
|
-
def initialize(config)
|
10
|
-
super
|
11
|
-
end
|
6
|
+
class Thesis < Puree::Extractor::Resource
|
12
7
|
|
13
8
|
# @param id [String]
|
9
|
+
# @return [Puree::Model::Thesis, nil]
|
14
10
|
def find(id)
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
super id: id,
|
12
|
+
api_resource_type: :research_output,
|
13
|
+
xml_extractor_resource_type: :thesis
|
18
14
|
end
|
19
15
|
|
20
16
|
end
|
data/lib/puree/rest/activity.rb
CHANGED
data/lib/puree/rest/dataset.rb
CHANGED
data/lib/puree/rest/equipment.rb
CHANGED
data/lib/puree/rest/event.rb
CHANGED
data/lib/puree/rest/impact.rb
CHANGED
data/lib/puree/rest/journal.rb
CHANGED
data/lib/puree/rest/person.rb
CHANGED
@@ -32,11 +32,6 @@ module Puree
|
|
32
32
|
include Puree::REST::ResearchOutputMixin
|
33
33
|
include Puree::REST::StudentThesisMixin
|
34
34
|
|
35
|
-
# (see Puree::REST::Base#initialize)
|
36
|
-
def initialize(config)
|
37
|
-
super
|
38
|
-
end
|
39
|
-
|
40
35
|
# (see Puree::REST::Base#find)
|
41
36
|
def curricula_vitae(id:, params: {}, accept: :xml)
|
42
37
|
get_request_singleton_subcollection(id: id,
|
data/lib/puree/rest/prize.rb
CHANGED
data/lib/puree/rest/project.rb
CHANGED
data/lib/puree/rest/publisher.rb
CHANGED
@@ -6,11 +6,6 @@ module Puree
|
|
6
6
|
#
|
7
7
|
class Publisher < Puree::REST::Base
|
8
8
|
|
9
|
-
# (see Puree::REST::Base#initialize)
|
10
|
-
def initialize(config)
|
11
|
-
super
|
12
|
-
end
|
13
|
-
|
14
9
|
# (see Puree::REST::Base#all)
|
15
10
|
def approved(params: {}, accept: :xml)
|
16
11
|
get_request_collection_subcollection(subcollection: 'approved',
|
data/lib/puree/version.rb
CHANGED
@@ -62,6 +62,14 @@ module Puree
|
|
62
62
|
models :person, xml, '/person'
|
63
63
|
end
|
64
64
|
|
65
|
+
# Get models from any multi-record person XML response
|
66
|
+
#
|
67
|
+
# @param xml [String]
|
68
|
+
# @return [Array<Puree::Model::Publisher>]
|
69
|
+
def self.publishers(xml)
|
70
|
+
models :publisher, xml, '/publisher'
|
71
|
+
end
|
72
|
+
|
65
73
|
# Get models from any multi-record Research output XML response
|
66
74
|
#
|
67
75
|
# @param xml [String]
|
@@ -102,6 +110,12 @@ module Puree
|
|
102
110
|
data
|
103
111
|
end
|
104
112
|
|
113
|
+
def self.count(xml)
|
114
|
+
doc = Nokogiri::XML xml
|
115
|
+
doc.remove_namespaces!
|
116
|
+
doc.xpath('/result/count').text.to_i
|
117
|
+
end
|
118
|
+
|
105
119
|
private
|
106
120
|
|
107
121
|
# Get models from any multi-record resource XML response
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestResourceCount < Minitest::Test
|
4
|
+
|
5
|
+
def test_dataset_count
|
6
|
+
extractor = Puree::Extractor::Dataset.new config
|
7
|
+
count = extractor.count
|
8
|
+
|
9
|
+
assert_instance_of Fixnum, count
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_external_organisation_count
|
13
|
+
extractor = Puree::Extractor::ExternalOrganisation.new config
|
14
|
+
count = extractor.count
|
15
|
+
|
16
|
+
assert_instance_of Fixnum, count
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_event_count
|
20
|
+
extractor = Puree::Extractor::Event.new config
|
21
|
+
count = extractor.count
|
22
|
+
|
23
|
+
assert_instance_of Fixnum, count
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_journal_count
|
27
|
+
extractor = Puree::Extractor::Journal.new config
|
28
|
+
count = extractor.count
|
29
|
+
|
30
|
+
assert_instance_of Fixnum, count
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_organisational_unit_count
|
34
|
+
extractor = Puree::Extractor::OrganisationalUnit.new config
|
35
|
+
count = extractor.count
|
36
|
+
|
37
|
+
assert_instance_of Fixnum, count
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_person_count
|
41
|
+
extractor = Puree::Extractor::Person.new config
|
42
|
+
count = extractor.count
|
43
|
+
|
44
|
+
assert_instance_of Fixnum, count
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_project_count
|
48
|
+
extractor = Puree::Extractor::Project.new config
|
49
|
+
count = extractor.count
|
50
|
+
|
51
|
+
assert_instance_of Fixnum, count
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_publisher_count
|
55
|
+
extractor = Puree::Extractor::Publisher.new config
|
56
|
+
count = extractor.count
|
57
|
+
|
58
|
+
assert_instance_of Fixnum, count
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_research_output_count
|
62
|
+
extractor = Puree::Extractor::ResearchOutput.new config
|
63
|
+
count = extractor.count
|
64
|
+
|
65
|
+
assert_instance_of Fixnum, count
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
File without changes
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestResourceRandom < Minitest::Test
|
4
|
+
|
5
|
+
def test_dataset_random
|
6
|
+
extractor = Puree::Extractor::Dataset.new config
|
7
|
+
|
8
|
+
assert_instance_of Puree::Model::Dataset, extractor.random
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_external_organisation_random
|
12
|
+
extractor = Puree::Extractor::ExternalOrganisation.new config
|
13
|
+
|
14
|
+
assert_instance_of Puree::Model::ExternalOrganisation, extractor.random
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_event_random
|
18
|
+
extractor = Puree::Extractor::Event.new config
|
19
|
+
|
20
|
+
assert_instance_of Puree::Model::Event, extractor.random
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_journal_random
|
24
|
+
extractor = Puree::Extractor::Journal.new config
|
25
|
+
|
26
|
+
assert_instance_of Puree::Model::Journal, extractor.random
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_organisational_unit_random
|
30
|
+
extractor = Puree::Extractor::OrganisationalUnit.new config
|
31
|
+
|
32
|
+
assert_instance_of Puree::Model::OrganisationalUnit, extractor.random
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_person_random
|
36
|
+
extractor = Puree::Extractor::Person.new config
|
37
|
+
|
38
|
+
assert_instance_of Puree::Model::Person, extractor.random
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_project_random
|
42
|
+
extractor = Puree::Extractor::Project.new config
|
43
|
+
|
44
|
+
assert_instance_of Puree::Model::Project, extractor.random
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_publisher_random
|
48
|
+
extractor = Puree::Extractor::Publisher.new config
|
49
|
+
|
50
|
+
assert_instance_of Puree::Model::Publisher, extractor.random
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_research_output_random
|
54
|
+
extractor = Puree::Extractor::ResearchOutput.new config
|
55
|
+
|
56
|
+
class_possibilities = [
|
57
|
+
Puree::Model::ResearchOutput,
|
58
|
+
Puree::Model::ConferencePaper,
|
59
|
+
Puree::Model::Thesis,
|
60
|
+
Puree::Model::JournalArticle
|
61
|
+
]
|
62
|
+
random = extractor.random
|
63
|
+
assert_includes class_possibilities, random.class
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.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: 2018-04-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -199,7 +199,9 @@ files:
|
|
199
199
|
- lib/puree/xml_extractor/thesis.rb
|
200
200
|
- lib/puree/xml_extractor/xml_extractor.rb
|
201
201
|
- puree.gemspec
|
202
|
-
- test/extractor/
|
202
|
+
- test/extractor/resource_count_test.rb
|
203
|
+
- test/extractor/resource_find_test.rb
|
204
|
+
- test/extractor/resource_random_test.rb
|
203
205
|
- test/rest/base_test.rb
|
204
206
|
- test/rest/common_test.rb
|
205
207
|
- test/test_extractor_helper.rb
|
@@ -244,7 +246,9 @@ signing_key:
|
|
244
246
|
specification_version: 4
|
245
247
|
summary: Metadata extraction from the Pure Research Information System.
|
246
248
|
test_files:
|
247
|
-
- test/extractor/
|
249
|
+
- test/extractor/resource_count_test.rb
|
250
|
+
- test/extractor/resource_find_test.rb
|
251
|
+
- test/extractor/resource_random_test.rb
|
248
252
|
- test/rest/base_test.rb
|
249
253
|
- test/rest/common_test.rb
|
250
254
|
- test/test_extractor_helper.rb
|