puree 2.4.0 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 951d9defbfc0c08a02ce5a113e567fe2483bb0273fdaf6357b8b69b1af8f82d5
4
- data.tar.gz: 644f09fe6de39e789ef0b186ece794a044bacc49aed60912d3c6ccf8cb6f958b
3
+ metadata.gz: d4e5029fa4e6560d831820e7a7852891d3d5aba9ab46fdc0b96d2db151ba0b07
4
+ data.tar.gz: 53c2ccd0e77dc22cc61b9e2813e6c97f8bc7c070074de26dde67dfe2b28c8575
5
5
  SHA512:
6
- metadata.gz: 0c5ae5ad398b0f593d0a89535bddf7ac9b42335457305d60657176b933d42d56ece5ed3d45b8366e46002bfdc9c225682506898a7b6ad24e6d75198256f7b973
7
- data.tar.gz: ce2ad05d7fe37585fa768988b506be9de69c927e8156fb1c51d8e48197bb416c3e6c58b2b87fad242f0a7da8dd347c587d0d97af77273612a3e346f79d779915
6
+ metadata.gz: 9764da69c66d18d6ff3f4ae53e35154f2ca509df28d157be2f751a576cbec4421b47ee722635de65850758493ec2d74148f9b70f081b791d7ca9bc1146d18184
7
+ data.tar.gz: 350872633c7a925cf81ef4c67a527b1205a720882860abf71ae81236c93c9adaccaa6f4f7e921efd4e92d06f9c52a51627fc3f1f032eeb7015a2533ced37f92e
@@ -2,6 +2,19 @@
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.5.0 2019-01-04
6
+ ### Added
7
+ - REST timeouts.
8
+
9
+ ### Changed
10
+ - For Pure API 511 due to change in source XML for Scopus ID in research output.
11
+
12
+ ### Added
13
+ - Organisational unit - parents.
14
+
15
+ ### Fixed
16
+ - Organisational unit - parent, for multiple parents.
17
+
5
18
  ## 2.4.0 2018-10-17
6
19
  ### Added
7
20
  - Research output - dois.
data/README.md CHANGED
@@ -25,13 +25,21 @@ Or install it yourself as:
25
25
  ```ruby
26
26
  # For Extractor and REST modules.
27
27
  config = {
28
- url: 'https://YOUR_HOST/ws/api/59',
28
+ url: 'https://YOUR_HOST/ws/api/YOUR_API_VERSION',
29
29
  username: 'YOUR_USERNAME',
30
30
  password: 'YOUR_PASSWORD',
31
31
  api_key: 'YOUR_API_KEY'
32
32
  }
33
33
  ```
34
34
 
35
+ Purée is tested using known data within a Pure installation.
36
+
37
+ Purée version | Pure API version
38
+ :---: | :---:
39
+ < 2 | < 59
40
+ < 2.5 | 59, 510
41
+ 2.5 | 511, 512
42
+
35
43
  ## Extractor module
36
44
  ```ruby
37
45
  # Configure an extractor for a resource
@@ -6,11 +6,7 @@ module Puree
6
6
  #
7
7
  class Resource
8
8
 
9
- # @param config [Hash]
10
- # @option config [String] :url URL of the Pure host
11
- # @option config [String] :username Username of the Pure host account
12
- # @option config [String] :password Password of the Pure host account
13
- # @option config [String] :api_key API key of the Pure host account
9
+ # (see Puree::REST::Base#initialize)
14
10
  def initialize(config)
15
11
  @config = config
16
12
  end
@@ -13,7 +13,7 @@ module Puree
13
13
  attr_accessor :description
14
14
 
15
15
  # Digital Object Identifier.
16
- # @return [String, nil]
16
+ # @return [Puree::Model::DOI, nil]
17
17
  attr_accessor :doi
18
18
 
19
19
  # Supporting files.
@@ -17,6 +17,9 @@ module Puree
17
17
  # @return [Puree::Model::OrganisationalUnitHeader, nil]
18
18
  attr_accessor :parent
19
19
 
20
+ # @return [Array<Puree::Model::OrganisationalUnitHeader>]
21
+ attr_accessor :parents
22
+
20
23
  # @return [Array<String>]
21
24
  attr_accessor :phone_numbers
22
25
 
@@ -14,10 +14,10 @@ module Puree
14
14
  # @return [String, nil]
15
15
  attr_accessor :description
16
16
 
17
- # @return [String, nil]
17
+ # @return [Puree::Model::DOI, nil]
18
18
  attr_accessor :doi
19
19
 
20
- # @return [Array<String>]
20
+ # @return [Array<Puree::Model::DOI>]
21
21
  attr_accessor :dois
22
22
 
23
23
  # @return [Array<Puree::Model::ExternalOrganisationHeader>]
@@ -13,7 +13,11 @@ module Puree
13
13
  # @option config [String] :username Username of the Pure host account
14
14
  # @option config [String] :password Password of the Pure host account
15
15
  # @option config [String] :api_key API key of the Pure host account
16
+ # @option config [Float] :http_read_timeout Read timeout in seconds
17
+ # @option config [Float] :http_write_timeout Write timeout in seconds
18
+ # @option config [Float] :http_connection_timeout Connection timeout in seconds
16
19
  def initialize(config)
20
+ config = http_defaults.merge config
17
21
  @http_client = HTTP::Client.new
18
22
  if config[:username] || config[:password]
19
23
  options = {}
@@ -22,6 +26,9 @@ module Puree
22
26
  @http_client = @http_client.basic_auth options
23
27
  end
24
28
  @http_client = @http_client.headers(api_key_header(config[:api_key]))
29
+ @http_client = @http_client.timeout read: config[:http_read_timeout],
30
+ write: config[:http_write_timeout],
31
+ connection: config[:http_connection_timeout]
25
32
  @url = config[:url]
26
33
  end
27
34
 
@@ -67,6 +74,14 @@ module Puree
67
74
 
68
75
  private
69
76
 
77
+ def http_defaults
78
+ {
79
+ http_read_timeout: 10,
80
+ http_write_timeout: 10,
81
+ http_connection_timeout: 10
82
+ }
83
+ end
84
+
70
85
  def accept_header(accept)
71
86
  case accept
72
87
  when :json
@@ -1,5 +1,5 @@
1
1
  module Puree
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "2.4.0"
4
+ VERSION = "2.5.0"
5
5
  end
@@ -41,10 +41,17 @@ module Puree
41
41
  xpath_query_for_single_value '/name'
42
42
  end
43
43
 
44
+ # First parent
44
45
  # @return [Puree::Model::OrganisationalUnitHeader, nil]
45
46
  def parent
47
+ multiple_parents = parents
48
+ multiple_parents.empty? ? nil : multiple_parents.first
49
+ end
50
+
51
+ # @return [Array<Puree::Model::OrganisationalUnitHeader>]
52
+ def parents
46
53
  xpath_result = xpath_query '/parents/parent'
47
- Puree::XMLExtractor::Shared.organisation_header xpath_result
54
+ Puree::XMLExtractor::Shared.organisation_multi_header xpath_result if xpath_result
48
55
  end
49
56
 
50
57
  # @return [Array<String>]
@@ -69,6 +76,7 @@ module Puree
69
76
  @model.email_addresses = email_addresses
70
77
  @model.name = name
71
78
  @model.parent = parent
79
+ @model.parents = parents
72
80
  @model.phone_numbers = phone_numbers
73
81
  @model.type = type
74
82
  @model.urls = urls
@@ -32,7 +32,7 @@ module Puree
32
32
  end
33
33
 
34
34
  # Digital Object Identifier (first one, if many)
35
- # @return [String, nil]
35
+ # @return [Puree::Model::DOI, nil]
36
36
  def doi
37
37
  multiple_dois = dois
38
38
  multiple_dois.empty? ? nil : multiple_dois.first
@@ -129,11 +129,10 @@ module Puree
129
129
 
130
130
  # @return [String, nil]
131
131
  def scopus_id
132
- xpath_result = xpath_query '/externalableInfo/secondarySources/secondarySource'
133
- return if xpath_result.empty?
134
- source = xpath_result.xpath('source')
135
- if source && source.text.strip.downcase === 'scopus'
136
- return xpath_result.xpath('sourceId').text.strip
132
+ external_identifiers.each do |i|
133
+ if i.type.downcase === 'scopus'
134
+ return i.id
135
+ end
137
136
  end
138
137
  end
139
138
 
@@ -203,6 +202,18 @@ module Puree
203
202
  @model
204
203
  end
205
204
 
205
+ def external_identifiers
206
+ xpath_result = xpath_query '/info/additionalExternalIds/id'
207
+ data = []
208
+ xpath_result.each do |d|
209
+ identifier = Puree::Model::Identifier.new
210
+ identifier.id = d.text.strip
211
+ identifier.type = d.attr('idSource').strip
212
+ data << identifier
213
+ end
214
+ data.uniq { |d| d.id }
215
+ end
216
+
206
217
  end
207
218
 
208
219
  end
@@ -28,7 +28,7 @@ class TestXMLExtractorDataset < Minitest::Test
28
28
  refute_empty x.description
29
29
 
30
30
  assert_instance_of String, x.doi
31
- refute_empty x.doi
31
+ refute_empty x.doi.to_s
32
32
 
33
33
  assert_instance_of Array, x.files
34
34
  assert_instance_of Puree::Model::File, x.files.first
@@ -35,6 +35,10 @@ class TestXMLExtractorOrganisation < Minitest::Test
35
35
  assert_instance_of Puree::Model::OrganisationalUnitHeader, x.parent
36
36
  assert_equal true, x.parent.data?
37
37
 
38
+ assert_instance_of Array, x.parents
39
+ assert_instance_of Puree::Model::OrganisationalUnitHeader, x.parents.first
40
+ assert_equal true, x.parents.first.data?
41
+
38
42
  assert_instance_of Array, x.phone_numbers
39
43
  assert_instance_of String, x.phone_numbers.first
40
44
  refute_empty x.phone_numbers.first
@@ -60,6 +64,9 @@ class TestXMLExtractorOrganisation < Minitest::Test
60
64
 
61
65
  assert_nil x.parent
62
66
 
67
+ assert_instance_of Array, x.parents
68
+ assert_empty x.parents
69
+
63
70
  assert_instance_of Array, x.phone_numbers
64
71
  assert_empty x.phone_numbers
65
72
 
@@ -31,7 +31,7 @@ class TestXMLExtractorResearchOutput < Minitest::Test
31
31
  refute_empty x.description
32
32
 
33
33
  assert_instance_of String, x.doi
34
- refute_empty x.doi
34
+ refute_empty x.doi.to_s
35
35
 
36
36
  assert_instance_of Array, x.files
37
37
  assert_instance_of Puree::Model::File, x.files.first
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.0
4
+ version: 2.5.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-10-17 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http