puree 1.3.0 → 1.4.0
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/CHANGELOG.md +4 -0
- data/lib/puree.rb +9 -5
- data/lib/puree/extractor/project.rb +4 -1
- data/lib/puree/extractor/publication.rb +2 -0
- data/lib/puree/model/external_organisation_header.rb +26 -0
- data/lib/puree/model/project.rb +10 -0
- data/lib/puree/model/publication.rb +6 -0
- data/lib/puree/version.rb +1 -1
- data/lib/puree/xml_extractor/dataset.rb +1 -15
- data/lib/puree/xml_extractor/mixins/associated_mixin.rb +27 -0
- data/lib/puree/xml_extractor/mixins/external_organisations_mixin.rb +18 -0
- data/lib/puree/xml_extractor/project.rb +9 -0
- data/lib/puree/xml_extractor/publication.rb +2 -0
- data/lib/puree/xml_extractor/shared.rb +17 -0
- data/spec/resource/project_http_spec.rb +13 -0
- data/spec/resource/publication_http_spec.rb +40 -4
- data/spec/spec_helper.rb +9 -5
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f4b875fcc3fc9d0c03faf62d20332c2be02b8c7
|
4
|
+
data.tar.gz: eacdf05a1625cda281f653009389b16dc2d10822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d644dbf426c9137f442e14b385b9535d9f65e4fd90c5bc24eb1417416d169b867f6aa828d16d44ffb95e7b39e2a49462a95aaff79b322c5385d30ae493afe25c
|
7
|
+
data.tar.gz: 9f40cdd393fb7606d55431c9de9ff68db7ee2341234997e48db252ec240a6fc50a55282ffb120820485379c69aa5e3d83f7f35d0c9c50dfc48adfe875250e508
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
## Unreleased
|
6
6
|
- Metadata: activity?, clipping?, externalPerson?
|
7
7
|
|
8
|
+
## 1.4.0 - 2017-09-01
|
9
|
+
- Project - external_organisations, funded.
|
10
|
+
- Publication - associated, external_organisations.
|
11
|
+
|
8
12
|
## 1.3.0 - 2017-04-03
|
9
13
|
### Added
|
10
14
|
- Publication type - JournalArticle, Paper, ConferencePaper.
|
data/lib/puree.rb
CHANGED
@@ -6,6 +6,14 @@ require 'puree/version'
|
|
6
6
|
require 'puree/util/date'
|
7
7
|
require 'puree/util/string'
|
8
8
|
|
9
|
+
require 'puree/xml_extractor/mixins/associated_mixin'
|
10
|
+
require 'puree/xml_extractor/mixins/doi_mixin'
|
11
|
+
require 'puree/xml_extractor/mixins/event_mixin'
|
12
|
+
require 'puree/xml_extractor/mixins/external_organisations_mixin'
|
13
|
+
require 'puree/xml_extractor/mixins/pages_mixin'
|
14
|
+
require 'puree/xml_extractor/mixins/page_range_mixin'
|
15
|
+
require 'puree/xml_extractor/mixins/peer_reviewed_mixin'
|
16
|
+
|
9
17
|
require 'puree/xml_extractor/shared'
|
10
18
|
require 'puree/xml_extractor/base'
|
11
19
|
require 'puree/xml_extractor/collection'
|
@@ -18,11 +26,6 @@ require 'puree/xml_extractor/organisation'
|
|
18
26
|
require 'puree/xml_extractor/person'
|
19
27
|
require 'puree/xml_extractor/project'
|
20
28
|
|
21
|
-
require 'puree/xml_extractor/mixins/doi_mixin'
|
22
|
-
require 'puree/xml_extractor/mixins/event_mixin'
|
23
|
-
require 'puree/xml_extractor/mixins/pages_mixin'
|
24
|
-
require 'puree/xml_extractor/mixins/page_range_mixin'
|
25
|
-
require 'puree/xml_extractor/mixins/peer_reviewed_mixin'
|
26
29
|
require 'puree/xml_extractor/publication'
|
27
30
|
require 'puree/xml_extractor/thesis'
|
28
31
|
require 'puree/xml_extractor/doctoral_thesis'
|
@@ -71,6 +74,7 @@ require 'puree/model/spatial_point'
|
|
71
74
|
require 'puree/model/address'
|
72
75
|
require 'puree/model/copyright_license'
|
73
76
|
require 'puree/model/event_header'
|
77
|
+
require 'puree/model/external_organisation_header'
|
74
78
|
require 'puree/model/file'
|
75
79
|
require 'puree/model/legal_condition'
|
76
80
|
require 'puree/model/organisation_header'
|
@@ -9,7 +9,7 @@ module Puree
|
|
9
9
|
# @option (see Puree::Extractor::Resource#initialize)
|
10
10
|
def initialize(config)
|
11
11
|
super
|
12
|
-
@latest_api = false #
|
12
|
+
@latest_api = false # current API does not return person roles
|
13
13
|
setup :project
|
14
14
|
end
|
15
15
|
|
@@ -18,7 +18,10 @@ module Puree
|
|
18
18
|
def combine_metadata
|
19
19
|
super
|
20
20
|
@model.acronym = @extractor.acronym
|
21
|
+
# @model.associated = @extractor.associated # not present in stable API
|
21
22
|
@model.description = @extractor.description
|
23
|
+
@model.external_organisations = @extractor.external_organisations
|
24
|
+
@model.funded = @extractor.funded?
|
22
25
|
@model.organisations = @extractor.organisations
|
23
26
|
@model.owner = @extractor.owner
|
24
27
|
@model.persons_internal = @extractor.persons_internal
|
@@ -17,10 +17,12 @@ module Puree
|
|
17
17
|
def combine_metadata
|
18
18
|
super
|
19
19
|
|
20
|
+
@model.associated = @extractor.associated
|
20
21
|
@model.bibliographical_note = @extractor.bibliographical_note
|
21
22
|
@model.category = @extractor.category
|
22
23
|
@model.description = @extractor.description
|
23
24
|
@model.dois = @extractor.dois
|
25
|
+
@model.external_organisations = @extractor.external_organisations
|
24
26
|
@model.files = @extractor.files
|
25
27
|
@model.keywords = @extractor.keywords
|
26
28
|
@model.language = @extractor.language
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Puree
|
2
|
+
module Model
|
3
|
+
|
4
|
+
# A minimal representation of an ExternalOrganisation.
|
5
|
+
#
|
6
|
+
class ExternalOrganisationHeader < Puree::Model::Structure
|
7
|
+
|
8
|
+
# @return [String, nil]
|
9
|
+
attr_reader :uuid
|
10
|
+
|
11
|
+
# @return [String, nil]
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
# @param v [String]
|
15
|
+
def uuid=(v)
|
16
|
+
@uuid = v if v && !v.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param v [String]
|
20
|
+
def name=(v)
|
21
|
+
@name = v if v && !v.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/puree/model/project.rb
CHANGED
@@ -8,9 +8,19 @@ module Puree
|
|
8
8
|
# @return [String, nil]
|
9
9
|
attr_accessor :acronym
|
10
10
|
|
11
|
+
# not present in stable API
|
12
|
+
# @return [Array<Puree::Model::RelatedContentHeader>]
|
13
|
+
# attr_accessor :associated
|
14
|
+
|
11
15
|
# @return [String, nil]
|
12
16
|
attr_accessor :description
|
13
17
|
|
18
|
+
# @return [Array<Puree::Model::ExternalOrganisationHeader>]
|
19
|
+
attr_accessor :external_organisations
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
attr_accessor :funded
|
23
|
+
|
14
24
|
# @return [Array<Puree::Model::OrganisationHeader>]
|
15
25
|
attr_accessor :organisations
|
16
26
|
|
@@ -5,6 +5,9 @@ module Puree
|
|
5
5
|
#
|
6
6
|
class Publication < Resource
|
7
7
|
|
8
|
+
# @return [Array<Puree::Model::RelatedContentHeader>]
|
9
|
+
attr_accessor :associated
|
10
|
+
|
8
11
|
# @return [String, nil]
|
9
12
|
attr_accessor :bibliographical_note
|
10
13
|
|
@@ -17,6 +20,9 @@ module Puree
|
|
17
20
|
# @return [Array<String>]
|
18
21
|
attr_accessor :dois
|
19
22
|
|
23
|
+
# @return [Array<Puree::Model::ExternalOrganisationHeader>]
|
24
|
+
attr_accessor :external_organisations
|
25
|
+
|
20
26
|
# @return [Array<Puree::Model::File>]
|
21
27
|
attr_accessor :files
|
22
28
|
|
data/lib/puree/version.rb
CHANGED
@@ -5,6 +5,7 @@ module Puree
|
|
5
5
|
# Dataset XML extractor.
|
6
6
|
#
|
7
7
|
class Dataset < Puree::XMLExtractor::Resource
|
8
|
+
include Puree::XMLExtractor::AssociatedMixin
|
8
9
|
|
9
10
|
def initialize(xml:)
|
10
11
|
super
|
@@ -17,21 +18,6 @@ module Puree
|
|
17
18
|
xpath_query_for_single_value '/openAccessPermission/term/localizedString'
|
18
19
|
end
|
19
20
|
|
20
|
-
# Combines projects and publications
|
21
|
-
# @return [Array<Puree::Model::RelatedContentHeader>]
|
22
|
-
def associated
|
23
|
-
xpath_result = xpath_query '/associatedContent/relatedContent'
|
24
|
-
data_arr = []
|
25
|
-
xpath_result.each { |i|
|
26
|
-
related = Puree::Model::RelatedContentHeader.new
|
27
|
-
related.type = i.xpath('typeClassification').text.strip
|
28
|
-
related.title = i.xpath('title').text.strip
|
29
|
-
related.uuid = i.attr('uuid').strip
|
30
|
-
data_arr << related
|
31
|
-
}
|
32
|
-
data_arr.uniq { |d| d.uuid }
|
33
|
-
end
|
34
|
-
|
35
21
|
# Date made available
|
36
22
|
# @return [Time, nil]
|
37
23
|
def available
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# Associated extractor mixin.
|
6
|
+
#
|
7
|
+
module AssociatedMixin
|
8
|
+
|
9
|
+
# Combines projects and publications
|
10
|
+
# @return [Array<Puree::Model::RelatedContentHeader>]
|
11
|
+
def associated
|
12
|
+
xpath_result = xpath_query '/associatedContent/relatedContent'
|
13
|
+
data_arr = []
|
14
|
+
xpath_result.each { |i|
|
15
|
+
related = Puree::Model::RelatedContentHeader.new
|
16
|
+
related.type = i.xpath('typeClassification').text.strip
|
17
|
+
related.title = i.xpath('title').text.strip
|
18
|
+
related.uuid = i.attr('uuid').strip
|
19
|
+
data_arr << related
|
20
|
+
}
|
21
|
+
data_arr.uniq { |d| d.uuid }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Puree
|
2
|
+
|
3
|
+
module XMLExtractor
|
4
|
+
|
5
|
+
# External organisations extractor mixin.
|
6
|
+
#
|
7
|
+
module ExternalOrganisationsMixin
|
8
|
+
|
9
|
+
# @return [Array<Puree::Model::ExternalOrganisationHeader>]
|
10
|
+
def external_organisations
|
11
|
+
xpath_result = xpath_query '/associatedExternalOrganisations/externalOrganisation'
|
12
|
+
Puree::XMLExtractor::Shared.external_organisation_multi_header xpath_result
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -5,6 +5,8 @@ module Puree
|
|
5
5
|
# Project XML extractor.
|
6
6
|
#
|
7
7
|
class Project < Puree::XMLExtractor::Resource
|
8
|
+
# include Puree::XMLExtractor::AssociatedMixin # not present in stable API
|
9
|
+
include Puree::XMLExtractor::ExternalOrganisationsMixin
|
8
10
|
|
9
11
|
def initialize(xml:)
|
10
12
|
super
|
@@ -21,6 +23,13 @@ module Puree
|
|
21
23
|
xpath_query_for_single_value '/description/localizedString'
|
22
24
|
end
|
23
25
|
|
26
|
+
# @return [Boolean]
|
27
|
+
def funded?
|
28
|
+
xpath_result = xpath_query_for_single_value '/type'
|
29
|
+
return false if xpath_result.downcase.include? 'nonfunded'
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
24
33
|
# @return [Array<Puree::Model::OrganisationHeader>]
|
25
34
|
def organisations
|
26
35
|
xpath_result = xpath_query '/organisations/association/organisation'
|
@@ -6,6 +6,23 @@ module Puree
|
|
6
6
|
#
|
7
7
|
module Shared
|
8
8
|
|
9
|
+
# @return [Puree::Model::ExternalOrganisationHeader]
|
10
|
+
def self.external_organisation_header(nokogiri_xml_element)
|
11
|
+
h = Puree::Model::ExternalOrganisationHeader.new
|
12
|
+
h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
|
13
|
+
h.name = nokogiri_xml_element.xpath('name').text.strip
|
14
|
+
h
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Array<Puree::Model::ExternalOrganisationHeader>]
|
18
|
+
def self.external_organisation_multi_header(nokogiri_xml_nodeset)
|
19
|
+
data = []
|
20
|
+
nokogiri_xml_nodeset.each do |i|
|
21
|
+
data << external_organisation_header(i)
|
22
|
+
end
|
23
|
+
data.uniq { |d| d.uuid }
|
24
|
+
end
|
25
|
+
|
9
26
|
# @return [Puree::Model::OrganisationHeader]
|
10
27
|
def self.organisation_header(nokogiri_xml_element)
|
11
28
|
h = Puree::Model::OrganisationHeader.new
|
@@ -23,10 +23,23 @@ describe 'Project' do
|
|
23
23
|
expect(@p.acronym).to be_a String if @p.acronym
|
24
24
|
end
|
25
25
|
|
26
|
+
# not present in stable API
|
27
|
+
# it '#associated' do
|
28
|
+
# expect(@p.associated).to all( be_a Puree::Model::RelatedContentHeader )
|
29
|
+
# end
|
30
|
+
|
26
31
|
it '#description' do
|
27
32
|
expect(@p.description).to be_a String if @p.description
|
28
33
|
end
|
29
34
|
|
35
|
+
it '#external_organisations' do
|
36
|
+
expect(@p.external_organisations).to all( be_a Puree::Model::ExternalOrganisationHeader )
|
37
|
+
end
|
38
|
+
|
39
|
+
it '#funded' do
|
40
|
+
expect(@p.funded).to be(true).or be(false)
|
41
|
+
end
|
42
|
+
|
30
43
|
it '#organisations' do
|
31
44
|
expect(@p.organisations).to all( be_a Puree::Model::OrganisationHeader )
|
32
45
|
end
|
@@ -17,6 +17,14 @@ describe 'Publication' do
|
|
17
17
|
expect(@p).to be_a Puree::Model::Publication
|
18
18
|
end
|
19
19
|
|
20
|
+
it '#associated' do
|
21
|
+
expect(@p.associated).to all( be_a Puree::Model::RelatedContentHeader )
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#bibliographical_note' do
|
25
|
+
expect(@p.bibliographical_note).to be_a String if @p.bibliographical_note
|
26
|
+
end
|
27
|
+
|
20
28
|
it '#category' do
|
21
29
|
expect(@p.category).to be_a String if @p.category
|
22
30
|
end
|
@@ -25,10 +33,30 @@ describe 'Publication' do
|
|
25
33
|
expect(@p.description).to be_a String if @p.description
|
26
34
|
end
|
27
35
|
|
36
|
+
it '#dois' do
|
37
|
+
expect(@p.dois).to all( be_a String )
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#external_organisations' do
|
41
|
+
expect(@p.external_organisations).to all( be_a Puree::Model::ExternalOrganisationHeader )
|
42
|
+
end
|
43
|
+
|
28
44
|
it '#files' do
|
29
45
|
expect(@p.files).to all( be_a Puree::Model::File )
|
30
46
|
end
|
31
47
|
|
48
|
+
it '#keywords' do
|
49
|
+
expect(@p.keywords).to all( be_a String )
|
50
|
+
end
|
51
|
+
|
52
|
+
it '#language' do
|
53
|
+
expect(@p.language).to be_a String if @p.language
|
54
|
+
end
|
55
|
+
|
56
|
+
it '#links' do
|
57
|
+
expect(@p.links).to all( be_a String )
|
58
|
+
end
|
59
|
+
|
32
60
|
it '#organisations' do
|
33
61
|
expect(@p.organisations).to all( be_a Puree::Model::OrganisationHeader )
|
34
62
|
end
|
@@ -49,6 +77,14 @@ describe 'Publication' do
|
|
49
77
|
expect(@p.persons_other).to all( be_a Puree::Model::EndeavourPerson )
|
50
78
|
end
|
51
79
|
|
80
|
+
it '#publication_place' do
|
81
|
+
expect(@p.publication_place).to be_a String if @p.publication_place
|
82
|
+
end
|
83
|
+
|
84
|
+
it '#publisher' do
|
85
|
+
expect(@p.publisher).to be_a String if @p.publisher
|
86
|
+
end
|
87
|
+
|
52
88
|
it '#statuses' do
|
53
89
|
expect(@p.statuses).to all( be_a Puree::Model::PublicationStatus )
|
54
90
|
end
|
@@ -61,14 +97,14 @@ describe 'Publication' do
|
|
61
97
|
expect(@p.title).to be_a String if @p.title
|
62
98
|
end
|
63
99
|
|
64
|
-
it '#translated_title' do
|
65
|
-
expect(@p.translated_title).to be_a String if @p.translated_title
|
66
|
-
end
|
67
|
-
|
68
100
|
it '#translated_subtitle' do
|
69
101
|
expect(@p.translated_subtitle).to be_a String if @p.translated_subtitle
|
70
102
|
end
|
71
103
|
|
104
|
+
it '#translated_title' do
|
105
|
+
expect(@p.translated_title).to be_a String if @p.translated_title
|
106
|
+
end
|
107
|
+
|
72
108
|
it '#type' do
|
73
109
|
expect(@p.type).to be_a String if @p.type
|
74
110
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,14 @@ require 'puree/version'
|
|
6
6
|
require 'puree/util/date'
|
7
7
|
require 'puree/util/string'
|
8
8
|
|
9
|
+
require 'puree/xml_extractor/mixins/associated_mixin'
|
10
|
+
require 'puree/xml_extractor/mixins/doi_mixin'
|
11
|
+
require 'puree/xml_extractor/mixins/event_mixin'
|
12
|
+
require 'puree/xml_extractor/mixins/external_organisations_mixin'
|
13
|
+
require 'puree/xml_extractor/mixins/pages_mixin'
|
14
|
+
require 'puree/xml_extractor/mixins/page_range_mixin'
|
15
|
+
require 'puree/xml_extractor/mixins/peer_reviewed_mixin'
|
16
|
+
|
9
17
|
require 'puree/xml_extractor/shared'
|
10
18
|
require 'puree/xml_extractor/base'
|
11
19
|
require 'puree/xml_extractor/collection'
|
@@ -18,11 +26,6 @@ require 'puree/xml_extractor/organisation'
|
|
18
26
|
require 'puree/xml_extractor/person'
|
19
27
|
require 'puree/xml_extractor/project'
|
20
28
|
|
21
|
-
require 'puree/xml_extractor/mixins/doi_mixin'
|
22
|
-
require 'puree/xml_extractor/mixins/event_mixin'
|
23
|
-
require 'puree/xml_extractor/mixins/pages_mixin'
|
24
|
-
require 'puree/xml_extractor/mixins/page_range_mixin'
|
25
|
-
require 'puree/xml_extractor/mixins/peer_reviewed_mixin'
|
26
29
|
require 'puree/xml_extractor/publication'
|
27
30
|
require 'puree/xml_extractor/thesis'
|
28
31
|
require 'puree/xml_extractor/doctoral_thesis'
|
@@ -71,6 +74,7 @@ require 'puree/model/spatial_point'
|
|
71
74
|
require 'puree/model/address'
|
72
75
|
require 'puree/model/copyright_license'
|
73
76
|
require 'puree/model/event_header'
|
77
|
+
require 'puree/model/external_organisation_header'
|
74
78
|
require 'puree/model/file'
|
75
79
|
require 'puree/model/legal_condition'
|
76
80
|
require 'puree/model/organisation_header'
|
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: 1.
|
4
|
+
version: 1.4.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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/puree/model/endeavour_person.rb
|
101
101
|
- lib/puree/model/event.rb
|
102
102
|
- lib/puree/model/event_header.rb
|
103
|
+
- lib/puree/model/external_organisation_header.rb
|
103
104
|
- lib/puree/model/file.rb
|
104
105
|
- lib/puree/model/helper/validation.rb
|
105
106
|
- lib/puree/model/journal.rb
|
@@ -140,8 +141,10 @@ files:
|
|
140
141
|
- lib/puree/xml_extractor/journal.rb
|
141
142
|
- lib/puree/xml_extractor/journal_article.rb
|
142
143
|
- lib/puree/xml_extractor/masters_thesis.rb
|
144
|
+
- lib/puree/xml_extractor/mixins/associated_mixin.rb
|
143
145
|
- lib/puree/xml_extractor/mixins/doi_mixin.rb
|
144
146
|
- lib/puree/xml_extractor/mixins/event_mixin.rb
|
147
|
+
- lib/puree/xml_extractor/mixins/external_organisations_mixin.rb
|
145
148
|
- lib/puree/xml_extractor/mixins/page_range_mixin.rb
|
146
149
|
- lib/puree/xml_extractor/mixins/pages_mixin.rb
|
147
150
|
- lib/puree/xml_extractor/mixins/peer_reviewed_mixin.rb
|