puree 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a22ff7fedfd49fa3ae29510a7aa3fd532e3c9838
4
- data.tar.gz: c879d11f1bf415b156e4959be2dde9119574d962
3
+ metadata.gz: 539976142cda876c73eb0caf03ae4b2eca425775
4
+ data.tar.gz: f5896f3afb50cbc67bca6d20124fef8d85ae4052
5
5
  SHA512:
6
- metadata.gz: e3ca6c455e0773a642bd5ad0bc513dc2a940ddc7c081be05deb0bc6ccd63e11789374a0ad70a12ad4caf8eaacff3d3ececb12fcedebe966880fa01cb6a176289
7
- data.tar.gz: cc3a510f29157231b12cb3f47b4b9790638d721583769358b236b45854b98f9d9a9f1ab895d855fd21233494b06520f3c09e7e07ebea9c79fd3223adc763daef
6
+ metadata.gz: a6f35ad8908b500f03ff30f00b38621bf8d570fc5b3c9f53be7e24ef1b7eb024e342fe3d56e8f99b7b8d23cdeaed466e2e3c372cb73b09a0f24e47c17d9a1ed6
7
+ data.tar.gz: 1b6b644bbb9157f345b29a03428805cee300a2982ac44378b5c3aa873fd8487a964bce711bb6f7553eaab3cf426c3c2e1f1abca0a0051738165d3024c67c304a
@@ -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, optionally specifying a quantity (default is 20)
79
- c.get endpoint: endpoint,
80
- username: username,
81
- password: password,
82
- qty: 100000
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
 
@@ -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, username:nil, password:nil, qty: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: true,
26
- resource_type: @resource_type.to_sym,
27
- rendering: :system,
28
- qty: qty
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
- if @options[:qty]
37
- query['window.size'] = @options[:qty]
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
- response_name = service_response_name
59
- resp = @response[response_name]['result']['renderedItem']
60
- arr = []
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
 
@@ -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, username:nil, password:nil, uuid:nil, id: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: true,
31
+ latest_api: true,
27
32
  resource_type: @resource_type.to_sym,
28
- rendering: :xml_long,
29
- uuid: uuid,
30
- id: 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
@@ -1,3 +1,3 @@
1
1
  module Puree
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Albin-Clark