puree 0.16.1 → 0.17.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: 702c6796091f8038d2f16e64a08771e0c7de343a
4
- data.tar.gz: 159ce8cf44a772788a75d09c805646270b6a4191
3
+ metadata.gz: 1a632a407b779c5a615440921a4f68b102720cf4
4
+ data.tar.gz: f5c253baddaf154171a1e48b8bfed12f8164faf1
5
5
  SHA512:
6
- metadata.gz: 016eab3513888247691e34ebf767d229cbf93cd60a0e29b06473a81a697334fd3e4de07da7153b11050e7042e9806483640b9d7b6afa2a70e1096a8043d8702b
7
- data.tar.gz: 7ccfa0e8cc2c138dfd7fe9cb54b27889172e29d4c7055d942b578b4b47fc7f3f43991d67d320f90a5deb579eaa47da69c9bb9730f72bae0854d4a5a2088dde64
6
+ metadata.gz: 77cb22c6d59964e383dea0f8aea621c7d11cbd62929a91c4a34636c21a8d17cbce45907d6b9d637c7390a3002e65b6b78be27ffce46ee1e251ed7e8f7c66cbfb
7
+ data.tar.gz: 0adf28ac11d47aae6767f7e36c92eda2736d92391b6bfe7b9730c86a96d015dffce02d1e533cbab52c664792070dc67c9302c72e1e89a697d47f5ff4abf54dbf
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
  - Factory to make resource objects?
8
8
  - Make ALL dates ISO 8601 YYYY-MM-DD, rather than mirror varying formats from Pure?
9
9
 
10
+ ## 0.17.0 - 2016-09-02
11
+ ### Added
12
+ - Resource subclasses - uuid, created, modified as methods.
13
+ - Resource subclasses - set content from XML string.
14
+
15
+ ### Fixed
16
+ - Organisation - organisation extraction.
17
+
10
18
  ## 0.16.1 - 2016-08-30
11
19
  ### Fixed
12
20
  - Dataset, Project, Publication - person uuid returns text rather than a Nokogiri object.
data/README.md CHANGED
@@ -50,8 +50,4 @@ metadata = c.find limit: 50
50
50
  ## Documentation
51
51
  [API in YARD](http://www.rubydoc.info/gems/puree)
52
52
 
53
- [Detailed usage](https://github.com/lulibrary/puree/wiki)
54
-
55
-
56
-
57
-
53
+ [Detailed usage in GitBook](https://aalbinclark.gitbooks.io/puree)
data/lib/puree.rb CHANGED
@@ -17,6 +17,8 @@ require 'puree/download'
17
17
  require 'puree/server'
18
18
  require 'puree/version'
19
19
 
20
+ # Top level namespace
21
+ #
20
22
  module Puree
21
23
 
22
24
  class << self
@@ -1,5 +1,7 @@
1
1
  module Puree
2
2
 
3
+ # Configuration options
4
+ #
3
5
  module Configuration
4
6
 
5
7
  attr_accessor :base_url, :username, :password, :basic_auth
data/lib/puree/date.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Puree
2
2
 
3
+ # Date utilities
4
+ #
3
5
  module Date
4
6
 
5
7
  # Converts a date with three components (year, month, day) to ISO 8601 date format
data/lib/puree/map.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Puree
2
2
 
3
+ # Pure API map
4
+ #
3
5
  class Map
4
6
 
5
7
  def initialize
@@ -36,7 +38,7 @@ module Puree
36
38
  # add_family
37
39
  end
38
40
 
39
- # Pure API map
41
+ # Get
40
42
  #
41
43
  # @return [Hash]
42
44
  def get
@@ -164,6 +164,7 @@ module Puree
164
164
  o['address'] = extract_address
165
165
  o['email'] = extract_email
166
166
  o['name'] = extract_name
167
+ o['organisation'] = extract_organisation
167
168
  o['parent'] = extract_parent
168
169
  o['phone'] = extract_phone
169
170
  o['type'] = extract_type
data/lib/puree/project.rb CHANGED
@@ -47,7 +47,7 @@ module Puree
47
47
 
48
48
  # Person (internal, external, other)
49
49
  #
50
- # @return [Array<Hash>]
50
+ # @return [Hash<Array,Array,Array>]
51
51
  def person
52
52
  @metadata['person']
53
53
  end
@@ -60,14 +60,14 @@ module Puree
60
60
 
61
61
  # Page
62
62
  #
63
- # @return [Array<String>]
63
+ # @return [String]
64
64
  def page
65
65
  @metadata['page']
66
66
  end
67
67
 
68
68
  # Person (internal, external, other)
69
69
  #
70
- # @return [Array<Hash>]
70
+ # @return [Hash<Array,Array,Array>]
71
71
  def person
72
72
  @metadata['person']
73
73
  end
@@ -27,6 +27,12 @@ module Puree
27
27
  @username = username.nil? ? Puree.username : username
28
28
  @password = password.nil? ? Puree.password : password
29
29
  end
30
+ @metadata = {}
31
+ @options = {
32
+ basic_auth: @basic_auth,
33
+ latest_api: @latest_api,
34
+ resource_type: @resource_type.to_sym
35
+ }
30
36
  end
31
37
 
32
38
  # Get
@@ -37,14 +43,9 @@ module Puree
37
43
  def get(uuid: nil, id: nil, rendering: :xml_long)
38
44
  reset
39
45
 
40
- @options = {
41
- basic_auth: @basic_auth,
42
- latest_api: @latest_api,
43
- resource_type: @resource_type.to_sym,
44
- rendering: rendering,
45
- uuid: uuid,
46
- id: id
47
- }
46
+ @options[:rendering] = rendering
47
+ @options[:uuid] = uuid
48
+ @options[:id] = id
48
49
 
49
50
  missing = missing_credentials
50
51
  if !missing.empty?
@@ -76,8 +77,8 @@ module Puree
76
77
  end
77
78
  end
78
79
 
79
- if @options['rendering']
80
- query['rendering'] = @options['rendering']
80
+ if @options[:rendering]
81
+ query['rendering'] = @options[:rendering]
81
82
  end
82
83
 
83
84
  begin
@@ -87,8 +88,7 @@ module Puree
87
88
  req = req.auth headers['Authorization']
88
89
  end
89
90
  @response = req.get(url, params: query)
90
- @doc = Nokogiri::XML @response.body
91
- @doc.remove_namespaces!
91
+ make_doc @response.body
92
92
 
93
93
  rescue HTTP::Error => e
94
94
  puts 'HTTP::Error '+ e.message
@@ -98,47 +98,57 @@ module Puree
98
98
 
99
99
  end
100
100
 
101
- # Set content
101
+ # UUID
102
102
  #
103
- # @param content [Hash]
104
- def set_content(content)
105
- if !content.nil? && !content.empty?
106
- @content = content
107
- else
108
- @content = {}
109
- end
103
+ # @return [String]
104
+ def uuid
105
+ @metadata['uuid']
110
106
  end
111
107
 
112
- # Content
108
+ # Created (UTC datetime)
113
109
  #
114
- # @return [Hash]
115
- def content
116
- @content ? @content : {}
110
+ # @return [String]
111
+ def created
112
+ @metadata['created']
117
113
  end
118
114
 
115
+ # Modified (UTC datetime)
116
+ #
117
+ # @return [String]
118
+ def modified
119
+ @metadata['modified']
120
+ end
119
121
 
122
+ # Set content from XML. In order for metadata extraction to work, the XML must have
123
+ # been retrieved using the .current version of the Pure API endpoints
124
+ #
125
+ # @param xml [String]
126
+ def set_content(xml)
127
+ if xml
128
+ make_doc xml
129
+ if get_data?
130
+ combine_metadata
131
+ end
132
+ end
133
+ end
120
134
 
121
135
  private
122
136
 
123
- # Created (UTC datetime)
124
- #
125
- # @return [String]
137
+ def make_doc(xml)
138
+ @doc = Nokogiri::XML xml
139
+ @doc.remove_namespaces!
140
+ end
141
+
126
142
  def extract_created
127
143
  path = '/created'
128
144
  xpath_query_for_single_value path
129
145
  end
130
146
 
131
- # Modified (UTC datetime)
132
- #
133
- # @return [String]
134
147
  def extract_modified
135
148
  path = '/modified'
136
149
  xpath_query_for_single_value path
137
150
  end
138
151
 
139
- # UUID
140
- #
141
- # @return [String]
142
152
  def extract_uuid
143
153
  path = '/@uuid'
144
154
  xpath_query_for_single_value path
@@ -232,5 +242,6 @@ module Puree
232
242
 
233
243
  alias :find :get
234
244
 
245
+
235
246
  end
236
247
  end
data/lib/puree/server.rb CHANGED
@@ -22,6 +22,7 @@ module Puree
22
22
  @username = username.nil? ? Puree.username : username
23
23
  @password = password.nil? ? Puree.password : password
24
24
  end
25
+ @metadata = {}
25
26
  end
26
27
 
27
28
  # Get
data/lib/puree/version.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  module Puree
2
- VERSION = "0.16.1"
2
+ # Semantic version number
3
+ #
4
+ VERSION = "0.17.0"
3
5
  end
data/puree.gemspec CHANGED
@@ -10,9 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["a.albin-clark@lancaster.ac.uk"]
11
11
  spec.summary = %q{A client for the Pure Research Information System API.}
12
12
  spec.description = %q{Consumes the Pure Research Information System API and puts the metadata into simple data structures.}
13
- spec.homepage = "https://github.com/lulibrary/puree.git"
13
+ spec.homepage = "https://rubygems.org/gems/puree/"
14
14
  spec.license = "MIT"
15
-
16
15
  spec.files = `git ls-files -z`.split("\x0")
17
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
data/spec/dataset.rb CHANGED
@@ -2,6 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe 'Dataset' do
4
4
 
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_DATASET_UUID']
10
+ @p = Puree::Dataset.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
5
17
  it '#new' do
6
18
  p = Puree::Dataset.new
7
19
  expect(p).to be_an_instance_of Puree::Dataset
@@ -9,93 +21,111 @@ describe 'Dataset' do
9
21
 
10
22
  describe 'data retrieval' do
11
23
  before(:all) do
12
- base_url = ENV['PURE_BASE_URL']
13
- username = ENV['PURE_USERNAME']
14
- password = ENV['PURE_PASSWORD']
15
- uuid = ENV['PURE_DATASET_UUID']
16
- @p = Puree::Dataset.new(base_url: base_url,
17
- username: username,
18
- password: password,
19
- basic_auth: true)
20
- @metadata = @p.find uuid: uuid
21
- end
22
-
23
- it '@metadata' do
24
+ request
25
+ end
26
+
27
+ it '#find' do
24
28
  expect(@metadata).to be_an_instance_of(Hash)
25
29
  end
26
30
 
27
31
  it '#access' do
28
- expect(@metadata['access']).to be_an_instance_of(String)
32
+ expect(@p.access).to be_an_instance_of(String)
29
33
  end
30
34
 
31
35
  it '#associated' do
32
- expect(@metadata['associated']).to be_an_instance_of(Array)
36
+ expect(@p.associated).to be_an_instance_of(Array)
33
37
  end
34
38
 
35
39
  it '#available' do
36
- expect(@metadata['available']).to be_an_instance_of(Hash)
40
+ expect(@p.available).to be_an_instance_of(Hash)
37
41
  end
38
42
 
39
43
  it '#created' do
40
- expect(@metadata['created']).to be_an_instance_of(String)
44
+ expect(@p.created).to be_an_instance_of(String)
41
45
  end
42
46
 
43
47
  it '#description' do
44
- expect(@metadata['description']).to be_an_instance_of(String)
48
+ expect(@p.description).to be_an_instance_of(String)
45
49
  end
46
50
 
47
51
  it '#doi' do
48
- expect(@metadata['doi']).to be_an_instance_of(String)
52
+ expect(@p.doi).to be_an_instance_of(String)
49
53
  end
50
54
 
51
55
  it '#file' do
52
- expect(@metadata['file']).to be_an_instance_of(Array)
56
+ expect(@p.file).to be_an_instance_of(Array)
53
57
  end
54
58
 
55
59
  it '#keyword' do
56
- expect(@metadata['keyword']).to be_an_instance_of(Array)
60
+ expect(@p.keyword).to be_an_instance_of(Array)
57
61
  end
58
62
 
59
63
  it '#link' do
60
- expect(@metadata['link']).to be_an_instance_of(Array)
64
+ expect(@p.link).to be_an_instance_of(Array)
65
+ end
66
+
67
+ it '#metadata' do
68
+ expect(@p.metadata).to be_an_instance_of(Hash)
61
69
  end
62
70
 
63
71
  it '#modified' do
64
- expect(@metadata['modified']).to be_an_instance_of(String)
72
+ expect(@p.modified).to be_an_instance_of(String)
65
73
  end
66
74
 
67
75
  it '#person' do
68
- expect(@metadata['person']).to be_an_instance_of(Hash)
76
+ expect(@p.person).to be_an_instance_of(Hash)
69
77
  end
70
78
 
71
79
  it '#production' do
72
- expect(@metadata['production']).to be_an_instance_of(Hash)
80
+ expect(@p.production).to be_an_instance_of(Hash)
73
81
  end
74
82
 
75
83
  it '#project' do
76
- expect(@metadata['project']).to be_an_instance_of(Array)
84
+ expect(@p.project).to be_an_instance_of(Array)
77
85
  end
78
86
 
79
87
  it '#publication' do
80
- expect(@metadata['publication']).to be_an_instance_of(Array)
88
+ expect(@p.publication).to be_an_instance_of(Array)
81
89
  end
82
90
 
83
91
  it '#publisher' do
84
- expect(@metadata['publisher']).to be_an_instance_of(String)
92
+ expect(@p.publisher).to be_an_instance_of(String)
85
93
  end
86
94
 
87
95
  it '#spatial' do
88
- expect(@metadata['spatial']).to be_an_instance_of(Array)
96
+ expect(@p.spatial).to be_an_instance_of(Array)
89
97
  end
90
98
 
91
99
  it '#temporal' do
92
- expect(@metadata['temporal']).to be_an_instance_of(Hash)
100
+ expect(@p.temporal).to be_an_instance_of(Hash)
93
101
  end
94
102
 
95
103
  it '#title' do
96
- expect(@metadata['title']).to be_an_instance_of(String)
104
+ expect(@p.title).to be_an_instance_of(String)
105
+ end
106
+
107
+ it '#uuid' do
108
+ expect(@p.uuid).to be_an_instance_of(String)
109
+ end
110
+ end
111
+
112
+ describe 'data retrieval from file' do
113
+ before(:all) do
114
+ request
115
+
116
+ filename = "#{ENV['PURE_FILE_PATH']}dataset.#{@uuid}.xml"
117
+ File.write(filename, @p.response.body)
118
+
119
+ @metadata = @p.set_content File.read(filename)
97
120
  end
98
121
 
122
+ it '#set_content' do
123
+ expect(@metadata).to be_an_instance_of(Hash)
124
+ end
125
+
126
+ it '#metadata' do
127
+ expect(@p.metadata).to be_an_instance_of(Hash)
128
+ end
99
129
 
100
130
  end
101
131
 
data/spec/download.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Download' do
4
+
5
+ it '#new' do
6
+ p = Puree::Download.new
7
+ expect(p).to be_an_instance_of Puree::Download
8
+ end
9
+
10
+ describe 'data retrieval' do
11
+ before(:all) do
12
+ base_url = ENV['PURE_BASE_URL']
13
+ username = ENV['PURE_USERNAME']
14
+ password = ENV['PURE_PASSWORD']
15
+ @p = Puree::Download.new(base_url: base_url,
16
+ username: username,
17
+ password: password,
18
+ basic_auth: true)
19
+ @metadata = @p.find resource: :dataset,
20
+ limit: 10
21
+ end
22
+
23
+ it '#find' do
24
+ expect(@metadata).to be_an_instance_of(Array)
25
+ end
26
+
27
+ end
28
+
29
+ end
data/spec/event.rb ADDED
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Event' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_EVENT_UUID']
10
+ @p = Puree::Event.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Event.new
19
+ expect(p).to be_an_instance_of Puree::Event
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#city' do
32
+ expect(@p.city).to be_an_instance_of(String)
33
+ end
34
+
35
+ it '#country' do
36
+ expect(@p.country).to be_an_instance_of(String)
37
+ end
38
+
39
+ it '#created' do
40
+ expect(@p.created).to be_an_instance_of(String)
41
+ end
42
+
43
+ it '#date' do
44
+ expect(@p.date).to be_an_instance_of(Hash)
45
+ end
46
+
47
+ it '#description' do
48
+ expect(@p.description).to be_an_instance_of(String)
49
+ end
50
+
51
+ it '#location' do
52
+ expect(@p.location).to be_an_instance_of(String)
53
+ end
54
+
55
+ it '#metadata' do
56
+ expect(@p.metadata).to be_an_instance_of(Hash)
57
+ end
58
+
59
+ it '#modified' do
60
+ expect(@p.modified).to be_an_instance_of(String)
61
+ end
62
+
63
+ it '#title' do
64
+ expect(@p.title).to be_an_instance_of(String)
65
+ end
66
+
67
+ it '#type' do
68
+ expect(@p.type).to be_an_instance_of(String)
69
+ end
70
+
71
+ it '#uuid' do
72
+ expect(@p.uuid).to be_an_instance_of(String)
73
+ end
74
+ end
75
+
76
+ describe 'data retrieval from file' do
77
+ before(:all) do
78
+ request
79
+
80
+ filename = "#{ENV['PURE_FILE_PATH']}event.#{@uuid}.xml"
81
+ File.write(filename, @p.response.body)
82
+
83
+ @metadata = @p.set_content File.read(filename)
84
+ end
85
+
86
+ it '#set_content' do
87
+ expect(@metadata).to be_an_instance_of(Hash)
88
+ end
89
+
90
+ it '#metadata' do
91
+ expect(@p.metadata).to be_an_instance_of(Hash)
92
+ end
93
+
94
+ end
95
+
96
+ end
data/spec/journal.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Journal' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_JOURNAL_UUID']
10
+ @p = Puree::Journal.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Journal.new
19
+ expect(p).to be_an_instance_of Puree::Journal
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#created' do
32
+ expect(@p.created).to be_an_instance_of(String)
33
+ end
34
+
35
+ it '#metadata' do
36
+ expect(@p.metadata).to be_an_instance_of(Hash)
37
+ end
38
+
39
+ it '#modified' do
40
+ expect(@p.modified).to be_an_instance_of(String)
41
+ end
42
+
43
+ it '#uuid' do
44
+ expect(@p.uuid).to be_an_instance_of(String)
45
+ end
46
+ end
47
+
48
+ describe 'data retrieval from file' do
49
+ before(:all) do
50
+ request
51
+
52
+ filename = "#{ENV['PURE_FILE_PATH']}journal.#{@uuid}.xml"
53
+ File.write(filename, @p.response.body)
54
+
55
+ @metadata = @p.set_content File.read(filename)
56
+ end
57
+
58
+ it '#set_content' do
59
+ expect(@metadata).to be_an_instance_of(Hash)
60
+ end
61
+
62
+ it '#metadata' do
63
+ expect(@p.metadata).to be_an_instance_of(Hash)
64
+ end
65
+
66
+ end
67
+
68
+ end
@@ -0,0 +1,100 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Organisation' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_ORGANISATION_UUID']
10
+ @p = Puree::Organisation.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Organisation.new
19
+ expect(p).to be_an_instance_of Puree::Organisation
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#address' do
32
+ expect(@p.address).to be_an_instance_of(Array)
33
+ end
34
+
35
+ it '#created' do
36
+ expect(@p.created).to be_an_instance_of(String)
37
+ end
38
+
39
+ it '#email' do
40
+ expect(@p.email).to be_an_instance_of(Array)
41
+ end
42
+
43
+ it '#metadata' do
44
+ expect(@p.metadata).to be_an_instance_of(Hash)
45
+ end
46
+
47
+ it '#modified' do
48
+ expect(@p.modified).to be_an_instance_of(String)
49
+ end
50
+
51
+ it '#name' do
52
+ expect(@p.name).to be_an_instance_of(String)
53
+ end
54
+
55
+ it '#organisation' do
56
+ expect(@p.organisation).to be_an_instance_of(Array)
57
+ end
58
+
59
+ it '#parent' do
60
+ expect(@p.parent).to be_an_instance_of(Hash)
61
+ end
62
+
63
+ it '#phone' do
64
+ expect(@p.phone).to be_an_instance_of(Array)
65
+ end
66
+
67
+ it '#type' do
68
+ expect(@p.type).to be_an_instance_of(String)
69
+ end
70
+
71
+ it '#url' do
72
+ expect(@p.url).to be_an_instance_of(Array)
73
+ end
74
+
75
+ it '#uuid' do
76
+ expect(@p.uuid).to be_an_instance_of(String)
77
+ end
78
+ end
79
+
80
+ describe 'data retrieval from file' do
81
+ before(:all) do
82
+ request
83
+
84
+ filename = "#{ENV['PURE_FILE_PATH']}organisation.#{@uuid}.xml"
85
+ File.write(filename, @p.response.body)
86
+
87
+ @metadata = @p.set_content File.read(filename)
88
+ end
89
+
90
+ it '#set_content' do
91
+ expect(@metadata).to be_an_instance_of(Hash)
92
+ end
93
+
94
+ it '#metadata' do
95
+ expect(@p.metadata).to be_an_instance_of(Hash)
96
+ end
97
+
98
+ end
99
+
100
+ end
data/spec/person.rb ADDED
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Person' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_PERSON_UUID']
10
+ @p = Puree::Person.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Person.new
19
+ expect(p).to be_an_instance_of Puree::Person
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#affiliation' do
32
+ expect(@p.affiliation).to be_an_instance_of(Array)
33
+ end
34
+
35
+ it '#created' do
36
+ expect(@p.created).to be_an_instance_of(String)
37
+ end
38
+
39
+ it '#email' do
40
+ expect(@p.email).to be_an_instance_of(Array)
41
+ end
42
+
43
+ it '#image' do
44
+ expect(@p.image).to be_an_instance_of(Array)
45
+ end
46
+
47
+ it '#keyword' do
48
+ expect(@p.keyword).to be_an_instance_of(Array)
49
+ end
50
+
51
+ it '#metadata' do
52
+ expect(@p.metadata).to be_an_instance_of(Hash)
53
+ end
54
+
55
+ it '#modified' do
56
+ expect(@p.modified).to be_an_instance_of(String)
57
+ end
58
+
59
+ it '#name' do
60
+ expect(@p.name).to be_an_instance_of(Hash)
61
+ end
62
+
63
+ it '#orcid' do
64
+ expect(@p.orcid).to be_an_instance_of(String)
65
+ end
66
+
67
+ it '#uuid' do
68
+ expect(@p.uuid).to be_an_instance_of(String)
69
+ end
70
+ end
71
+
72
+ describe 'data retrieval from file' do
73
+ before(:all) do
74
+ request
75
+
76
+ filename = "#{ENV['PURE_FILE_PATH']}person.#{@uuid}.xml"
77
+ File.write(filename, @p.response.body)
78
+
79
+ @metadata = @p.set_content File.read(filename)
80
+ end
81
+
82
+ it '#set_content' do
83
+ expect(@metadata).to be_an_instance_of(Hash)
84
+ end
85
+
86
+ it '#metadata' do
87
+ expect(@p.metadata).to be_an_instance_of(Hash)
88
+ end
89
+
90
+ end
91
+
92
+ end
data/spec/project.rb ADDED
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Project' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_PROJECT_UUID']
10
+ @p = Puree::Project.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Project.new
19
+ expect(p).to be_an_instance_of Puree::Project
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#acronym' do
32
+ expect(@p.acronym).to be_an_instance_of(String)
33
+ end
34
+
35
+ it '#created' do
36
+ expect(@p.created).to be_an_instance_of(String)
37
+ end
38
+
39
+ it '#description' do
40
+ expect(@p.description).to be_an_instance_of(String)
41
+ end
42
+
43
+ it '#metadata' do
44
+ expect(@p.metadata).to be_an_instance_of(Hash)
45
+ end
46
+
47
+ it '#modified' do
48
+ expect(@p.modified).to be_an_instance_of(String)
49
+ end
50
+
51
+ it '#organisation' do
52
+ expect(@p.organisation).to be_an_instance_of(Array)
53
+ end
54
+
55
+ it '#owner' do
56
+ expect(@p.owner).to be_an_instance_of(Hash)
57
+ end
58
+
59
+ it '#person' do
60
+ expect(@p.person).to be_an_instance_of(Hash)
61
+ end
62
+
63
+ it '#status' do
64
+ expect(@p.status).to be_an_instance_of(String)
65
+ end
66
+
67
+ it '#temporal' do
68
+ expect(@p.temporal).to be_an_instance_of(Hash)
69
+ end
70
+
71
+ it '#title' do
72
+ expect(@p.title).to be_an_instance_of(String)
73
+ end
74
+
75
+ it '#type' do
76
+ expect(@p.type).to be_an_instance_of(String)
77
+ end
78
+
79
+ it '#url' do
80
+ expect(@p.url).to be_an_instance_of(String)
81
+ end
82
+
83
+ it '#uuid' do
84
+ expect(@p.uuid).to be_an_instance_of(String)
85
+ end
86
+ end
87
+
88
+ describe 'data retrieval from file' do
89
+ before(:all) do
90
+ request
91
+
92
+ filename = "#{ENV['PURE_FILE_PATH']}project.#{@uuid}.xml"
93
+ File.write(filename, @p.response.body)
94
+
95
+ @metadata = @p.set_content File.read(filename)
96
+ end
97
+
98
+ it '#set_content' do
99
+ expect(@metadata).to be_an_instance_of(Hash)
100
+ end
101
+
102
+ it '#metadata' do
103
+ expect(@p.metadata).to be_an_instance_of(Hash)
104
+ end
105
+
106
+ end
107
+
108
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Publication' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_PUBLICATION_UUID']
10
+ @p = Puree::Publication.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Publication.new
19
+ expect(p).to be_an_instance_of Puree::Publication
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#category' do
32
+ expect(@p.category).to be_an_instance_of(String)
33
+ end
34
+
35
+ it '#created' do
36
+ expect(@p.created).to be_an_instance_of(String)
37
+ end
38
+
39
+ it '#description' do
40
+ expect(@p.description).to be_an_instance_of(String)
41
+ end
42
+
43
+ it '#doi' do
44
+ expect(@p.doi).to be_an_instance_of(String)
45
+ end
46
+
47
+ it '#event' do
48
+ expect(@p.event).to be_an_instance_of(Hash)
49
+ end
50
+
51
+ it '#file' do
52
+ expect(@p.file).to be_an_instance_of(Array)
53
+ end
54
+
55
+ it '#metadata' do
56
+ expect(@p.metadata).to be_an_instance_of(Hash)
57
+ end
58
+
59
+ it '#modified' do
60
+ expect(@p.modified).to be_an_instance_of(String)
61
+ end
62
+
63
+ it '#organisation' do
64
+ expect(@p.organisation).to be_an_instance_of(Array)
65
+ end
66
+
67
+ it '#page' do
68
+ expect(@p.page).to be_an_instance_of(String)
69
+ end
70
+
71
+ it '#person' do
72
+ expect(@p.person).to be_an_instance_of(Hash)
73
+ end
74
+
75
+ it '#status' do
76
+ expect(@p.status).to be_an_instance_of(Array)
77
+ end
78
+
79
+ it '#subtitle' do
80
+ expect(@p.subtitle).to be_an_instance_of(String)
81
+ end
82
+
83
+ it '#title' do
84
+ expect(@p.title).to be_an_instance_of(String)
85
+ end
86
+
87
+ it '#type' do
88
+ expect(@p.type).to be_an_instance_of(String)
89
+ end
90
+
91
+ it '#uuid' do
92
+ expect(@p.uuid).to be_an_instance_of(String)
93
+ end
94
+ end
95
+
96
+ describe 'data retrieval from file' do
97
+ before(:all) do
98
+ request
99
+
100
+ filename = "#{ENV['PURE_FILE_PATH']}publication.#{@uuid}.xml"
101
+ File.write(filename, @p.response.body)
102
+
103
+ @metadata = @p.set_content File.read(filename)
104
+ end
105
+
106
+ it '#set_content' do
107
+ expect(@metadata).to be_an_instance_of(Hash)
108
+ end
109
+
110
+ it '#metadata' do
111
+ expect(@p.metadata).to be_an_instance_of(Hash)
112
+ end
113
+
114
+ end
115
+
116
+ end
data/spec/publisher.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Publisher' do
4
+
5
+ def request
6
+ base_url = ENV['PURE_BASE_URL']
7
+ username = ENV['PURE_USERNAME']
8
+ password = ENV['PURE_PASSWORD']
9
+ @uuid = ENV['PURE_PUBLISHER_UUID']
10
+ @p = Puree::Publisher.new(base_url: base_url,
11
+ username: username,
12
+ password: password,
13
+ basic_auth: true)
14
+ @metadata = @p.find uuid: @uuid
15
+ end
16
+
17
+ it '#new' do
18
+ p = Puree::Publisher.new
19
+ expect(p).to be_an_instance_of Puree::Publisher
20
+ end
21
+
22
+ describe 'data retrieval' do
23
+ before(:all) do
24
+ request
25
+ end
26
+
27
+ it '#find' do
28
+ expect(@metadata).to be_an_instance_of(Hash)
29
+ end
30
+
31
+ it '#created' do
32
+ expect(@p.created).to be_an_instance_of(String)
33
+ end
34
+
35
+ it '#metadata' do
36
+ expect(@p.metadata).to be_an_instance_of(Hash)
37
+ end
38
+
39
+ it '#modified' do
40
+ expect(@p.modified).to be_an_instance_of(String)
41
+ end
42
+
43
+ it '#uuid' do
44
+ expect(@p.uuid).to be_an_instance_of(String)
45
+ end
46
+ end
47
+
48
+ describe 'data retrieval from file' do
49
+ before(:all) do
50
+ request
51
+
52
+ filename = "#{ENV['PURE_FILE_PATH']}publisher.#{@uuid}.xml"
53
+ File.write(filename, @p.response.body)
54
+
55
+ @metadata = @p.set_content File.read(filename)
56
+ end
57
+
58
+ it '#set_content' do
59
+ expect(@metadata).to be_an_instance_of(Hash)
60
+ end
61
+
62
+ it '#metadata' do
63
+ expect(@p.metadata).to be_an_instance_of(Hash)
64
+ end
65
+
66
+ end
67
+
68
+ end
data/spec/server.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Server' do
4
+
5
+ it '#new' do
6
+ p = Puree::Server.new
7
+ expect(p).to be_an_instance_of Puree::Server
8
+ end
9
+
10
+ describe 'data retrieval' do
11
+ before(:all) do
12
+ base_url = ENV['PURE_BASE_URL']
13
+ username = ENV['PURE_USERNAME']
14
+ password = ENV['PURE_PASSWORD']
15
+ @p = Puree::Server.new(base_url: base_url,
16
+ username: username,
17
+ password: password,
18
+ basic_auth: true)
19
+ @metadata = @p.find
20
+ end
21
+
22
+ it '#find' do
23
+ expect(@metadata).to be_an_instance_of(Hash)
24
+ end
25
+
26
+ it '#version' do
27
+ expect(@p.version).to be_an_instance_of(String)
28
+ end
29
+
30
+ end
31
+
32
+ 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.16.1
4
+ version: 0.17.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-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -72,8 +72,17 @@ files:
72
72
  - puree.gemspec
73
73
  - spec/collection.rb
74
74
  - spec/dataset.rb
75
+ - spec/download.rb
76
+ - spec/event.rb
77
+ - spec/journal.rb
78
+ - spec/organisation.rb
79
+ - spec/person.rb
80
+ - spec/project.rb
81
+ - spec/publication.rb
82
+ - spec/publisher.rb
83
+ - spec/server.rb
75
84
  - spec/spec_helper.rb
76
- homepage: https://github.com/lulibrary/puree.git
85
+ homepage: https://rubygems.org/gems/puree/
77
86
  licenses:
78
87
  - MIT
79
88
  metadata: {}
@@ -100,5 +109,14 @@ summary: A client for the Pure Research Information System API.
100
109
  test_files:
101
110
  - spec/collection.rb
102
111
  - spec/dataset.rb
112
+ - spec/download.rb
113
+ - spec/event.rb
114
+ - spec/journal.rb
115
+ - spec/organisation.rb
116
+ - spec/person.rb
117
+ - spec/project.rb
118
+ - spec/publication.rb
119
+ - spec/publisher.rb
120
+ - spec/server.rb
103
121
  - spec/spec_helper.rb
104
122
  has_rdoc: