puree 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +14 -7
- data/lib/puree/collection.rb +45 -24
- data/lib/puree/resource.rb +11 -5
- data/lib/puree/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 539976142cda876c73eb0caf03ae4b2eca425775
|
4
|
+
data.tar.gz: f5896f3afb50cbc67bca6d20124fef8d85ae4052
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6f35ad8908b500f03ff30f00b38621bf8d570fc5b3c9f53be7e24ef1b7eb024e342fe3d56e8f99b7b8d23cdeaed466e2e3c372cb73b09a0f24e47c17d9a1ed6
|
7
|
+
data.tar.gz: 1b6b644bbb9157f345b29a03428805cee300a2982ac44378b5c3aa873fd8487a964bce711bb6f7553eaab3cf426c3c2e1f1abca0a0051738165d3024c67c304a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
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
|
+
## 0.13.0 - 2016-05-20
|
6
|
+
### Added
|
7
|
+
- Collection server-side search by date range (created, modified) and paging.
|
8
|
+
|
5
9
|
## 0.12.0 - 2016-05-20
|
6
10
|
### Added
|
7
11
|
- Resource (created, modified, uuid).
|
data/README.md
CHANGED
@@ -75,11 +75,16 @@ Collection.
|
|
75
75
|
```ruby
|
76
76
|
c = Puree::Collection.new(resource_type: :dataset)
|
77
77
|
|
78
|
-
# Get minimal datasets,
|
79
|
-
c.get endpoint:
|
80
|
-
username:
|
81
|
-
password:
|
82
|
-
|
78
|
+
# Get three minimal datasets, starting at record ten, created and modified in January 2016.
|
79
|
+
c.get endpoint: endpoint,
|
80
|
+
username: username,
|
81
|
+
password: password,
|
82
|
+
limit: 3, # optional, default 20
|
83
|
+
offset: 10, # optional, default 0
|
84
|
+
created_start: '2016-01-01', # optional
|
85
|
+
created_end: '2016-01-31', # optional
|
86
|
+
modified_start: '2016-01-01', # optional
|
87
|
+
modified_end: '2016-01-31' # optional
|
83
88
|
|
84
89
|
# Get UUIDs for datasets
|
85
90
|
uuids = c.uuid
|
@@ -160,12 +165,14 @@ Contains an array of internal persons, an array of external persons and an array
|
|
160
165
|
"external"=>[
|
161
166
|
],
|
162
167
|
"other"=>[
|
168
|
+
{
|
163
169
|
"name"=>{
|
164
170
|
"first"=>"Hal",
|
165
171
|
"last"=>"Roach"
|
166
172
|
},
|
167
173
|
"role"=>"Contributor",
|
168
174
|
"uuid"=>""
|
175
|
+
},
|
169
176
|
]
|
170
177
|
}
|
171
178
|
```
|
@@ -216,7 +223,7 @@ An array of research outputs associated with the dataset.
|
|
216
223
|
"type": "Chapter",
|
217
224
|
"title": "An interesting chapter title",
|
218
225
|
"uuid": "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"
|
219
|
-
}
|
226
|
+
},
|
220
227
|
]
|
221
228
|
```
|
222
229
|
|
@@ -251,7 +258,7 @@ An array of addresses.
|
|
251
258
|
"postcode"=>"LA1 4YN",
|
252
259
|
"city"=>"Lancaster",
|
253
260
|
"country"=>"United Kingdom"
|
254
|
-
}
|
261
|
+
},
|
255
262
|
]
|
256
263
|
```
|
257
264
|
|
data/lib/puree/collection.rb
CHANGED
@@ -16,25 +16,60 @@ module Puree
|
|
16
16
|
# @param password [String]
|
17
17
|
# @param qty [Integer]
|
18
18
|
# @return [HTTParty::Response]
|
19
|
-
def get(endpoint:nil,
|
19
|
+
def get(endpoint: nil,
|
20
|
+
username: nil,
|
21
|
+
password: nil,
|
22
|
+
limit: 20,
|
23
|
+
offset: 0,
|
24
|
+
created_start: nil,
|
25
|
+
created_end: nil,
|
26
|
+
modified_start: nil,
|
27
|
+
modified_end: nil)
|
20
28
|
# strip any trailing slash
|
21
29
|
@endpoint = endpoint.sub(/(\/)+$/, '')
|
22
30
|
@auth = Base64::strict_encode64(username + ':' + password)
|
23
31
|
|
24
32
|
@options = {
|
25
|
-
latest_api:
|
26
|
-
resource_type:
|
27
|
-
rendering:
|
28
|
-
|
33
|
+
latest_api: true,
|
34
|
+
resource_type: @resource_type.to_sym,
|
35
|
+
rendering: :system,
|
36
|
+
limit: limit,
|
37
|
+
offset: offset,
|
38
|
+
created_start: created_start,
|
39
|
+
created_end: created_end,
|
40
|
+
modified_start: modified_start,
|
41
|
+
modified_end: modified_end
|
29
42
|
}
|
30
43
|
headers = {
|
31
44
|
'Accept' => 'application/xml',
|
32
45
|
'Authorization' => 'Basic ' + @auth
|
33
46
|
}
|
34
47
|
query = {}
|
48
|
+
|
35
49
|
query['rendering'] = @options[:rendering]
|
36
|
-
|
37
|
-
|
50
|
+
|
51
|
+
if @options[:limit]
|
52
|
+
query['window.size'] = @options[:limit]
|
53
|
+
end
|
54
|
+
|
55
|
+
if @options[:offset]
|
56
|
+
query['window.offset'] = @options[:offset]
|
57
|
+
end
|
58
|
+
|
59
|
+
if @options[:created_start]
|
60
|
+
query['createdDate.fromDate'] = @options[:created_start]
|
61
|
+
end
|
62
|
+
|
63
|
+
if @options[:created_end]
|
64
|
+
query['createdDate.toDate'] = @options[:created_end]
|
65
|
+
end
|
66
|
+
|
67
|
+
if @options[:modified_start]
|
68
|
+
query['modifiedDate.fromDate'] = @options[:modified_start]
|
69
|
+
end
|
70
|
+
|
71
|
+
if @options[:modified_end]
|
72
|
+
query['modifiedDate.toDate'] = @options[:modified_end]
|
38
73
|
end
|
39
74
|
|
40
75
|
@response = HTTParty.get(build_url, query: query, headers: headers)
|
@@ -55,23 +90,9 @@ module Puree
|
|
55
90
|
|
56
91
|
|
57
92
|
def collect_uuid
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
if resp.is_a?(Array)
|
62
|
-
arr = resp
|
63
|
-
else
|
64
|
-
arr << resp
|
65
|
-
end
|
66
|
-
arr.each do |a|
|
67
|
-
tableRows = a['div']['table']['tbody']['tr']
|
68
|
-
tableRows.each do |row|
|
69
|
-
if row['th'] === 'UUID'
|
70
|
-
uuid = row['td']
|
71
|
-
@uuids << uuid
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
93
|
+
path = '//renderedItem/@renderedContentUUID'
|
94
|
+
xpath_result = xpath_query path
|
95
|
+
xpath_result.each { |i| @uuids << i.text.strip }
|
75
96
|
end
|
76
97
|
|
77
98
|
|
data/lib/puree/resource.rb
CHANGED
@@ -17,17 +17,22 @@ module Puree
|
|
17
17
|
# @param uuid [String]
|
18
18
|
# @param id [String]
|
19
19
|
# @return [HTTParty::Response]
|
20
|
-
def get(endpoint:nil,
|
20
|
+
def get(endpoint: nil,
|
21
|
+
username: nil,
|
22
|
+
password: nil,
|
23
|
+
uuid: nil,
|
24
|
+
id: nil
|
25
|
+
)
|
21
26
|
# strip any trailing slash
|
22
27
|
@endpoint = endpoint.sub(/(\/)+$/, '')
|
23
28
|
@auth = Base64::strict_encode64(username + ':' + password)
|
24
29
|
|
25
30
|
@options = {
|
26
|
-
latest_api:
|
31
|
+
latest_api: true,
|
27
32
|
resource_type: @resource_type.to_sym,
|
28
|
-
rendering:
|
29
|
-
uuid:
|
30
|
-
id:
|
33
|
+
rendering: :xml_long,
|
34
|
+
uuid: uuid,
|
35
|
+
id: id
|
31
36
|
}
|
32
37
|
headers = {
|
33
38
|
'Accept' => 'application/xml',
|
@@ -35,6 +40,7 @@ module Puree
|
|
35
40
|
}
|
36
41
|
query = {}
|
37
42
|
query['rendering'] = @options[:rendering]
|
43
|
+
|
38
44
|
if @options[:uuid]
|
39
45
|
query['uuids.uuid'] = @options[:uuid]
|
40
46
|
else
|
data/lib/puree/version.rb
CHANGED