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
@@ -0,0 +1,14 @@
1
+ module Puree
2
+ module REST
3
+ module ActiveMixin
4
+
5
+ # (see Puree::REST::Base#all)
6
+ def active(params: {}, accept: :xml)
7
+ get_request_collection_subcollection(subcollection: 'active',
8
+ params: params,
9
+ accept: accept)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Puree
2
+ module REST
3
+ module ActivityMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def activities(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'activities',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module ApplicationMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def applications(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'applications',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module AwardMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def awards(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'awards',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module DatasetMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def datasets(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'datasets',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ module Puree
2
+ module REST
3
+ module FormerMixin
4
+
5
+ # (see Puree::REST::Base#all)
6
+ def former(params: {}, accept: :xml)
7
+ get_request_collection_subcollection(subcollection: 'former',
8
+ params: params,
9
+ accept: accept)
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module ImpactMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def impacts(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'impacts',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module PersonMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def persons(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'persons',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module PressMediaMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def press_media(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'press-media',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module PrizeMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def prizes(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'prizes',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module ProjectMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def projects(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'projects',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module ResearchOutputMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def research_outputs(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'research-outputs',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module REST
3
+ module StudentThesisMixin
4
+
5
+ # (see Puree::REST::Base#find)
6
+ def student_theses(id:, params: {}, accept: :xml)
7
+ get_request_singleton_subcollection(id: id,
8
+ subcollection: 'student-theses',
9
+ params: params,
10
+ accept: accept)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,51 @@
1
+ require 'puree/rest/mixins/active_mixin'
2
+ require 'puree/rest/mixins/activity_mixin'
3
+ require 'puree/rest/mixins/application_mixin'
4
+ require 'puree/rest/mixins/award_mixin'
5
+ require 'puree/rest/mixins/dataset_mixin'
6
+ require 'puree/rest/mixins/former_mixin'
7
+ require 'puree/rest/mixins/impact_mixin'
8
+ require 'puree/rest/mixins/person_mixin'
9
+ require 'puree/rest/mixins/press_media_mixin'
10
+ require 'puree/rest/mixins/prize_mixin'
11
+ require 'puree/rest/mixins/project_mixin'
12
+ require 'puree/rest/mixins/research_output_mixin'
13
+ require 'puree/rest/mixins/student_thesis_mixin'
14
+
15
+ module Puree
16
+
17
+ module REST
18
+
19
+ # Requests for the Organisational Unit resource
20
+ #
21
+ class OrganisationalUnit < Puree::REST::Base
22
+ include Puree::REST::ActiveMixin
23
+ include Puree::REST::ActivityMixin
24
+ include Puree::REST::ApplicationMixin
25
+ include Puree::REST::AwardMixin
26
+ include Puree::REST::DatasetMixin
27
+ include Puree::REST::FormerMixin
28
+ include Puree::REST::ImpactMixin
29
+ include Puree::REST::PersonMixin
30
+ include Puree::REST::PressMediaMixin
31
+ include Puree::REST::PrizeMixin
32
+ include Puree::REST::ProjectMixin
33
+ include Puree::REST::ResearchOutputMixin
34
+ include Puree::REST::StudentThesisMixin
35
+
36
+ # (see Puree::REST::Base#initialize)
37
+ def initialize(config)
38
+ super
39
+ end
40
+
41
+ private
42
+
43
+ def collection
44
+ 'organisational-units'
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,58 @@
1
+ require 'puree/rest/mixins/active_mixin'
2
+ require 'puree/rest/mixins/activity_mixin'
3
+ require 'puree/rest/mixins/application_mixin'
4
+ require 'puree/rest/mixins/award_mixin'
5
+ require 'puree/rest/mixins/dataset_mixin'
6
+ require 'puree/rest/mixins/former_mixin'
7
+ require 'puree/rest/mixins/impact_mixin'
8
+ require 'puree/rest/mixins/press_media_mixin'
9
+ require 'puree/rest/mixins/prize_mixin'
10
+ require 'puree/rest/mixins/project_mixin'
11
+ require 'puree/rest/mixins/research_output_mixin'
12
+ require 'puree/rest/mixins/student_thesis_mixin'
13
+
14
+ module Puree
15
+
16
+ module REST
17
+
18
+ # Requests for the Person resource
19
+ #
20
+ # @note :id can be UUID, ID, Employee ID or HESA Staff ID
21
+ class Person < Puree::REST::Base
22
+ include Puree::REST::ActiveMixin
23
+ include Puree::REST::ActivityMixin
24
+ include Puree::REST::ApplicationMixin
25
+ include Puree::REST::AwardMixin
26
+ include Puree::REST::DatasetMixin
27
+ include Puree::REST::FormerMixin
28
+ include Puree::REST::ImpactMixin
29
+ include Puree::REST::PressMediaMixin
30
+ include Puree::REST::PrizeMixin
31
+ include Puree::REST::ProjectMixin
32
+ include Puree::REST::ResearchOutputMixin
33
+ include Puree::REST::StudentThesisMixin
34
+
35
+ # (see Puree::REST::Base#initialize)
36
+ def initialize(config)
37
+ super
38
+ end
39
+
40
+ # (see Puree::REST::Base#find)
41
+ def curricula_vitae(id:, params: {}, accept: :xml)
42
+ get_request_singleton_subcollection(id: id,
43
+ subcollection: 'curricula-vitae',
44
+ params: params,
45
+ accept: accept)
46
+ end
47
+
48
+ private
49
+
50
+ def collection
51
+ 'persons'
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,24 @@
1
+ module Puree
2
+
3
+ module REST
4
+
5
+ # Requests for the Press Media resource
6
+ #
7
+ class PressMedia < Puree::REST::Base
8
+
9
+ # (see Puree::REST::Base#initialize)
10
+ def initialize(config)
11
+ super
12
+ end
13
+
14
+ private
15
+
16
+ def collection
17
+ 'press-media'
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,24 @@
1
+ module Puree
2
+
3
+ module REST
4
+
5
+ # Requests for the Prize resource
6
+ #
7
+ class Prize < Puree::REST::Base
8
+
9
+ # (see Puree::REST::Base#initialize)
10
+ def initialize(config)
11
+ super
12
+ end
13
+
14
+ private
15
+
16
+ def collection
17
+ 'prizes'
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'puree/rest/mixins/active_mixin'
2
+
3
+ module Puree
4
+
5
+ module REST
6
+
7
+ # Requests for the Project resource
8
+ #
9
+ class Project < Puree::REST::Base
10
+ include Puree::REST::ActiveMixin
11
+
12
+ # (see Puree::REST::Base#initialize)
13
+ def initialize(config)
14
+ super
15
+ end
16
+
17
+ private
18
+
19
+ def collection
20
+ 'projects'
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,31 @@
1
+ module Puree
2
+
3
+ module REST
4
+
5
+ # Requests for the Publisher resource
6
+ #
7
+ class Publisher < Puree::REST::Base
8
+
9
+ # (see Puree::REST::Base#initialize)
10
+ def initialize(config)
11
+ super
12
+ end
13
+
14
+ # (see Puree::REST::Base#all)
15
+ def approved(params: {}, accept: :xml)
16
+ get_request_collection_subcollection(subcollection: 'approved',
17
+ params: params,
18
+ accept: accept)
19
+ end
20
+
21
+ private
22
+
23
+ def collection
24
+ 'publishers'
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,24 @@
1
+ module Puree
2
+
3
+ module REST
4
+
5
+ # Requests for the Research Output resource
6
+ #
7
+ class ResearchOutput < Puree::REST::Base
8
+
9
+ # (see Puree::REST::Base#initialize)
10
+ def initialize(config)
11
+ super
12
+ end
13
+
14
+ private
15
+
16
+ def collection
17
+ 'research-outputs'
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'http'
2
+
3
+ require 'puree/rest/base'
4
+ require 'puree/rest/activity'
5
+ require 'puree/rest/application'
6
+ require 'puree/rest/classification_scheme'
7
+ require 'puree/rest/curricula_vitae'
8
+ require 'puree/rest/dataset'
9
+ require 'puree/rest/equipment'
10
+ require 'puree/rest/event'
11
+ require 'puree/rest/external_organisation'
12
+ require 'puree/rest/external_person'
13
+ require 'puree/rest/impact'
14
+ require 'puree/rest/journal'
15
+ require 'puree/rest/organisational_unit'
16
+ require 'puree/rest/person'
17
+ require 'puree/rest/press_media'
18
+ require 'puree/rest/prize'
19
+ require 'puree/rest/project'
20
+ require 'puree/rest/publisher'
21
+ require 'puree/rest/research_output'
22
+
23
+ require 'puree/rest/client'
24
+
25
+ module Puree
26
+ # Query the Pure REST API.
27
+ #
28
+ module REST
29
+ end
30
+ end
@@ -1,3 +1,6 @@
1
+ require 'puree/util/date'
2
+ require 'puree/util/string'
3
+
1
4
  module Puree
2
5
 
3
6
  # Utilities.
data/lib/puree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Puree
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "1.9.1"
4
+ VERSION = "2.0.0"
5
5
  end
@@ -6,8 +6,7 @@ module Puree
6
6
  #
7
7
  class Base
8
8
 
9
- def initialize(xml:)
10
- @api_map = Puree::API::Map.new.get
9
+ def initialize(xml)
11
10
  make_doc xml
12
11
  end
13
12
 
@@ -31,15 +30,16 @@ module Puree
31
30
 
32
31
  private
33
32
 
33
+ def setup_model(resource)
34
+ resource_class = "Puree::Model::#{Puree::Util::String.titleize(resource)}"
35
+ @model = Object.const_get(resource_class).new
36
+ end
37
+
34
38
  def make_doc(xml)
35
39
  @doc = Nokogiri::XML xml
36
40
  @doc.remove_namespaces!
37
41
  end
38
42
 
39
- def service_response_name
40
- @api_map[:resource_type][@resource_type][:response]
41
- end
42
-
43
43
  end
44
44
 
45
45
  end
@@ -2,35 +2,128 @@ module Puree
2
2
 
3
3
  module XMLExtractor
4
4
 
5
- # Collection XML extractor.
5
+ # Resource collection XML extractor.
6
6
  #
7
- class Collection < Puree::XMLExtractor::Base
7
+ module Collection
8
8
 
9
- def initialize(xml:)
10
- super
9
+ # Get models from any multi-record dataset XML response
10
+ #
11
+ # @param xml [String]
12
+ # @return [Array<Puree::Model::Dataset>]
13
+ def self.datasets(xml)
14
+ models :dataset, xml, '/dataSet'
15
+ end
16
+
17
+ # Get models from any multi-record event XML response
18
+ #
19
+ # @param xml [String]
20
+ # @return [Array<Puree::Model::Event>]
21
+ def self.events(xml)
22
+ models :event, xml, '/event'
23
+ end
24
+
25
+ # Get models from any multi-record external organisation XML response
26
+ #
27
+ # @param xml [String]
28
+ # @return [Array<Puree::Model::ExternalOrganisation>]
29
+ def self.external_organisations(xml)
30
+ models :external_organisation, xml, '/externalOrganisation'
31
+ end
32
+
33
+ # Get models from any multi-record journal XML response
34
+ #
35
+ # @param xml [String]
36
+ # @return [Array<Puree::Model::Journal>]
37
+ def self.journals(xml)
38
+ models :journal, xml, '/journal'
11
39
  end
12
40
 
13
- # Records available in collection.
41
+ # Get models from any multi-record organisation XML response
14
42
  #
15
- # @return [Fixnum]
16
- def count
17
- @doc.xpath('//count').text.strip.to_i
43
+ # @param xml [String]
44
+ # @return [Array<Puree::Model::OrganisationalUnit>]
45
+ def self.organisational_units(xml)
46
+ models :organisational_unit, xml, '/organisationalUnit'
18
47
  end
19
48
 
20
- # Resource UUIDs in collection response.
49
+ # Get models from any multi-record project XML response
50
+ #
51
+ # @param xml [String]
52
+ # @return [Array<Puree::Model::Project>]
53
+ def self.projects(xml)
54
+ models :project, xml, '/project'
55
+ end
56
+
57
+ # Get models from any multi-record person XML response
58
+ #
59
+ # @param xml [String]
60
+ # @return [Array<Puree::Model::Person>]
61
+ def self.persons(xml)
62
+ models :person, xml, '/person'
63
+ end
64
+
65
+ # Get models from any multi-record Research output XML response
66
+ #
67
+ # @param xml [String]
68
+ # @return [Hash{Symbol => Array<Puree::Model::ResearchOutput class/subclass>}]
69
+ def self.research_outputs(xml)
70
+ path_from_root = File.join 'result', '/*'
71
+ doc = Nokogiri::XML xml
72
+ doc.remove_namespaces!
73
+ xpath_result = doc.xpath path_from_root
74
+ data = {
75
+ journal_articles: [],
76
+ conference_papers: [],
77
+ theses: [],
78
+ other: []
79
+ }
80
+ xpath_result.each do |research_output|
81
+ type = research_output.xpath('type').text.strip
82
+ unless type.empty?
83
+ case type
84
+ when 'Journal article'
85
+ extractor = Puree::XMLExtractor::JournalArticle.new research_output.to_s
86
+ data[:journal_articles] << extractor.model
87
+ when 'Conference paper'
88
+ extractor = Puree::XMLExtractor::ConferencePaper.new research_output.to_s
89
+ data[:conference_papers] << extractor.model
90
+ when 'Doctoral Thesis'
91
+ extractor = Puree::XMLExtractor::Thesis.new research_output.to_s
92
+ data[:theses] << extractor.model
93
+ when "Master's Thesis"
94
+ extractor = Puree::XMLExtractor::Thesis.new research_output.to_s
95
+ data[:theses] << extractor.model
96
+ else
97
+ extractor = Puree::XMLExtractor::ResearchOutput.new research_output.to_s
98
+ data[:other] << extractor.model
99
+ end
100
+ end
101
+ end
102
+ data
103
+ end
104
+
105
+ private
106
+
107
+ # Get models from any multi-record resource XML response
21
108
  #
22
- # @return [Array<String>]
23
- def uuids
24
- arr = []
25
- xpath_result = @doc.xpath '//renderedItem/@renderedContentUUID'
26
- xpath_result.each { |i| arr << i.text.strip }
27
- arr
109
+ # @param xml [String]
110
+ # @return [Array<Puree::Model::Resource subclass>]
111
+ def self.models(resource_type, xml, xpath_root)
112
+ doc = Nokogiri::XML xml
113
+ doc.remove_namespaces!
114
+ path_from_root = File.join 'result', xpath_root
115
+ xpath_result = doc.xpath path_from_root
116
+ data = []
117
+ xpath_result.each do |i|
118
+ xml_extractor = make_xml_extractor resource_type, i.to_s
119
+ data << xml_extractor.model
120
+ end
121
+ data
28
122
  end
29
123
 
30
- # Is there any data after get?
31
- # @return [Boolean]
32
- def get_data?
33
- count >= 1 ? true : false
124
+ def self.make_xml_extractor(resource_type, xml)
125
+ resource_class = "Puree::XMLExtractor::#{Puree::Util::String.titleize(resource_type)}"
126
+ Object.const_get(resource_class).new xml
34
127
  end
35
128
 
36
129
  end