puree 1.9.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -12
  3. data/Gemfile +1 -1
  4. data/README.md +106 -75
  5. data/lib/puree/extractor/conference_paper.rb +6 -14
  6. data/lib/puree/extractor/dataset.rb +5 -41
  7. data/lib/puree/extractor/doctoral_thesis.rb +5 -6
  8. data/lib/puree/extractor/event.rb +6 -14
  9. data/lib/puree/extractor/external_organisation.rb +5 -8
  10. data/lib/puree/extractor/extractor.rb +19 -0
  11. data/lib/puree/extractor/journal.rb +5 -9
  12. data/lib/puree/extractor/journal_article.rb +6 -15
  13. data/lib/puree/extractor/masters_thesis.rb +5 -6
  14. data/lib/puree/extractor/organisational_unit.rb +25 -0
  15. data/lib/puree/extractor/paper.rb +6 -11
  16. data/lib/puree/extractor/person.rb +4 -53
  17. data/lib/puree/extractor/project.rb +5 -28
  18. data/lib/puree/extractor/publisher.rb +5 -12
  19. data/lib/puree/extractor/research_output.rb +20 -0
  20. data/lib/puree/extractor/resource.rb +22 -58
  21. data/lib/puree/extractor/thesis.rb +6 -17
  22. data/lib/puree/model/conference_paper.rb +1 -1
  23. data/lib/puree/model/dataset.rb +8 -25
  24. data/lib/puree/model/event.rb +0 -9
  25. data/lib/puree/model/external_organisation.rb +1 -1
  26. data/lib/puree/model/external_organisation_header.rb +2 -19
  27. data/lib/puree/model/identifier.rb +26 -0
  28. data/lib/puree/model/journal.rb +1 -1
  29. data/lib/puree/model/journal_article.rb +1 -4
  30. data/lib/puree/model/model.rb +43 -0
  31. data/lib/puree/model/{organisation_header.rb → organisation_header_base.rb} +2 -2
  32. data/lib/puree/model/{organisation.rb → organisational_unit.rb} +3 -6
  33. data/lib/puree/model/organisational_unit_header.rb +9 -0
  34. data/lib/puree/model/paper.rb +10 -1
  35. data/lib/puree/model/person.rb +3 -9
  36. data/lib/puree/model/project.rb +7 -14
  37. data/lib/puree/model/publication_status.rb +1 -1
  38. data/lib/puree/model/publisher.rb +3 -0
  39. data/lib/puree/model/publisher_header.rb +9 -0
  40. data/lib/puree/model/{publication.rb → research_output.rb} +18 -20
  41. data/lib/puree/model/research_output_scopus_metric.rb +26 -0
  42. data/lib/puree/model/resource.rb +19 -11
  43. data/lib/puree/model/thesis.rb +6 -3
  44. data/lib/puree/rest/activity.rb +24 -0
  45. data/lib/puree/rest/application.rb +24 -0
  46. data/lib/puree/rest/base.rb +131 -0
  47. data/lib/puree/rest/classification_scheme.rb +24 -0
  48. data/lib/puree/rest/client.rb +105 -0
  49. data/lib/puree/rest/curricula_vitae.rb +24 -0
  50. data/lib/puree/rest/dataset.rb +24 -0
  51. data/lib/puree/rest/equipment.rb +24 -0
  52. data/lib/puree/rest/event.rb +24 -0
  53. data/lib/puree/rest/external_organisation.rb +24 -0
  54. data/lib/puree/rest/external_person.rb +24 -0
  55. data/lib/puree/rest/impact.rb +24 -0
  56. data/lib/puree/rest/journal.rb +24 -0
  57. data/lib/puree/rest/mixins/active_mixin.rb +14 -0
  58. data/lib/puree/rest/mixins/activity_mixin.rb +14 -0
  59. data/lib/puree/rest/mixins/application_mixin.rb +15 -0
  60. data/lib/puree/rest/mixins/award_mixin.rb +15 -0
  61. data/lib/puree/rest/mixins/dataset_mixin.rb +15 -0
  62. data/lib/puree/rest/mixins/former_mixin.rb +14 -0
  63. data/lib/puree/rest/mixins/impact_mixin.rb +15 -0
  64. data/lib/puree/rest/mixins/person_mixin.rb +15 -0
  65. data/lib/puree/rest/mixins/press_media_mixin.rb +15 -0
  66. data/lib/puree/rest/mixins/prize_mixin.rb +15 -0
  67. data/lib/puree/rest/mixins/project_mixin.rb +15 -0
  68. data/lib/puree/rest/mixins/research_output_mixin.rb +15 -0
  69. data/lib/puree/rest/mixins/student_thesis_mixin.rb +15 -0
  70. data/lib/puree/rest/organisational_unit.rb +51 -0
  71. data/lib/puree/rest/person.rb +58 -0
  72. data/lib/puree/rest/press_media.rb +24 -0
  73. data/lib/puree/rest/prize.rb +24 -0
  74. data/lib/puree/rest/project.rb +27 -0
  75. data/lib/puree/rest/publisher.rb +31 -0
  76. data/lib/puree/rest/research_output.rb +24 -0
  77. data/lib/puree/rest/rest.rb +30 -0
  78. data/lib/puree/util/util.rb +3 -0
  79. data/lib/puree/version.rb +1 -1
  80. data/lib/puree/xml_extractor/base.rb +6 -6
  81. data/lib/puree/xml_extractor/collection.rb +112 -19
  82. data/lib/puree/xml_extractor/conference_paper.rb +9 -2
  83. data/lib/puree/xml_extractor/dataset.rb +56 -166
  84. data/lib/puree/xml_extractor/doctoral_thesis.rb +1 -1
  85. data/lib/puree/xml_extractor/event.rb +16 -19
  86. data/lib/puree/xml_extractor/external_organisation.rb +14 -5
  87. data/lib/puree/xml_extractor/journal.rb +18 -8
  88. data/lib/puree/xml_extractor/journal_article.rb +24 -11
  89. data/lib/puree/xml_extractor/masters_thesis.rb +1 -1
  90. data/lib/puree/xml_extractor/mixins/abstract_mixin.rb +17 -0
  91. data/lib/puree/xml_extractor/mixins/description_mixin.rb +17 -0
  92. data/lib/puree/xml_extractor/mixins/{external_organisations_mixin.rb → external_organisation_mixin.rb} +2 -2
  93. data/lib/puree/xml_extractor/mixins/identifier_mixin.rb +25 -0
  94. data/lib/puree/xml_extractor/mixins/keyword_mixin.rb +21 -0
  95. data/lib/puree/xml_extractor/mixins/organisational_unit_mixin.rb +18 -0
  96. data/lib/puree/xml_extractor/mixins/owner_mixin.rb +18 -0
  97. data/lib/puree/xml_extractor/mixins/peer_reviewed_mixin.rb +1 -1
  98. data/lib/puree/xml_extractor/mixins/person_mixin.rb +45 -0
  99. data/lib/puree/xml_extractor/mixins/publisher_mixin.rb +22 -0
  100. data/lib/puree/xml_extractor/mixins/{associated_mixin.rb → research_output_mixin.rb} +7 -7
  101. data/lib/puree/xml_extractor/mixins/title_mixin.rb +17 -0
  102. data/lib/puree/xml_extractor/mixins/type_mixin.rb +17 -0
  103. data/lib/puree/xml_extractor/mixins/workflow_mixin.rb +17 -0
  104. data/lib/puree/xml_extractor/organisational_unit.rb +82 -0
  105. data/lib/puree/xml_extractor/paper.rb +17 -3
  106. data/lib/puree/xml_extractor/person.rb +30 -35
  107. data/lib/puree/xml_extractor/project.rb +39 -75
  108. data/lib/puree/xml_extractor/publisher.rb +15 -6
  109. data/lib/puree/xml_extractor/research_output.rb +189 -0
  110. data/lib/puree/xml_extractor/resource.rb +28 -36
  111. data/lib/puree/xml_extractor/shared.rb +12 -9
  112. data/lib/puree/xml_extractor/thesis.rb +29 -15
  113. data/lib/puree/xml_extractor/xml_extractor.rb +43 -0
  114. data/lib/puree.rb +5 -114
  115. data/puree.gemspec +1 -1
  116. data/test/extractor/resource_test.rb +103 -0
  117. data/test/rest/base_test.rb +45 -0
  118. data/test/rest/common_test.rb +44 -0
  119. data/test/test_extractor_helper.rb +1 -0
  120. data/test/test_helper.rb +17 -0
  121. data/test/test_rest_helper.rb +82 -0
  122. data/test/test_xml_extractor_helper.rb +17 -0
  123. data/test/xml_extractor/xml_extractor_collection_test.rb +120 -0
  124. data/test/xml_extractor/xml_extractor_conference_paper_test.rb +69 -0
  125. data/test/xml_extractor/xml_extractor_dataset_test.rb +156 -0
  126. data/test/xml_extractor/xml_extractor_event_test.rb +58 -0
  127. data/test/xml_extractor/xml_extractor_external_organisation_test.rb +49 -0
  128. data/test/xml_extractor/xml_extractor_journal_article_test.rb +66 -0
  129. data/test/xml_extractor/xml_extractor_journal_test.rb +53 -0
  130. data/test/xml_extractor/xml_extractor_organisation_test.rb +80 -0
  131. data/test/xml_extractor/xml_extractor_person_test.rb +88 -0
  132. data/test/xml_extractor/xml_extractor_project_test.rb +136 -0
  133. data/test/xml_extractor/xml_extractor_publisher_test.rb +49 -0
  134. data/test/xml_extractor/xml_extractor_research_output_test.rb +214 -0
  135. data/test/xml_extractor/xml_extractor_thesis_test.rb +80 -0
  136. metadata +105 -68
  137. data/lib/puree/api/api.rb +0 -9
  138. data/lib/puree/api/authentication.rb +0 -33
  139. data/lib/puree/api/configuration.rb +0 -43
  140. data/lib/puree/api/map.rb +0 -80
  141. data/lib/puree/api/person_request.rb +0 -64
  142. data/lib/puree/api/request.rb +0 -119
  143. data/lib/puree/extractor/collection.rb +0 -131
  144. data/lib/puree/extractor/download.rb +0 -71
  145. data/lib/puree/extractor/organisation.rb +0 -34
  146. data/lib/puree/extractor/paper_base.rb +0 -28
  147. data/lib/puree/extractor/publication.rb +0 -53
  148. data/lib/puree/extractor/server.rb +0 -56
  149. data/lib/puree/model/download_header.rb +0 -21
  150. data/lib/puree/model/paper_base.rb +0 -19
  151. data/lib/puree/model/server.rb +0 -13
  152. data/lib/puree/query/funding.rb +0 -54
  153. data/lib/puree/query/person.rb +0 -121
  154. data/lib/puree/query/query.rb +0 -6
  155. data/lib/puree/xml_extractor/download.rb +0 -42
  156. data/lib/puree/xml_extractor/mixins/workflow_state_mixin.rb +0 -18
  157. data/lib/puree/xml_extractor/organisation.rb +0 -75
  158. data/lib/puree/xml_extractor/paper_base.rb +0 -17
  159. data/lib/puree/xml_extractor/publication.rb +0 -257
  160. data/lib/puree/xml_extractor/server.rb +0 -32
  161. data/spec/download_http_spec.rb +0 -31
  162. data/spec/open_api_dataset_http_spec.rb +0 -15
  163. data/spec/query/funding_http_spec.rb +0 -29
  164. data/spec/query/person_http_spec.rb +0 -52
  165. data/spec/resource/collection_all_http_spec.rb +0 -77
  166. data/spec/resource/collection_http_spec.rb +0 -65
  167. data/spec/resource/dataset_http_spec.rb +0 -112
  168. data/spec/resource/event_http_spec.rb +0 -52
  169. data/spec/resource/journal_http_spec.rb +0 -36
  170. data/spec/resource/organisation_http_spec.rb +0 -52
  171. data/spec/resource/person_http_spec.rb +0 -60
  172. data/spec/resource/project_http_spec.rb +0 -89
  173. data/spec/resource/publication_http_spec.rb +0 -126
  174. data/spec/resource/publisher_http_spec.rb +0 -26
  175. data/spec/server_http_spec.rb +0 -26
  176. data/spec/spec_helper.rb +0 -159
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62a7e0f61a351c75ad89d9e02351a86b7a3d7db9
4
- data.tar.gz: 40ba45ce2fd4edbdf7805a4da9e0523141313d60
3
+ metadata.gz: 68e9bc6b3031be78761029cf76f9a2d0ca19dc83
4
+ data.tar.gz: c25c6ba1167ee3b477c58bf1e1f1b0774fb9b410
5
5
  SHA512:
6
- metadata.gz: 8e3c77f6f00e25b2a637c3ec501d4ba7e9794878c6bafc3b9db2a1624a138275648d4a82308d3fb7981bfefc3c016f790e1bc64bb645e3bb37b2dd8ffc2b27b7
7
- data.tar.gz: 21dbbb1df2d1869f492b6acf1e5f7458c72ff32cd58c79f790af7dc98a43f18b760a0a91186ddfe632e0e9ad42534f091fc2966ee0b911ace957ad91db0508ad
6
+ metadata.gz: e09b12ccea6749fe4904031d366c38eb677f4a4b653f7a5d8f1ac2139cdb56db97cacd183db9b4beb3cfb2c4a49a05a1bd27d337f5f3dd98301a44e9aa6617e9
7
+ data.tar.gz: 23b257d617b8f47802ec213b592b75b15fc9132058c5299761c30291e1739353e149db0e1bf5580beee55a51f5d3bad255e1376d48318480c565c6dd4932ec57
data/CHANGELOG.md CHANGED
@@ -2,20 +2,13 @@
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
- ## Unreleased
6
- - Metadata: activity?, clipping?, externalPerson?
7
-
8
- ## 1.9.1 - 2018-04-18
9
- ### Fixed
10
- - Handle missing created and modified.
11
-
12
- ## 1.9.0 - 2018-03-09
13
- ### Added
14
- - Publication - doi.
5
+ ## 2.0.0 - 2017-12-19
6
+ ### Changed
7
+ - For Pure API 59.
15
8
 
16
- ## 1.8.0 - 2018-03-02
17
9
  ### Added
18
- - Publication - Scopus id.
10
+ - Independent modules: REST, Extractor, XMLExtractor
11
+ - Testing against known live data.
19
12
 
20
13
  ## 1.7.0 - 2017-11-03
21
14
  ### Added
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in puree.gemspec
4
- gemspec
4
+ gemspec
data/README.md CHANGED
@@ -5,10 +5,7 @@ Metadata extraction from the Pure Research Information System.
5
5
  ## Status
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/puree.svg)](https://badge.fury.io/rb/puree)
8
- [![Build Status](https://semaphoreci.com/api/v1/aalbinclark/puree/branches/master/badge.svg)](https://semaphoreci.com/aalbinclark/puree)
9
- [![Code Climate](https://codeclimate.com/github/lulibrary/puree/badges/gpa.svg)](https://codeclimate.com/github/lulibrary/puree)
10
- [![Dependency Status](https://www.versioneye.com/user/projects/5899d253a86053003f389e1f/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/5899d253a86053003f389e1f)
11
- [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/lulibrary/puree)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/0a0a8249dcadb444eb9e/maintainability)](https://codeclimate.com/github/lulibrary/puree/maintainability)
12
9
 
13
10
  ## Installation
14
11
 
@@ -24,130 +21,164 @@ Or install it yourself as:
24
21
 
25
22
  $ gem install puree
26
23
 
27
-
28
- ## Usage
29
- The following examples are for the Dataset resource type.
30
-
31
- ### Configuration
32
-
33
- Create a hash for passing to an extractor.
34
-
35
- ```ruby
36
- # Pure host with authentication.
37
- config = {
38
- url: ENV['PURE_URL'],
39
- username: ENV['PURE_USERNAME'],
40
- password: ENV['PURE_PASSWORD']
41
- }
42
- ```
43
-
24
+ ## Configuration
44
25
  ```ruby
45
- # Pure host without authentication.
26
+ # For Extractor and REST modules.
46
27
  config = {
47
- url: ENV['PURE_URL']
28
+ url: 'https://YOUR_HOST/ws/api/59',
29
+ username: 'YOUR_USERNAME',
30
+ password: 'YOUR_PASSWORD',
31
+ api_key: 'YOUR_API_KEY'
48
32
  }
49
33
  ```
50
34
 
51
- ### Resource
52
-
53
- Configure an extractor to retrieve data from a Pure host.
35
+ ## Extractor module
36
+ Find a resource by identifier and get Ruby objects.
54
37
 
55
38
  ```ruby
56
- dataset_extractor = Puree::Extractor::Dataset.new config
39
+ # Configure an extractor
40
+ extractor = Puree::Extractor::Dataset.new config
57
41
  ```
58
42
 
59
- Fetch the metadata for a resource with a particular identifier.
60
-
61
43
  ```ruby
62
- dataset = dataset_extractor.find uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
63
- # =>
64
- #<Puree::Model::Dataset:0x987f7a4>
44
+ # Fetch the metadata for a resource with a particular identifier
45
+ dataset = extractor.find 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
46
+ #=> #<Puree::Model::Dataset:0x00c0ffee>
65
47
  ```
66
48
 
67
- Access specific metadata e.g. an internal person's name.
68
-
69
49
  ```ruby
50
+ # Access specific metadata e.g. an internal person's name
70
51
  dataset.persons_internal[0].name
71
- # =>
72
- #<Puree::Model::PersonName:0x9add67c @first="Foo", @last="Bar">
52
+ #=> #<Puree::Model::PersonName:0x00c0ffee @first="Foo", @last="Bar">
73
53
  ```
74
54
 
75
- Select a formatting style for a person's name.
76
-
77
55
  ```ruby
56
+ # Select a formatting style for a person's name
78
57
  dataset.persons_internal[0].name.last_initial
79
- # =>
80
- # "Bar, F."
58
+ #=> "Bar, F."
81
59
  ```
82
60
 
83
- ### Collection
61
+ ## XMLExtractor module
62
+ Get Ruby objects from Pure XML.
84
63
 
85
- Configure a collection extractor to retrieve data from a Pure host.
64
+ ### Single resource
65
+ ```ruby
66
+ xml = '<project> ... </project>'
67
+ ```
86
68
 
87
69
  ```ruby
88
- collection_extractor = Puree::Extractor::Collection.new config: config,
89
- resource: :dataset
70
+ # Configure an XML extractor
71
+ xml_extractor = Puree::XMLExtractor::Project.new xml
90
72
  ```
91
73
 
92
- Fetch a bunch of resources.
74
+ ```ruby
75
+ # Get a single piece of metadata
76
+ xml_extractor.title
77
+ #=> "An interesting project title"
78
+ ```
93
79
 
94
80
  ```ruby
95
- collection_extractor.find limit: 2
96
- # =>
97
- #<Puree::Model::Dataset:0xa62fd90>
98
- #<Puree::Model::Dataset:0xa5e8c24>
81
+ # Get all the metadata together
82
+ xml_extractor.model
83
+ #=> #<Puree::Model::Project:0x00c0ffee>
99
84
  ```
100
85
 
101
- Fetch a random resource from the entire collection.
86
+ ### Homogeneous resource collection
87
+ ```ruby
88
+ xml = '<result>
89
+ <dataSet> ... </dataSet>
90
+ <dataSet> ... </dataSet>
91
+ ...
92
+ </result>'
93
+ ```
102
94
 
103
95
  ```ruby
104
- collection_extractor.random_resource
105
- # =>
106
- #<Puree::Model::Dataset:0x97998bc>
96
+ # Get an array of datasets
97
+ Puree::XMLExtractor::Collection.datasets xml
98
+ #=> [#<Puree::Model::Dataset:0x00c0ffee>, ...]
107
99
  ```
108
100
 
109
- ### Query
101
+ ### Heterogeneous resource collection
102
+ ```ruby
103
+ xml = '<result>
104
+ <contributionToJournal> ... </contributionToJournal>
105
+ <contributionToConference> ... </contributionToConference>
106
+ ...
107
+ </result>'
108
+ ```
110
109
 
111
- Get answers to important questions.
110
+ ```ruby
111
+ # Get a hash of research outputs
112
+ Puree::XMLExtractor::Collection.research_outputs xml
113
+ #=> {
114
+ # journal_articles: [#<Puree::Model::JournalArticle:0x00c0ffee>, ...],
115
+ # conference_papers: [#<Puree::Model::ConferencePaper:0x00c0ffee>, ...],
116
+ # theses: [#<Puree::Model::Thesis:0x00c0ffee>, ...],
117
+ # other: [#<Puree::Model::ResearchOutput:0x00c0ffee>, ...]
118
+ # }
119
+ ```
112
120
 
113
- #### Funding
121
+ ## REST module
122
+ Query the Pure REST API.
114
123
 
115
- Configure a funding query to retrieve data from a Pure host.
124
+ ### Client
125
+ ```ruby
126
+ # Configure a client
127
+ client = Puree::REST::Client.new config
128
+ ```
116
129
 
117
130
  ```ruby
118
- funding_query = Puree::Query::Funding.new config
131
+ # Find a person
132
+ client.persons.find id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
133
+ #=> #<HTTP::Response:0x00c0ffee>
119
134
  ```
120
135
 
121
- Who are the funders (if any) for a project?
136
+ ```ruby
137
+ # Find a person, limit the metadata to ORCID and employee start date
138
+ client.persons.find id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
139
+ params: {fields: ['orcid', 'employeeStartDate']}
140
+ #=> #<HTTP::Response:0x00c0ffee>
141
+ ```
122
142
 
123
143
  ```ruby
124
- funding_query.project_funders uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
125
- # =>
126
- #<Puree::Model::ExternalOrganisation:0x98986f0>
144
+ # Find five people, response body as JSON
145
+ client.persons.all params: {size: 5}, accept: :json
146
+ #=> #<HTTP::Response:0x00c0ffee>
127
147
  ```
128
148
 
129
- Who are the funders (if any) for a publication?
149
+ ```ruby
150
+ # Find research outputs for a person
151
+ client.persons.research_outputs id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
152
+ #=> #<HTTP::Response:0x00c0ffee>
153
+ ```
130
154
 
155
+ ### Resource
131
156
  ```ruby
132
- funding_query.publication_funders uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
157
+ # Configure a resource
158
+ persons = Puree::REST::Person.new config
133
159
  ```
134
160
 
135
- #### Person
161
+ ```ruby
162
+ # Find a person
163
+ persons.find id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
164
+ #=> #<HTTP::Response:0x00c0ffee>
165
+ ```
136
166
 
137
- Configure a person query to retrieve data from a Pure host.
167
+ ## REST module with XMLExtractor module
168
+ Query the Pure REST API and get Ruby objects from Pure XML.
138
169
 
139
170
  ```ruby
140
- person_query = Puree::Query::Person.new config
171
+ # Configure a client
172
+ client = Puree::REST::Client.new config
141
173
  ```
142
174
 
143
- Get at most ten publications published by a person during the first six months of 2017.
175
+ ```ruby
176
+ # Find projects for a person
177
+ response = client.persons.projects id: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
178
+ ```
144
179
 
145
180
  ```ruby
146
- person_query.publications uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx',
147
- limit: 10,
148
- published_start: '2017-01-01',
149
- published_end: '2017-06-30'
150
- # =>
151
- #<Puree::Model::Publication:0x9d2c004>
152
- #<Puree::Model::Publication:0xa285028>
181
+ # Extract metadata from XML
182
+ Puree::XMLExtractor::Collection.projects response.to_s
183
+ #=> [#<Puree::Model::Project:0x00c0ffee>, ...]
153
184
  ```
@@ -3,21 +3,13 @@ module Puree
3
3
 
4
4
  # Conference paper extractor.
5
5
  #
6
- class ConferencePaper < Puree::Extractor::PaperBase
6
+ class ConferencePaper < Puree::Extractor::Paper
7
7
 
8
- # @option (see Puree::Extractor::Resource#initialize)
9
- def initialize(config)
10
- set_model_type 'conference_paper'
11
- super
12
- end
13
-
14
- private
15
-
16
- def combine_metadata
17
- super
18
-
19
- @model.event = @extractor.event
20
- @model
8
+ # @param id [String]
9
+ def find(id)
10
+ find_and_extract id: id,
11
+ api_resource_type: :research_output,
12
+ xml_extractor_resource_type: :conference_paper
21
13
  end
22
14
 
23
15
  end
@@ -9,49 +9,13 @@ module Puree
9
9
  # @option (see Puree::Extractor::Resource#initialize)
10
10
  def initialize(config)
11
11
  super
12
- setup :dataset
13
12
  end
14
13
 
15
- private
16
-
17
- def combine_metadata
18
- super
19
- @model.access = @extractor.access
20
- @model.associated = @extractor.associated
21
- @model.available = @extractor.available
22
- @model.description = @extractor.description
23
- @model.doi = @extractor.doi
24
- @model.files = @extractor.files
25
- @model.keywords = @extractor.keywords
26
- @model.links = @extractor.links
27
- @model.legal_conditions = @extractor.legal_conditions
28
- @model.organisations = @extractor.organisations
29
- @model.owner = @extractor.owner
30
- @model.persons_internal = @extractor.persons_internal
31
- @model.persons_external = @extractor.persons_external
32
- @model.persons_other = @extractor.persons_other
33
- @model.projects = @extractor.projects
34
- @model.production = @extractor.production
35
- @model.publications = @extractor.publications
36
- @model.publisher = @extractor.publisher
37
- @model.spatial_places = @extractor.spatial_places
38
- @model.spatial_point = @extractor.spatial_point
39
- @model.temporal = @extractor.temporal
40
- @model.title = @extractor.title
41
- @model.workflow_state = @extractor.workflow_state
42
- @model
43
- end
44
-
45
- def configure_api(config)
46
- @config = Puree::API::Configuration.new url: config[:url]
47
- @config.basic_auth username: config[:username],
48
- password: config[:password]
49
-
50
- @request = Puree::API::PersonRequest.new url: @config.url
51
- if @config.basic_auth?
52
- @request.basic_auth username: @config.username,
53
- password: @config.password
54
- end
14
+ # @param id [String]
15
+ def find(id)
16
+ find_and_extract id: id,
17
+ api_resource_type: :dataset,
18
+ xml_extractor_resource_type: :dataset
55
19
  end
56
20
 
57
21
  end
@@ -7,15 +7,14 @@ module Puree
7
7
 
8
8
  # @option (see Puree::Extractor::Resource#initialize)
9
9
  def initialize(config)
10
- set_model_type 'doctoral_thesis'
11
10
  super
12
11
  end
13
12
 
14
- private
15
-
16
- def combine_metadata
17
- super
18
- @model.type === 'Doctoral Thesis' ? @model : nil
13
+ # @param id [String]
14
+ def find(id)
15
+ find_and_extract id: id,
16
+ api_resource_type: :research_output,
17
+ xml_extractor_resource_type: :doctoral_thesis
19
18
  end
20
19
 
21
20
  end
@@ -9,21 +9,13 @@ module Puree
9
9
  # @option (see Puree::Extractor::Resource#initialize)
10
10
  def initialize(config)
11
11
  super
12
- setup :event
13
- end
14
-
15
- private
12
+ end
16
13
 
17
- def combine_metadata
18
- super
19
- @model.city = @extractor.city
20
- @model.country = @extractor.country
21
- @model.date = @extractor.date
22
- @model.description = @extractor.description
23
- @model.location = @extractor.location
24
- @model.title = @extractor.title
25
- @model.type = @extractor.type
26
- @model
14
+ # @param id [String]
15
+ def find(id)
16
+ find_and_extract id: id,
17
+ api_resource_type: :event,
18
+ xml_extractor_resource_type: :event
27
19
  end
28
20
 
29
21
  end
@@ -9,16 +9,13 @@ module Puree
9
9
  # @option (see Puree::Extractor::Resource#initialize)
10
10
  def initialize(config)
11
11
  super
12
- setup :external_organisation
13
12
  end
14
13
 
15
- private
16
-
17
- def combine_metadata
18
- super
19
- @model.name = @extractor.name
20
- @model.type = @extractor.type
21
- @model
14
+ # @param id [String]
15
+ def find(id)
16
+ find_and_extract id: id,
17
+ api_resource_type: :external_organisation,
18
+ xml_extractor_resource_type: :external_organisation
22
19
  end
23
20
 
24
21
  end
@@ -1,3 +1,22 @@
1
+ require 'puree/extractor/resource'
2
+ require 'puree/extractor/dataset'
3
+ require 'puree/extractor/event'
4
+ require 'puree/extractor/external_organisation'
5
+ require 'puree/extractor/journal'
6
+ require 'puree/extractor/organisational_unit'
7
+ require 'puree/extractor/person'
8
+ require 'puree/extractor/project'
9
+
10
+ require 'puree/extractor/research_output'
11
+ require 'puree/extractor/thesis'
12
+ require 'puree/extractor/doctoral_thesis'
13
+ require 'puree/extractor/masters_thesis'
14
+ require 'puree/extractor/journal_article'
15
+ require 'puree/extractor/paper'
16
+ require 'puree/extractor/conference_paper'
17
+
18
+ require 'puree/extractor/publisher'
19
+
1
20
  module Puree
2
21
 
3
22
  # An Extractor manages HTTP requests to Pure and the subsequent
@@ -9,17 +9,13 @@ module Puree
9
9
  # @option (see Puree::Extractor::Resource#initialize)
10
10
  def initialize(config)
11
11
  super
12
- setup :journal
13
12
  end
14
13
 
15
- private
16
-
17
- def combine_metadata
18
- super
19
- @model.issn = @extractor.issn
20
- @model.publisher = @extractor.publisher
21
- @model.title = @extractor.title
22
- @model
14
+ # @param id [String]
15
+ def find(id)
16
+ find_and_extract id: id,
17
+ api_resource_type: :journal,
18
+ xml_extractor_resource_type: :journal
23
19
  end
24
20
 
25
21
  end
@@ -3,27 +3,18 @@ module Puree
3
3
 
4
4
  # Journal article extractor.
5
5
  #
6
- class JournalArticle < Puree::Extractor::Publication
6
+ class JournalArticle < Puree::Extractor::ResearchOutput
7
7
 
8
8
  # @option (see Puree::Extractor::Resource#initialize)
9
9
  def initialize(config)
10
- set_model_type 'journal_article'
11
10
  super
12
11
  end
13
12
 
14
- private
15
-
16
- def combine_metadata
17
- super
18
-
19
- @model.article_number = @extractor.article_number
20
- @model.issue = @extractor.issue
21
- @model.journal = @extractor.journal
22
- @model.pages = @extractor.pages
23
- @model.page_range = @extractor.page_range
24
- @model.peer_reviewed = @extractor.peer_reviewed
25
- @model.volume = @extractor.volume
26
- @model
13
+ # @param id [String]
14
+ def find(id)
15
+ find_and_extract id: id,
16
+ api_resource_type: :research_output,
17
+ xml_extractor_resource_type: :journal_article
27
18
  end
28
19
 
29
20
  end
@@ -7,15 +7,14 @@ module Puree
7
7
 
8
8
  # @option (see Puree::Extractor::Resource#initialize)
9
9
  def initialize(config)
10
- set_model_type 'masters_thesis'
11
10
  super
12
11
  end
13
12
 
14
- private
15
-
16
- def combine_metadata
17
- super
18
- @model.type === "Master's Thesis" ? @model : nil
13
+ # @param id [String]
14
+ def find(id)
15
+ find_and_extract id: id,
16
+ api_resource_type: :research_output,
17
+ xml_extractor_resource_type: :masters_thesis
19
18
  end
20
19
 
21
20
  end
@@ -0,0 +1,25 @@
1
+ module Puree
2
+
3
+ module Extractor
4
+
5
+ # Organisational unit extractor.
6
+ #
7
+ class OrganisationalUnit < Puree::Extractor::Resource
8
+
9
+ # @option (see Puree::Extractor::Resource#initialize)
10
+ def initialize(config)
11
+ super
12
+ end
13
+
14
+ # @param id [String]
15
+ def find(id)
16
+ find_and_extract id: id,
17
+ api_resource_type: :organisational_unit,
18
+ xml_extractor_resource_type: :organisational_unit
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -3,18 +3,13 @@ module Puree
3
3
 
4
4
  # Paper extractor.
5
5
  #
6
- class Paper < Puree::Extractor::PaperBase
6
+ class Paper < Puree::Extractor::ResearchOutput
7
7
 
8
- # @option (see Puree::Extractor::Resource#initialize)
9
- def initialize(config)
10
- set_model_type 'paper'
11
- super
12
- end
13
-
14
- private
15
-
16
- def combine_metadata
17
- super
8
+ # @param id [String]
9
+ def find(id)
10
+ find_and_extract id: id,
11
+ api_resource_type: :research_output,
12
+ xml_extractor_resource_type: :paper
18
13
  end
19
14
 
20
15
  end
@@ -6,60 +6,11 @@ module Puree
6
6
  #
7
7
  class Person < Puree::Extractor::Resource
8
8
 
9
- # @option (see Puree::Extractor::Resource#initialize)
10
- def initialize(config)
11
- super
12
- setup :person
13
- end
14
-
15
- # Find a person by identifier.
16
- #
17
- # @param uuid [String]
18
9
  # @param id [String]
19
- # @param employee_id [String]
20
- # @return [Puree::Model::Person]
21
- def find_by_id(uuid: nil, id: nil, employee_id: nil)
22
- raise 'Cannot perform a request without a configuration' if @config.nil?
23
- @response = @request.get uuid: uuid,
24
- id: id,
25
- employee_id: employee_id,
26
- latest_api: @latest_api,
27
- resource_type: @resource_type
28
- set_content @response.body
29
- end
30
-
31
- private
32
-
33
- def combine_metadata
34
- super
35
- @model.affiliations = @extractor.affiliations
36
- @model.email_addresses = @extractor.email_addresses
37
- @model.employee_id = @extractor.employee_id
38
- @model.hesa_id = @extractor.hesa_id
39
- @model.image_urls = @extractor.image_urls
40
- @model.keywords = @extractor.keywords
41
- @model.name = @extractor.name
42
- @model.orcid = @extractor.orcid
43
- @model.scopus_id = @extractor.scopus_id
44
- @model
45
- end
46
-
47
- # Configure a Pure host for API access.
48
- #
49
- # @param config [Hash]
50
- # @option config [String] :url The URL of the Pure host.
51
- # @option config [String] :username The username of the Pure host account.
52
- # @option config [String] :password The password of the Pure host account.
53
- def configure_api(config)
54
- @config = Puree::API::Configuration.new url: config[:url]
55
- @config.basic_auth username: config[:username],
56
- password: config[:password]
57
-
58
- @request = Puree::API::PersonRequest.new url: @config.url
59
- if @config.basic_auth?
60
- @request.basic_auth username: @config.username,
61
- password: @config.password
62
- end
10
+ def find(id)
11
+ find_and_extract id: id,
12
+ api_resource_type: :person,
13
+ xml_extractor_resource_type: :person
63
14
  end
64
15
 
65
16
  end