puree 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7129e92fd2ea35a0f0fde2fbf9a205b4df5e3ad
4
- data.tar.gz: 085ffa88bed9104eeb96e1ce0098c86d4da24ae5
3
+ metadata.gz: f8bc93ad5800cd2505cfb1e29dd1297e24f1314e
4
+ data.tar.gz: 69057fe1977ca9ba0918ec9df90a0ad0459730df
5
5
  SHA512:
6
- metadata.gz: 34a695d6a4a69ec49798dfb59199ea6f7f4bfc6d43976d8c0ff00965b88008289b236f3ab7294c55d874819e1bc2c2b2cbeaf6eb36c2a23c279adbe903808583
7
- data.tar.gz: 7195777fc8b4ecd80b5ef5b448e5ba4a666ac58dc1e198788b37b21cda1b4003d1cfb02b046cb30f41437b4b292b55afc2fe1a7d17f6a6e674bdcde49cdec0cb
6
+ metadata.gz: e8419dade2d8cfa512fcb0afabe4c9c5db592d13c70e634272f39f945eb8a1ee66796dd1cf663294fd7b85454cb754fd5a2faf3113c2219a36542587fa4457f6
7
+ data.tar.gz: 5466e882728576e0a1ae1ab2267a9b4fa1ff9771badab46b33ed9cc63d242f5cb6524ef9e21dbdce7b8ab40164704fb2bed1c09fbc973ea06c671f495e7d5bd3
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
+ ## 0.8.0 - 2016-05-11
6
+ ### Added
7
+ - Publication metadata (description, doi, file, subtitle, title).
8
+
5
9
  ## 0.7.0 - 2016-05-10
6
10
  ### Added
7
11
  - Person metadata (affiliation, orcid).
data/README.md CHANGED
@@ -173,6 +173,21 @@ Date range. If year is present, month and day will have data or an empty string.
173
173
  }
174
174
  ```
175
175
 
176
+ ## Publication data structures
177
+
178
+ ### file
179
+ An array of files.
180
+
181
+ ```ruby
182
+ [
183
+ {
184
+ "name"=>"foo.csv",
185
+ "mime"=>"application/octet-stream",
186
+ "size"=>"1616665158",
187
+ "url"=>"http://example.com/ws/rest/files/12345678/foo.csv",
188
+ },
189
+ ]
190
+ ```
176
191
 
177
192
  ## Utilities
178
193
 
@@ -206,6 +221,8 @@ Resource metadata
206
221
 
207
222
  ```ruby
208
223
  :dataset
224
+ :person
225
+ :publication
209
226
  ```
210
227
 
211
228
  Resource metadata (single hash only)
data/lib/puree/map.rb CHANGED
@@ -16,7 +16,8 @@ module Puree
16
16
  resource_type: {
17
17
  dataset: {
18
18
  service: 'datasets',
19
- response: 'GetDataSetsResponse'
19
+ response: 'GetDataSetsResponse',
20
+ xpath: nil
20
21
  }
21
22
  }
22
23
  }
@@ -39,6 +40,7 @@ module Puree
39
40
  resource_type = {}
40
41
  resource_type[:service] = c
41
42
  resource_type[:response] = 'Get' + c.capitalize + 'Response'
43
+ resource_type[:xpath] = nil
42
44
  @api_map[:resource_type][c.to_sym] = resource_type
43
45
  end
44
46
  end
data/lib/puree/person.rb CHANGED
@@ -13,7 +13,7 @@ module Puree
13
13
  # @return [Array<String>]
14
14
  def affiliation
15
15
  path = '//organisation/name/localizedString'
16
- xpath_result = xpath_doc.xpath path
16
+ xpath_result = xpath_query path
17
17
  affiliations = []
18
18
  xpath_result.each { |i| affiliations << i.text }
19
19
  return affiliations.uniq
@@ -8,6 +8,80 @@ module Puree
8
8
  super(:publication)
9
9
  end
10
10
 
11
+ # Description
12
+ #
13
+ # @return [Array<String>]
14
+ def description
15
+ path = '//abstract/localizedString'
16
+ xpath_result = xpath_query path
17
+ data_arr = []
18
+ xpath_result.each { |i| data_arr << i.text }
19
+ data_arr
20
+ end
21
+
22
+ # Digital Object Identifier
23
+ #
24
+ # @return [String]
25
+ def doi
26
+ path = '//doi'
27
+ xpath_result = xpath_query path
28
+ xpath_result ? xpath_result.text : ''
29
+ end
30
+
31
+ # Supporting file
32
+ #
33
+ # @return [Array<Hash>]
34
+ def file
35
+ path = '//electronicVersionFileAssociations/electronicVersionFileAssociation/file'
36
+ xpath_result = xpath_query path
37
+ docs = []
38
+ xpath_result.each do |d|
39
+ doc = {}
40
+ # doc['id'] = d.xpath('id').text
41
+ doc['name'] = d.xpath('fileName').text
42
+ doc['mime'] = d.xpath('mimeType').text
43
+ doc['size'] = d.xpath('size').text
44
+ doc['url'] = d.xpath('url').text
45
+ docs << doc
46
+ end
47
+ docs
48
+ end
49
+
50
+ # Title
51
+ #
52
+ # @return [Array<String>]
53
+ def title
54
+ path = '//content/title'
55
+ xpath_result = xpath_query path
56
+ data_arr = []
57
+ xpath_result.each { |i| data_arr << i.text }
58
+ data_arr
59
+ end
60
+
61
+ # Subtitle
62
+ #
63
+ # @return [Array<String>]
64
+ def subtitle
65
+ path = '//content/subtitle'
66
+ xpath_result = xpath_query path
67
+ data_arr = []
68
+ xpath_result.each { |i| data_arr << i.text }
69
+ data_arr
70
+ end
71
+
72
+ # All metadata
73
+ #
74
+ # @return [Hash]
75
+ def metadata
76
+ o = {}
77
+ o['description'] = description
78
+ o['doi'] = doi
79
+ o['file'] = file
80
+ o['subtitle'] = subtitle
81
+ o['title'] = title
82
+ o
83
+ end
84
+
11
85
  end
12
86
 
13
87
  end
@@ -88,8 +88,8 @@ module Puree
88
88
  # Node
89
89
  #
90
90
  # @return [Hash]
91
- def node(*path)
92
- @content ? @content.dig(*path) : {}
91
+ def node(path)
92
+ @content ? @content[path] : {}
93
93
  end
94
94
 
95
95
 
@@ -121,10 +121,11 @@ module Puree
121
121
  @endpoint + '/' + service_api_mode
122
122
  end
123
123
 
124
- def xpath_doc
124
+ def xpath_query(path)
125
125
  xml = @response.body
126
126
  doc = Nokogiri::XML xml
127
127
  doc.remove_namespaces!
128
+ doc.xpath path
128
129
  end
129
130
 
130
131
  end
data/lib/puree/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Puree
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/puree.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency 'httparty', '~> 0.13', '>= 0.13.7'
22
- spec.add_runtime_dependency 'nokogiri', '~> 1.6', '>= 1.6.7.2'
21
+ spec.required_ruby_version = '~> 2.1'
22
+
23
+ spec.add_runtime_dependency 'httparty', '~> 0.13'
24
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6'
23
25
  end
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: 0.7.0
4
+ version: 0.8.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: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.13'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.13.7
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0.13'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.13.7
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: nokogiri
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +31,6 @@ dependencies:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
33
  version: '1.6'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 1.6.7.2
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +38,6 @@ dependencies:
47
38
  - - "~>"
48
39
  - !ruby/object:Gem::Version
49
40
  version: '1.6'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 1.6.7.2
53
41
  description: Consumes the Pure Research Information System API and facilitates post-processing
54
42
  of metadata into simple data structures.
55
43
  email:
@@ -91,9 +79,9 @@ require_paths:
91
79
  - lib
92
80
  required_ruby_version: !ruby/object:Gem::Requirement
93
81
  requirements:
94
- - - ">="
82
+ - - "~>"
95
83
  - !ruby/object:Gem::Version
96
- version: '0'
84
+ version: '2.1'
97
85
  required_rubygems_version: !ruby/object:Gem::Requirement
98
86
  requirements:
99
87
  - - ">="