puree 0.15.0 → 0.16.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.
@@ -4,24 +4,70 @@ module Puree
4
4
  #
5
5
  class Person < Resource
6
6
 
7
- # @param endpoint [String]
8
- # @param optional username [String]
9
- # @param optional password [String]
10
- # @param optional basic_auth [Boolean]
11
- def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil)
7
+ # @param base_url [String]
8
+ # @param username [String]
9
+ # @param password [String]
10
+ # @param basic_auth [Boolean]
11
+ def initialize(base_url: nil, username: nil, password: nil, basic_auth: nil)
12
12
  super(api: :person,
13
- endpoint: endpoint,
13
+ base_url: base_url,
14
14
  username: username,
15
15
  password: password,
16
16
  basic_auth: basic_auth)
17
17
  end
18
18
 
19
-
20
-
21
19
  # Affiliation
22
20
  #
23
21
  # @return [Array<Hash>]
24
22
  def affiliation
23
+ @metadata['affiliation']
24
+ end
25
+
26
+ # Email
27
+ #
28
+ # @return [Array]
29
+ def email
30
+ @metadata['email']
31
+ end
32
+
33
+ # Image URL
34
+ #
35
+ # @return [Array<String>]
36
+ def image
37
+ @metadata['image']
38
+ end
39
+
40
+ # Keyword
41
+ #
42
+ # @return [Array<String>]
43
+ def keyword
44
+ @metadata['keyword']
45
+ end
46
+
47
+ # Name
48
+ #
49
+ # @return [Hash]
50
+ def name
51
+ @metadata['name']
52
+ end
53
+
54
+ # ORCID
55
+ #
56
+ # @return [String]
57
+ def orcid
58
+ @metadata['orcid']
59
+ end
60
+
61
+ # All metadata
62
+ #
63
+ # @return [Hash]
64
+ def metadata
65
+ @metadata
66
+ end
67
+
68
+ private
69
+
70
+ def extract_affiliation
25
71
  path = '//organisation'
26
72
  xpath_result = xpath_query path
27
73
  data_arr = []
@@ -34,10 +80,7 @@ module Puree
34
80
  data_arr.uniq
35
81
  end
36
82
 
37
- # Email
38
- #
39
- # @return [Array]
40
- def email
83
+ def extract_email
41
84
  path = '//emails/classificationDefinedStringFieldExtension/value'
42
85
  xpath_result = xpath_query path
43
86
  data = []
@@ -45,10 +88,7 @@ module Puree
45
88
  data.uniq
46
89
  end
47
90
 
48
- # Image URL
49
- #
50
- # @return [Array<String>]
51
- def image
91
+ def extract_image
52
92
  path = '/photos/file/url'
53
93
  xpath_result = xpath_query path
54
94
  data = []
@@ -56,10 +96,7 @@ module Puree
56
96
  data.uniq
57
97
  end
58
98
 
59
- # Keyword
60
- #
61
- # @return [Array<String>]
62
- def keyword
99
+ def extract_keyword
63
100
  path = '//keywordGroup/keyword/userDefinedKeyword/freeKeyword'
64
101
  xpath_result = xpath_query path
65
102
  data = []
@@ -67,10 +104,7 @@ module Puree
67
104
  data.uniq
68
105
  end
69
106
 
70
- # Name
71
- #
72
- # @return [Hash]
73
- def name
107
+ def extract_name
74
108
  path = '/name'
75
109
  xpath_result = xpath_query path
76
110
  first = xpath_result.xpath('firstName').text.strip
@@ -81,26 +115,20 @@ module Puree
81
115
  o
82
116
  end
83
117
 
84
- # ORCID
85
- #
86
- # @return [String]
87
- def orcid
118
+ def extract_orcid
88
119
  path = '/orcid'
89
120
  xpath_query_for_single_value path
90
121
  end
91
122
 
92
- # All metadata
93
- #
94
- # @return [Hash]
95
- def metadata
123
+ def combine_metadata
96
124
  o = super
97
- o['affiliation'] = affiliation
98
- o['email'] = email
99
- o['image'] = image
100
- o['keyword'] = keyword
101
- o['name'] = name
102
- o['orcid'] = orcid
103
- o
125
+ o['affiliation'] = extract_affiliation
126
+ o['email'] = extract_email
127
+ o['image'] = extract_image
128
+ o['keyword'] = extract_keyword
129
+ o['name'] = extract_name
130
+ o['orcid'] = extract_orcid
131
+ @metadata = o
104
132
  end
105
133
 
106
134
  end
@@ -4,41 +4,110 @@ module Puree
4
4
  #
5
5
  class Project < Resource
6
6
 
7
- # @param endpoint [String]
8
- # @param optional username [String]
9
- # @param optional password [String]
10
- # @param optional basic_auth [Boolean]
11
- def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil)
7
+ # @param base_url [String]
8
+ # @param username [String]
9
+ # @param password [String]
10
+ # @param basic_auth [Boolean]
11
+ def initialize(base_url: nil, username: nil, password: nil, basic_auth: nil)
12
12
  super(api: :project,
13
- endpoint: endpoint,
13
+ base_url: base_url,
14
14
  username: username,
15
15
  password: password,
16
16
  bleeding: false,
17
17
  basic_auth: basic_auth)
18
18
  end
19
19
 
20
-
21
-
22
20
  # Acronym
23
21
  #
24
22
  # @return [String]
25
23
  def acronym
26
- path = '/acronym'
27
- xpath_query_for_single_value path
24
+ @metadata['acronym']
28
25
  end
29
26
 
30
27
  # Description
31
28
  #
32
29
  # @return [String]
33
30
  def description
34
- path = '/description/localizedString'
35
- xpath_query_for_single_value path
31
+ @metadata['description']
36
32
  end
37
33
 
38
34
  # Organisation
39
35
  #
40
36
  # @return [Array<Hash>]
41
37
  def organisation
38
+ @metadata['organisation']
39
+ end
40
+
41
+ # Owner
42
+ #
43
+ # @return [Hash]
44
+ def owner
45
+ @metadata['owner']
46
+ end
47
+
48
+ # Person (internal, external, other)
49
+ #
50
+ # @return [Array<Hash>]
51
+ def person
52
+ @metadata['person']
53
+ end
54
+
55
+ # Status
56
+ #
57
+ # @return [String]
58
+ def status
59
+ @metadata['status']
60
+ end
61
+
62
+ # Temporal, expected and actual start and end dates as UTC datetime.
63
+ #
64
+ # @return [Hash]
65
+ def temporal
66
+ @metadata['temporal']
67
+ end
68
+
69
+ # Title
70
+ #
71
+ # @return [String]
72
+ def title
73
+ @metadata['title']
74
+ end
75
+
76
+ # Type
77
+ #
78
+ # @return [String]
79
+ def type
80
+ @metadata['type']
81
+ end
82
+
83
+ # URL
84
+ #
85
+ # @return [String]
86
+ def url
87
+ @metadata['url']
88
+ end
89
+
90
+ # All metadata
91
+ #
92
+ # @return [Hash]
93
+ def metadata
94
+ @metadata
95
+ end
96
+
97
+
98
+ private
99
+
100
+ def extract_acronym
101
+ path = '/acronym'
102
+ xpath_query_for_single_value path
103
+ end
104
+
105
+ def extract_description
106
+ path = '/description/localizedString'
107
+ xpath_query_for_single_value path
108
+ end
109
+
110
+ def extract_organisation
42
111
  path = '/organisations/association/organisation'
43
112
  xpath_result = xpath_query path
44
113
  data = []
@@ -52,10 +121,7 @@ module Puree
52
121
  data
53
122
  end
54
123
 
55
- # Owner
56
- #
57
- # @return [Hash]
58
- def owner
124
+ def extract_owner
59
125
  path = '/owner'
60
126
  xpath_result = xpath_query path
61
127
  o = {}
@@ -65,10 +131,7 @@ module Puree
65
131
  o
66
132
  end
67
133
 
68
- # Person (internal, external, other)
69
- #
70
- # @return [Array<Hash>]
71
- def person
134
+ def extract_person
72
135
  data = {}
73
136
  # internal
74
137
  path = '/persons/participantAssociation'
@@ -104,18 +167,12 @@ module Puree
104
167
  data
105
168
  end
106
169
 
107
- # Status
108
- #
109
- # @return [String]
110
- def status
170
+ def extract_status
111
171
  path = '/status/term/localizedString'
112
172
  xpath_query_for_single_value path
113
173
  end
114
174
 
115
- # Temporal, expected and actual start and end dates as UTC datetime.
116
- #
117
- # @return [Hash]
118
- def temporal
175
+ def extract_temporal
119
176
  o = {}
120
177
  o['expected'] = {}
121
178
  o['actual'] = {}
@@ -139,46 +196,34 @@ module Puree
139
196
  o
140
197
  end
141
198
 
142
- # Title
143
- #
144
- # @return [String]
145
- def title
199
+ def extract_title
146
200
  path = '/title/localizedString'
147
201
  xpath_query_for_single_value path
148
202
  end
149
203
 
150
- # Type
151
- #
152
- # @return [String]
153
- def type
204
+ def extract_type
154
205
  path = '/typeClassification/term/localizedString'
155
206
  xpath_query_for_single_value path
156
207
  end
157
208
 
158
- # URL
159
- #
160
- # @return [String]
161
- def url
209
+ def extract_url
162
210
  path = '/projectURL'
163
211
  xpath_query_for_single_value path
164
212
  end
165
213
 
166
- # All metadata
167
- #
168
- # @return [Hash]
169
- def metadata
214
+ def combine_metadata
170
215
  o = super
171
- o['acronym'] = acronym
172
- o['description'] = description
173
- o['organisation'] = organisation
174
- o['owner'] = owner
175
- o['person'] = person
176
- o['status'] = status
177
- o['temporal'] = temporal
178
- o['title'] = title
179
- o['type'] = type
180
- o['url'] = url
181
- o
216
+ o['acronym'] = extract_acronym
217
+ o['description'] = extract_description
218
+ o['organisation'] = extract_organisation
219
+ o['owner'] = extract_owner
220
+ o['person'] = extract_person
221
+ o['status'] = extract_status
222
+ o['temporal'] = extract_temporal
223
+ o['title'] = extract_title
224
+ o['type'] = extract_type
225
+ o['url'] = extract_url
226
+ @metadata = o
182
227
  end
183
228
 
184
229
  end
@@ -4,13 +4,13 @@ module Puree
4
4
  #
5
5
  class Publication < Resource
6
6
 
7
- # @param endpoint [String]
8
- # @param optional username [String]
9
- # @param optional password [String]
10
- # @param optional basic_auth [Boolean]
11
- def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil)
7
+ # @param base_url [String]
8
+ # @param username [String]
9
+ # @param password [String]
10
+ # @param basic_auth [Boolean]
11
+ def initialize(base_url: nil, username: nil, password: nil, basic_auth: nil)
12
12
  super(api: :publication,
13
- endpoint: endpoint,
13
+ base_url: base_url,
14
14
  username: username,
15
15
  password: password,
16
16
  basic_auth: basic_auth)
@@ -20,42 +20,121 @@ module Puree
20
20
  #
21
21
  # @return [String]
22
22
  def category
23
- path = '/publicationCategory/publicationCategory/term/localizedString'
24
- xpath_query_for_single_value path
23
+ @metadata['category']
25
24
  end
26
25
 
27
26
  # Description
28
27
  #
29
28
  # @return [String]
30
29
  def description
31
- path = '/abstract/localizedString'
32
- xpath_query_for_single_value path
30
+ @metadata['description']
33
31
  end
34
32
 
35
33
  # Event
36
34
  #
37
35
  # @return [Hash]
38
36
  def event
39
- path = '/event'
40
- xpath_result = xpath_query path
41
- o = {}
42
- o['uuid'] = xpath_result.xpath('@uuid').text.strip
43
- o['title'] = xpath_result.xpath('title/localizedString').text.strip
44
- o
37
+ @metadata['event']
45
38
  end
46
39
 
47
40
  # Digital Object Identifier
48
41
  #
49
42
  # @return [String]
50
43
  def doi
51
- path = '//doi'
52
- xpath_query_for_single_value path
44
+ @metadata['doi']
53
45
  end
54
46
 
55
47
  # Supporting file
56
48
  #
57
49
  # @return [Array<Hash>]
58
50
  def file
51
+ @metadata['file']
52
+ end
53
+
54
+ # Organisation
55
+ #
56
+ # @return [Array<Hash>]
57
+ def organisation
58
+ @metadata['organisation']
59
+ end
60
+
61
+ # Page
62
+ #
63
+ # @return [Array<String>]
64
+ def page
65
+ @metadata['page']
66
+ end
67
+
68
+ # Person (internal, external, other)
69
+ #
70
+ # @return [Array<Hash>]
71
+ def person
72
+ @metadata['person']
73
+ end
74
+
75
+ # Status
76
+ #
77
+ # @return [Array<Hash>]
78
+ def status
79
+ @metadata['status']
80
+ end
81
+
82
+ # Title
83
+ #
84
+ # @return [String]
85
+ def title
86
+ @metadata['title']
87
+ end
88
+
89
+ # Subtitle
90
+ #
91
+ # @return [String]
92
+ def subtitle
93
+ @metadata['subtitle']
94
+ end
95
+
96
+ # Type
97
+ #
98
+ # @return [String]
99
+ def type
100
+ @metadata['type']
101
+ end
102
+
103
+ # All metadata
104
+ #
105
+ # @return [Hash]
106
+ def metadata
107
+ @metadata
108
+ end
109
+
110
+
111
+ private
112
+
113
+ def extract_category
114
+ path = '/publicationCategory/publicationCategory/term/localizedString'
115
+ xpath_query_for_single_value path
116
+ end
117
+
118
+ def extract_description
119
+ path = '/abstract/localizedString'
120
+ xpath_query_for_single_value path
121
+ end
122
+
123
+ def extract_event
124
+ path = '/event'
125
+ xpath_result = xpath_query path
126
+ o = {}
127
+ o['uuid'] = xpath_result.xpath('@uuid').text.strip
128
+ o['title'] = xpath_result.xpath('title/localizedString').text.strip
129
+ o
130
+ end
131
+
132
+ def extract_doi
133
+ path = '//doi'
134
+ xpath_query_for_single_value path
135
+ end
136
+
137
+ def extract_file
59
138
  path = '/electronicVersionAssociations/electronicVersionFileAssociations/electronicVersionFileAssociation/file'
60
139
  xpath_result = xpath_query path
61
140
  docs = []
@@ -71,10 +150,7 @@ module Puree
71
150
  docs.uniq
72
151
  end
73
152
 
74
- # Organisation
75
- #
76
- # @return [Array<Hash>]
77
- def organisation
153
+ def extract_organisation
78
154
  path = '/organisations/association/organisation'
79
155
  xpath_result = xpath_query path
80
156
  data = []
@@ -88,18 +164,12 @@ module Puree
88
164
  data
89
165
  end
90
166
 
91
- # Page
92
- #
93
- # @return [Array<String>]
94
- def page
167
+ def extract_page
95
168
  path = '/numberOfPages'
96
169
  xpath_query_for_single_value path
97
170
  end
98
171
 
99
- # Person (internal, external, other)
100
- #
101
- # @return [Array<Hash>]
102
- def person
172
+ def extract_person
103
173
  data = {}
104
174
  # internal
105
175
  path = '/persons/personAssociation'
@@ -135,10 +205,7 @@ module Puree
135
205
  data
136
206
  end
137
207
 
138
- # Status
139
- #
140
- # @return [Array<Hash>]
141
- def status
208
+ def extract_status
142
209
  path = '/publicationStatuses/publicationStatus'
143
210
  xpath_result = xpath_query path
144
211
  data = []
@@ -155,48 +222,36 @@ module Puree
155
222
  data
156
223
  end
157
224
 
158
- # Title
159
- #
160
- # @return [String]
161
- def title
225
+ def extract_title
162
226
  path = '/title'
163
227
  xpath_query_for_single_value path
164
228
  end
165
229
 
166
- # Subtitle
167
- #
168
- # @return [String]
169
- def subtitle
230
+ def extract_subtitle
170
231
  path = '/subtitle'
171
232
  xpath_query_for_single_value path
172
233
  end
173
234
 
174
- # Type
175
- #
176
- # @return [String]
177
- def type
235
+ def extract_type
178
236
  path = '/typeClassification/term/localizedString'
179
237
  xpath_query_for_single_value path
180
238
  end
181
239
 
182
- # All metadata
183
- #
184
- # @return [Hash]
185
- def metadata
240
+ def combine_metadata
186
241
  o = super
187
- o['category'] = category
188
- o['description'] = description
189
- o['doi'] = doi
190
- o['event'] = event
191
- o['file'] = file
192
- o['organisation'] = organisation
193
- o['page'] = page
194
- o['person'] = person
195
- o['status'] = status
196
- o['subtitle'] = subtitle
197
- o['title'] = title
198
- o['type'] = type
199
- o
242
+ o['category'] = extract_category
243
+ o['description'] = extract_description
244
+ o['doi'] = extract_doi
245
+ o['event'] = extract_event
246
+ o['file'] = extract_file
247
+ o['organisation'] = extract_organisation
248
+ o['page'] = extract_page
249
+ o['person'] = extract_person
250
+ o['status'] = extract_status
251
+ o['subtitle'] = extract_subtitle
252
+ o['title'] = extract_title
253
+ o['type'] = extract_type
254
+ @metadata = o
200
255
  end
201
256
 
202
257
  end