collectionspace-client 0.1.4 → 0.1.5
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 +5 -5
- data/README.md +1 -1
- data/collectionspace-client.gemspec +1 -1
- data/examples/demo.rb +1 -5
- data/examples/export.rb +1 -1
- data/examples/purge-empty-vocabularies.rb +2 -1
- data/lib/collectionspace/client/helpers.rb +16 -22
- data/lib/collectionspace/client/request.rb +3 -3
- data/lib/collectionspace/client/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 102021d7f34434b3f5a79382333ec7677ef7fba8dcdfd2f73daff1a7faa10b59
|
4
|
+
data.tar.gz: 2510a4f0c3932bb08545e9c263c4357faccad8c6183f43f2e8122bef740dc34c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90419be95bd910c0f17e9f0adc9918f702d985278a7b91d0cd531179bacac3e2ce1a1c08aa98510fb7ed66b258451f31923a2013c488110b4e7262383d199feb
|
7
|
+
data.tar.gz: 031e9d9b52bbe9a83a8c3234bc52f9cbcc5a09c89340c7016dc9d8e5075582954945632cdc133426f42fcbeb6d2fc56995fe1cc7059ca2ba1e30eee47f2b62ca
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "json"
|
23
23
|
spec.add_dependency "nokogiri"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "rspec"
|
28
28
|
spec.add_development_dependency "vcr"
|
data/examples/demo.rb
CHANGED
@@ -13,12 +13,8 @@ if response.status_code == 200
|
|
13
13
|
ap response.xml
|
14
14
|
end
|
15
15
|
|
16
|
-
# GET ALL ACQUISITIONS AND PRINT TO CONSOLE
|
17
|
-
acquisitions = client.all('acquisitions')
|
18
|
-
ap acquisitions
|
19
|
-
|
20
16
|
# GET ALL INTAKE RECORDS AND PROCESS PER PAGE (INSTEAD OF WAITING FOR ALL)
|
21
|
-
client.all('
|
17
|
+
client.all('media').each do |item|
|
22
18
|
uri = item["uri"]
|
23
19
|
intake = client.get uri
|
24
20
|
ap intake.parsed
|
data/examples/export.rb
CHANGED
@@ -21,7 +21,7 @@ client = CollectionSpace::Client.new
|
|
21
21
|
client.config.throttle = 1
|
22
22
|
|
23
23
|
# GET ALL CATALOGING RECORDS AND DUMP THE XML IF UPDATED SINCE 3 DAYS AGO
|
24
|
-
client.all('collectionobjects') do |item|
|
24
|
+
client.all('collectionobjects').each do |item|
|
25
25
|
updated = Date.parse item["updatedAt"]
|
26
26
|
if updated > Date.parse(14.days.ago.to_s)
|
27
27
|
collectionobject = client.get item["uri"]
|
@@ -6,8 +6,9 @@ require 'collectionspace/client'
|
|
6
6
|
client = CollectionSpace::Client.new
|
7
7
|
client.config.throttle = 1
|
8
8
|
|
9
|
-
client.all('vocabularies') do |item|
|
9
|
+
client.all('vocabularies').each do |item|
|
10
10
|
uri = item["uri"]
|
11
|
+
puts "Checking vocabulary: #{uri}"
|
11
12
|
if client.count("#{uri}/items") == 0
|
12
13
|
puts "Purging empty vocabulary:\t#{item['displayName']} (#{item['csid']})"
|
13
14
|
# YOU WOULD UNCOMMENT THIS TO ACTUALLY PERFORM THE PURGE ...
|
@@ -19,29 +19,23 @@ module CollectionSpace
|
|
19
19
|
module Helpers
|
20
20
|
|
21
21
|
# get ALL records at path by paging through record set
|
22
|
-
|
23
|
-
def all(path, options = {}, &block)
|
24
|
-
all = []
|
22
|
+
def all(path, options = {})
|
25
23
|
list_type, list_item = get_list_types(path)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
list_items.each { |item| yield item if block_given? }
|
42
|
-
all.concat list_items
|
43
|
-
end
|
44
|
-
all
|
24
|
+
Enumerator.new do |yielder|
|
25
|
+
page = 0
|
26
|
+
loop do
|
27
|
+
result = request('GET', path, options.merge(query: { pgNum: page }))
|
28
|
+
raise StopIteration unless result.parsed[list_type].key?('itemsInPage')
|
29
|
+
|
30
|
+
items = result.parsed[list_type]['itemsInPage'].to_i
|
31
|
+
raise StopIteration if items == 0
|
32
|
+
|
33
|
+
list_items = result.parsed[list_type][list_item]
|
34
|
+
list_items = [list_items] if items == 1
|
35
|
+
list_items.each { |item| yielder << item }
|
36
|
+
page += 1
|
37
|
+
end
|
38
|
+
end.lazy
|
45
39
|
end
|
46
40
|
|
47
41
|
def count(path)
|
@@ -21,9 +21,9 @@ module CollectionSpace
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def initialize(config, method = "GET", path = "", options = {})
|
24
|
-
@config
|
25
|
-
@method
|
26
|
-
@path
|
24
|
+
@config = config
|
25
|
+
@method = method.downcase.to_sym
|
26
|
+
@path = path.gsub(/^\//, '')
|
27
27
|
|
28
28
|
@auth = {
|
29
29
|
username: config.username,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collectionspace-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cooper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.6
|
187
|
+
rubygems_version: 2.7.6
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: CollectionSpace API client.
|