puree 0.20.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -2
  3. data/PITCHME.md +43 -21
  4. data/README.md +72 -18
  5. data/lib/puree.rb +66 -21
  6. data/lib/puree/api/api.rb +9 -0
  7. data/lib/puree/api/authentication.rb +33 -0
  8. data/lib/puree/api/configuration.rb +43 -0
  9. data/lib/puree/api/map.rb +76 -0
  10. data/lib/puree/api/request.rb +116 -0
  11. data/lib/puree/extractor/collection.rb +131 -0
  12. data/lib/puree/extractor/dataset.rb +48 -0
  13. data/lib/puree/extractor/download.rb +71 -0
  14. data/lib/puree/extractor/event.rb +33 -0
  15. data/lib/puree/extractor/extractor.rb +10 -0
  16. data/lib/puree/extractor/journal.rb +29 -0
  17. data/lib/puree/extractor/organisation.rb +34 -0
  18. data/lib/puree/extractor/person.rb +32 -0
  19. data/lib/puree/extractor/project.rb +40 -0
  20. data/lib/puree/extractor/publication.rb +40 -0
  21. data/lib/puree/extractor/publisher.rb +27 -0
  22. data/lib/puree/extractor/resource.rb +69 -0
  23. data/lib/puree/extractor/server.rb +56 -0
  24. data/lib/puree/model/address.rb +50 -0
  25. data/lib/puree/model/copyright_license.rb +26 -0
  26. data/lib/puree/model/dataset.rb +84 -0
  27. data/lib/puree/model/download_header.rb +21 -0
  28. data/lib/puree/model/endeavour_person.rb +34 -0
  29. data/lib/puree/model/event.rb +31 -0
  30. data/lib/puree/model/event_header.rb +26 -0
  31. data/lib/puree/model/file.rb +45 -0
  32. data/lib/puree/model/helper/validation.rb +15 -0
  33. data/lib/puree/model/journal.rb +20 -0
  34. data/lib/puree/model/legal_condition.rb +26 -0
  35. data/lib/puree/model/link.rb +26 -0
  36. data/lib/puree/model/model.rb +7 -0
  37. data/lib/puree/model/organisation.rb +34 -0
  38. data/lib/puree/model/organisation_header.rb +34 -0
  39. data/lib/puree/model/person.rb +28 -0
  40. data/lib/puree/model/person_name.rb +52 -0
  41. data/lib/puree/model/project.rb +49 -0
  42. data/lib/puree/model/publication.rb +53 -0
  43. data/lib/puree/model/publication_status.rb +21 -0
  44. data/lib/puree/model/publisher.rb +13 -0
  45. data/lib/puree/model/related_content_header.rb +34 -0
  46. data/lib/puree/model/resource.rb +42 -0
  47. data/lib/puree/model/server.rb +13 -0
  48. data/lib/puree/model/spatial_point.rb +16 -0
  49. data/lib/puree/model/structure.rb +18 -0
  50. data/lib/puree/model/temporal_range.rb +15 -0
  51. data/lib/puree/util/date.rb +86 -0
  52. data/lib/puree/util/util.rb +8 -0
  53. data/lib/puree/version.rb +1 -1
  54. data/lib/puree/xml_extractor/base.rb +47 -0
  55. data/lib/puree/xml_extractor/collection.rb +40 -0
  56. data/lib/puree/xml_extractor/dataset.rb +305 -0
  57. data/lib/puree/xml_extractor/download.rb +42 -0
  58. data/lib/puree/xml_extractor/event.rb +63 -0
  59. data/lib/puree/xml_extractor/journal.rb +33 -0
  60. data/lib/puree/xml_extractor/organisation.rb +75 -0
  61. data/lib/puree/xml_extractor/person.rb +57 -0
  62. data/lib/puree/xml_extractor/project.rb +135 -0
  63. data/lib/puree/xml_extractor/publication.rb +189 -0
  64. data/lib/puree/xml_extractor/publisher.rb +28 -0
  65. data/lib/puree/xml_extractor/resource.rb +71 -0
  66. data/lib/puree/xml_extractor/server.rb +32 -0
  67. data/lib/puree/xml_extractor/shared.rb +31 -0
  68. data/lib/puree/xml_extractor/xml_extractor.rb +10 -0
  69. data/puree.gemspec +11 -8
  70. data/spec/download_http_spec.rb +31 -0
  71. data/spec/open_api_dataset_http_spec.rb +15 -0
  72. data/spec/resource/collection_all_http_spec.rb +77 -0
  73. data/spec/resource/collection_http_spec.rb +65 -0
  74. data/spec/resource/dataset_http_spec.rb +104 -0
  75. data/spec/resource/event_http_spec.rb +52 -0
  76. data/spec/resource/journal_http_spec.rb +36 -0
  77. data/spec/resource/organisation_http_spec.rb +52 -0
  78. data/spec/resource/person_http_spec.rb +48 -0
  79. data/spec/resource/project_http_spec.rb +76 -0
  80. data/spec/resource/publication_http_spec.rb +78 -0
  81. data/spec/resource/publisher_http_spec.rb +26 -0
  82. data/spec/server_http_spec.rb +26 -0
  83. data/spec/spec_helper.rb +106 -21
  84. metadata +110 -46
  85. data/lib/puree/collection.rb +0 -285
  86. data/lib/puree/configuration.rb +0 -15
  87. data/lib/puree/dataset.rb +0 -483
  88. data/lib/puree/date.rb +0 -63
  89. data/lib/puree/download.rb +0 -189
  90. data/lib/puree/event.rb +0 -133
  91. data/lib/puree/journal.rb +0 -75
  92. data/lib/puree/map.rb +0 -68
  93. data/lib/puree/organisation.rb +0 -177
  94. data/lib/puree/person.rb +0 -136
  95. data/lib/puree/project.rb +0 -231
  96. data/lib/puree/publication.rb +0 -258
  97. data/lib/puree/publisher.rb +0 -64
  98. data/lib/puree/resource.rb +0 -261
  99. data/lib/puree/server.rb +0 -156
  100. data/spec/collection_spec.rb +0 -62
  101. data/spec/dataset_spec.rb +0 -148
  102. data/spec/download_spec.rb +0 -33
  103. data/spec/event_spec.rb +0 -108
  104. data/spec/journal_spec.rb +0 -92
  105. data/spec/organisation_spec.rb +0 -112
  106. data/spec/person_spec.rb +0 -104
  107. data/spec/project_spec.rb +0 -120
  108. data/spec/publication_spec.rb +0 -128
  109. data/spec/publisher_spec.rb +0 -89
  110. data/spec/server_spec.rb +0 -36
@@ -0,0 +1,21 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A minimal representation of a Download.
5
+ #
6
+ class DownloadHeader < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :uuid
10
+
11
+ # @return [Fixnum, nil]
12
+ attr_accessor :count
13
+
14
+ # @param v [String]
15
+ def uuid=(v)
16
+ @uuid = v if v && !v.empty?
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A person involved in an endeavour.
5
+ #
6
+ class EndeavourPerson < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :uuid
10
+
11
+ # @return [String, nil]
12
+ attr_reader :name
13
+
14
+ # @return [String, nil]
15
+ attr_reader :role
16
+
17
+ # @param v [String]
18
+ def uuid=(v)
19
+ @uuid = v if v && !v.empty?
20
+ end
21
+
22
+ # @param v [Puree::Model::PersonName]
23
+ def name=(v)
24
+ @name = v if v && v.data?
25
+ end
26
+
27
+ # @param v [String]
28
+ def role=(v)
29
+ @role = v if v && !v.empty?
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # An organised event.
5
+ #
6
+ class Event < Resource
7
+
8
+ # @return [String, nil]
9
+ attr_accessor :city
10
+
11
+ # @return [String, nil]
12
+ attr_accessor :country
13
+
14
+ # @return [Puree::Model::TemporalRange, nil]
15
+ attr_accessor :date
16
+
17
+ # @return [String, nil]
18
+ attr_accessor :description
19
+
20
+ # @return [String, nil]
21
+ attr_accessor :location
22
+
23
+ # @return [String, nil]
24
+ attr_accessor :title
25
+
26
+ # @return [String, nil]
27
+ attr_accessor :type
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A minimal representation of an Event.
5
+ #
6
+ class EventHeader < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :uuid
10
+
11
+ # @return [String, nil]
12
+ attr_reader :title
13
+
14
+ # @param v [String]
15
+ def uuid=(v)
16
+ @uuid = v if v && !v.empty?
17
+ end
18
+
19
+ # @param v [String]
20
+ def title=(v)
21
+ @title = v if v && !v.empty?
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,45 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # Description of a file.
5
+ #
6
+ class File < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :name
10
+
11
+ # @return [String, nil]
12
+ attr_reader :mime
13
+
14
+ # @return [Fixnum, nil]
15
+ attr_accessor :size
16
+
17
+ # @return [String, nil]
18
+ attr_reader :url
19
+
20
+ # @return [Puree::Model::CopyrightLicense, nil]
21
+ attr_reader :license
22
+
23
+ # @param v [String]
24
+ def name=(v)
25
+ @name = v if v && !v.empty?
26
+ end
27
+
28
+ # @param v [String]
29
+ def mime=(v)
30
+ @mime = v if v && !v.empty?
31
+ end
32
+
33
+ # @param v [String]
34
+ def url=(v)
35
+ @url = v if v && !v.empty?
36
+ end
37
+
38
+ # @param v [Puree::Model::CopyrightLicense]
39
+ def license=(v)
40
+ @license = v if v && v.data?
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,15 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # Model validation.
5
+ #
6
+ module Validation
7
+ def enforce_class(v, klass)
8
+ raise ArgumentError, "Expected #{klass}. Got #{v.class}." unless v && v.is_a?(klass)
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+
15
+
@@ -0,0 +1,20 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A journal.
5
+ #
6
+ class Journal < Resource
7
+
8
+ # @return [String, nil]
9
+ attr_accessor :issn
10
+
11
+ # @return [String, nil]
12
+ attr_accessor :publisher
13
+
14
+ # @return [String, nil]
15
+ attr_accessor :title
16
+
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,26 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A legal condition.
5
+ #
6
+ class LegalCondition < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :name
10
+
11
+ # @return [String, nil]
12
+ attr_reader :description
13
+
14
+ # @param v [String]
15
+ def name=(v)
16
+ @name = v if v && !v.empty?
17
+ end
18
+
19
+ # @param v [String]
20
+ def description=(v)
21
+ @description = v if v && !v.empty?
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # URL which points to something of interest.
5
+ #
6
+ class Link < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :description
10
+
11
+ # @return [String, nil]
12
+ attr_reader :url
13
+
14
+ # @param v [String]
15
+ def description=(v)
16
+ @description = v if v && !v.empty?
17
+ end
18
+
19
+ # @param v [String]
20
+ def url=(v)
21
+ @url = v if v && !v.empty?
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ module Puree
2
+ # A model is a data structure.
3
+ #
4
+ module Model
5
+
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # An organisational unit as defined by the institution.
5
+ #
6
+ class Organisation < Resource
7
+
8
+ # @return [Array<Puree::Model::Address>]
9
+ attr_accessor :address
10
+
11
+ # @return [Array<String>]
12
+ attr_accessor :email_addresses
13
+
14
+ # @return [String, nil]
15
+ attr_accessor :name
16
+
17
+ # @return [Array<Puree::Model::OrganisationHeader>]
18
+ attr_accessor :organisations
19
+
20
+ # @return [Puree::Model::OrganisationHeader, nil]
21
+ attr_accessor :parent
22
+
23
+ # @return [Array<String>]
24
+ attr_accessor :phone_numbers
25
+
26
+ # @return [String, nil]
27
+ attr_accessor :type
28
+
29
+ # @return [Array<String>]
30
+ attr_accessor :urls
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A minimal representation of an Organisation.
5
+ #
6
+ class OrganisationHeader < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :uuid
10
+
11
+ # @return [String, nil]
12
+ attr_reader :name
13
+
14
+ # @return [String, nil]
15
+ attr_reader :type
16
+
17
+ # @param v [String]
18
+ def uuid=(v)
19
+ @uuid = v if v && !v.empty?
20
+ end
21
+
22
+ # @param v [String]
23
+ def name=(v)
24
+ @name = v if v && !v.empty?
25
+ end
26
+
27
+ # @param v [String]
28
+ def type=(v)
29
+ @type = v if v && !v.empty?
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A person.
5
+ #
6
+ class Person < Resource
7
+
8
+ # @return [Array<Puree::Model::OrganisationHeader>]
9
+ attr_accessor :affiliations
10
+
11
+ # @return [Array<String>]
12
+ attr_accessor :email_addresses
13
+
14
+ # @return [Array<String>]
15
+ attr_accessor :image_urls
16
+
17
+ # @return [Array<String>]
18
+ attr_accessor :keywords
19
+
20
+ # @return [Puree::Model::PersonName, nil]
21
+ attr_accessor :name
22
+
23
+ # @return [String, nil]
24
+ attr_accessor :orcid
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,52 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # The name of a person.
5
+ #
6
+ class PersonName < Puree::Model::Structure
7
+
8
+ # @return [String, nil]
9
+ attr_reader :first
10
+
11
+ # @return [String, nil]
12
+ attr_reader :last
13
+
14
+ # @param v [String]
15
+ def first=(v)
16
+ @first = v if v && !v.empty?
17
+ end
18
+
19
+ # @param v [String]
20
+ def last=(v)
21
+ @last = v if v && !v.empty?
22
+ end
23
+
24
+ # @return [String]
25
+ def first_last
26
+ both? ? "#{first} #{last}" : 'One or both names missing'
27
+ end
28
+
29
+ # @return [String]
30
+ def last_first
31
+ both? ? "#{last}, #{first}" : 'One or both names missing'
32
+ end
33
+
34
+ # @return [String]
35
+ def initial_last
36
+ both? ? "#{first[0, 1]}. #{last}" : 'One or both names missing'
37
+ end
38
+
39
+ # @return [String]
40
+ def last_initial
41
+ both? ? "#{last}, #{first[0, 1]}." : 'One or both names missing'
42
+ end
43
+
44
+ private
45
+
46
+ def both?
47
+ !@first.nil? && !@last.nil? || false
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,49 @@
1
+ module Puree
2
+ module Model
3
+
4
+ # A project.
5
+ #
6
+ class Project < Resource
7
+
8
+ # @return [String, nil]
9
+ attr_accessor :acronym
10
+
11
+ # @return [String, nil]
12
+ attr_accessor :description
13
+
14
+ # @return [Array<Puree::Model::OrganisationHeader>]
15
+ attr_accessor :organisations
16
+
17
+ # @return [Puree::Model::OrganisationHeader, nil]
18
+ attr_accessor :owner
19
+
20
+ # @return [Array<Puree::Model::EndeavourPerson>]
21
+ attr_accessor :persons_internal
22
+
23
+ # @return [Array<Puree::Model::EndeavourPerson>]
24
+ attr_accessor :persons_external
25
+
26
+ # @return [Array<Puree::Model::EndeavourPerson>]
27
+ attr_accessor :persons_other
28
+
29
+ # @return [String, nil]
30
+ attr_accessor :status
31
+
32
+ # @return [Puree::Model::TemporalRange, nil]
33
+ attr_accessor :temporal_actual
34
+
35
+ # @return [Puree::Model::TemporalRange, nil]
36
+ attr_accessor :temporal_expected
37
+
38
+ # @return [String, nil]
39
+ attr_accessor :title
40
+
41
+ # @return [String, nil]
42
+ attr_accessor :type
43
+
44
+ # @return [String, nil]
45
+ attr_accessor :url
46
+
47
+ end
48
+ end
49
+ end