collectionspace-client 0.14.1 → 0.15.1
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 +4 -4
- data/.git-blame-ignore-revs +8 -0
- data/.github/workflows/ci.yml +30 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +4 -8
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +109 -0
- data/README.md +4 -3
- data/Rakefile +12 -11
- data/bin/console +6 -6
- data/bin/rspec +1 -1
- data/collectionspace-client.gemspec +28 -25
- data/examples/batches.rb +50 -0
- data/examples/demo.rb +8 -8
- data/examples/media_with_external_file.rb +9 -9
- data/examples/purge_empty_vocabs.rb +8 -8
- data/examples/reports.rb +36 -169
- data/examples/reset_media_blob.rb +35 -0
- data/examples/search.rb +15 -15
- data/examples/update_password.rb +1 -1
- data/lib/collectionspace/client/batch.rb +55 -0
- data/lib/collectionspace/client/client.rb +16 -5
- data/lib/collectionspace/client/configuration.rb +2 -1
- data/lib/collectionspace/client/helpers.rb +107 -46
- data/lib/collectionspace/client/refname.rb +22 -22
- data/lib/collectionspace/client/report.rb +180 -0
- data/lib/collectionspace/client/request.rb +10 -9
- data/lib/collectionspace/client/response.rb +6 -6
- data/lib/collectionspace/client/search.rb +4 -4
- data/lib/collectionspace/client/service.rb +129 -117
- data/lib/collectionspace/client/template.rb +4 -4
- data/lib/collectionspace/client/templates/batch.xml.erb +18 -0
- data/lib/collectionspace/client/version.rb +1 -1
- data/lib/collectionspace/client.rb +18 -16
- metadata +30 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9f5c5e51e9a99c4ac0ab4d9a9e0ac8cecac7bc38391c3cc57d3c987394110de
|
4
|
+
data.tar.gz: 3106c95bf948acacb6b109b2c672ef9e2e71d51b6d9ee16b40794c4c98b8d2d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa8523a50202bebcaf3a09151e3376251b5575e7e344a32624016979f8e49de45193cb630f0a5be1acec660a94f959ef03e935ed1042a244a52fe076c92c067
|
7
|
+
data.tar.gz: 9074177d65643755b34380f53ecf3bcfd77ec3c5e7d1c8af92df2e11e0edeac89ae6223e4645f7aac75f6983e826a22055021017259c27b743c08a86eb610e40
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [pull_request]
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
tests:
|
6
|
+
name: Tests
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby-version: ['3.2', '3.1', '3.0', '2.7']
|
11
|
+
steps:
|
12
|
+
- name: Checkout code
|
13
|
+
uses: actions/checkout@v3
|
14
|
+
|
15
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
bundler-cache: true
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
|
24
|
+
- name: Lint
|
25
|
+
run: |
|
26
|
+
bundle exec standardrb
|
27
|
+
|
28
|
+
- name: Run tests
|
29
|
+
run: |
|
30
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
3.2.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
collectionspace-client (0.15.1)
|
5
|
+
httparty
|
6
|
+
json
|
7
|
+
nokogiri
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.1)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
awesome_print (1.9.2)
|
16
|
+
coderay (1.1.3)
|
17
|
+
crack (0.4.5)
|
18
|
+
rexml
|
19
|
+
diff-lcs (1.5.0)
|
20
|
+
docile (1.4.0)
|
21
|
+
hashdiff (1.0.1)
|
22
|
+
httparty (0.21.0)
|
23
|
+
mini_mime (>= 1.0.0)
|
24
|
+
multi_xml (>= 0.5.2)
|
25
|
+
json (2.6.3)
|
26
|
+
language_server-protocol (3.17.0.3)
|
27
|
+
method_source (1.0.0)
|
28
|
+
mini_mime (1.1.2)
|
29
|
+
mini_portile2 (2.8.1)
|
30
|
+
multi_xml (0.6.0)
|
31
|
+
nokogiri (1.14.2)
|
32
|
+
mini_portile2 (~> 2.8.0)
|
33
|
+
racc (~> 1.4)
|
34
|
+
parallel (1.22.1)
|
35
|
+
parser (3.2.1.0)
|
36
|
+
ast (~> 2.4.1)
|
37
|
+
pry (0.14.2)
|
38
|
+
coderay (~> 1.1)
|
39
|
+
method_source (~> 1.0)
|
40
|
+
public_suffix (5.0.1)
|
41
|
+
racc (1.6.2)
|
42
|
+
rainbow (3.1.1)
|
43
|
+
rake (13.0.6)
|
44
|
+
regexp_parser (2.7.0)
|
45
|
+
rexml (3.2.5)
|
46
|
+
rspec (3.12.0)
|
47
|
+
rspec-core (~> 3.12.0)
|
48
|
+
rspec-expectations (~> 3.12.0)
|
49
|
+
rspec-mocks (~> 3.12.0)
|
50
|
+
rspec-core (3.12.1)
|
51
|
+
rspec-support (~> 3.12.0)
|
52
|
+
rspec-expectations (3.12.2)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.12.0)
|
55
|
+
rspec-mocks (3.12.3)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.12.0)
|
58
|
+
rspec-support (3.12.0)
|
59
|
+
rubocop (1.44.1)
|
60
|
+
json (~> 2.3)
|
61
|
+
parallel (~> 1.10)
|
62
|
+
parser (>= 3.2.0.0)
|
63
|
+
rainbow (>= 2.2.2, < 4.0)
|
64
|
+
regexp_parser (>= 1.8, < 3.0)
|
65
|
+
rexml (>= 3.2.5, < 4.0)
|
66
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
69
|
+
rubocop-ast (1.27.0)
|
70
|
+
parser (>= 3.2.1.0)
|
71
|
+
rubocop-performance (1.15.2)
|
72
|
+
rubocop (>= 1.7.0, < 2.0)
|
73
|
+
rubocop-ast (>= 0.4.0)
|
74
|
+
ruby-progressbar (1.12.0)
|
75
|
+
simplecov (0.22.0)
|
76
|
+
docile (~> 1.1)
|
77
|
+
simplecov-html (~> 0.11)
|
78
|
+
simplecov_json_formatter (~> 0.1)
|
79
|
+
simplecov-html (0.12.3)
|
80
|
+
simplecov_json_formatter (0.1.4)
|
81
|
+
standard (1.24.3)
|
82
|
+
language_server-protocol (~> 3.17.0.2)
|
83
|
+
rubocop (= 1.44.1)
|
84
|
+
rubocop-performance (= 1.15.2)
|
85
|
+
unicode-display_width (2.4.2)
|
86
|
+
vcr (6.1.0)
|
87
|
+
webmock (3.18.1)
|
88
|
+
addressable (>= 2.8.0)
|
89
|
+
crack (>= 0.3.2)
|
90
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
awesome_print
|
97
|
+
bundler
|
98
|
+
collectionspace-client!
|
99
|
+
pry
|
100
|
+
rake (~> 13.0)
|
101
|
+
rspec
|
102
|
+
rubocop
|
103
|
+
simplecov (~> 0.21)
|
104
|
+
standard
|
105
|
+
vcr (~> 6.1)
|
106
|
+
webmock
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
2.4.7
|
data/README.md
CHANGED
@@ -37,10 +37,11 @@ bundle exec rake
|
|
37
37
|
```bash
|
38
38
|
gem install gem-release
|
39
39
|
# https://github.com/svenfuchs/gem-release#gem-bump
|
40
|
-
gem bump --version $VERSION
|
40
|
+
gem bump --version $VERSION
|
41
41
|
# i.e.
|
42
|
-
gem bump --version minor --
|
43
|
-
gem bump --version minor
|
42
|
+
gem bump --version minor --pretend # dryrun
|
43
|
+
gem bump --version minor # do it for real
|
44
|
+
bundle # update gem version in Gemfile.lock
|
44
45
|
# PR and merge will publish new version
|
45
46
|
```
|
46
47
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "base64"
|
6
|
+
require "collectionspace/client"
|
7
|
+
require "standard/rake"
|
7
8
|
|
8
9
|
RSpec::Core::RakeTask.new(:spec)
|
9
10
|
|
@@ -16,10 +17,10 @@ end
|
|
16
17
|
namespace :cli do
|
17
18
|
desc "Update a user's password: requires an Admin level account to perform the update"
|
18
19
|
task :update_password, [:endpoint, :admin, :password, :user, :new_password] do |_t, args|
|
19
|
-
endpoint
|
20
|
-
admin
|
21
|
-
password
|
22
|
-
user
|
20
|
+
endpoint = args[:endpoint]
|
21
|
+
admin = args[:admin]
|
22
|
+
password = args[:password]
|
23
|
+
user = args[:user]
|
23
24
|
new_password = args[:new_password]
|
24
25
|
|
25
26
|
client = CollectionSpace::Client.new(
|
@@ -37,9 +38,9 @@ namespace :cli do
|
|
37
38
|
</ns2:accounts_common>
|
38
39
|
XML
|
39
40
|
|
40
|
-
client.all(
|
41
|
-
if account[
|
42
|
-
puts client.put(account[
|
41
|
+
client.all("accounts").each do |account|
|
42
|
+
if account["email"] == user
|
43
|
+
puts client.put(account["uri"], payload).parsed
|
43
44
|
break
|
44
45
|
end
|
45
46
|
end
|
data/bin/console
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require
|
4
|
+
require "bundler/setup"
|
5
5
|
Bundler.require(:tools)
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require
|
7
|
+
require_relative "../lib/collectionspace/client"
|
8
|
+
require "irb"
|
9
9
|
|
10
10
|
module CollectionSpace
|
11
11
|
::CS = CollectionSpace # alias only in console to minimize typing
|
@@ -15,9 +15,9 @@ module CollectionSpace
|
|
15
15
|
def coredev
|
16
16
|
CollectionSpace::Client.new(
|
17
17
|
CollectionSpace::Configuration.new(
|
18
|
-
base_uri:
|
19
|
-
username:
|
20
|
-
password:
|
18
|
+
base_uri: "https://core.dev.collectionspace.org/cspace-services",
|
19
|
+
username: "admin@core.collectionspace.org",
|
20
|
+
password: "Administrator"
|
21
21
|
)
|
22
22
|
)
|
23
23
|
end
|
data/bin/rspec
CHANGED
@@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
15
15
|
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
|
-
if
|
18
|
+
if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
|
19
19
|
load(bundle_binstub)
|
20
20
|
else
|
21
21
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
@@ -1,33 +1,36 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
3
|
+
require "collectionspace/client/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name
|
7
|
-
spec.version
|
8
|
-
spec.authors
|
9
|
-
spec.email
|
6
|
+
spec.name = "collectionspace-client"
|
7
|
+
spec.version = CollectionSpace::Client::VERSION
|
8
|
+
spec.authors = ["Mark Cooper"]
|
9
|
+
spec.email = ["mark.cooper@lyrasis.org"]
|
10
10
|
|
11
|
-
spec.summary
|
12
|
-
spec.
|
13
|
-
spec.
|
11
|
+
spec.summary = "CollectionSpace API client."
|
12
|
+
spec.description = "Client for interacting with CollectionSpace Services API"
|
13
|
+
spec.homepage = "https://github.com/lyrasis/collectionspace-client.git"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.7.4"
|
14
16
|
|
15
|
-
spec.files
|
16
|
-
spec.bindir
|
17
|
-
spec.executables
|
18
|
-
spec.require_paths = [
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
19
21
|
|
20
|
-
spec.add_dependency
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
22
|
+
spec.add_dependency "httparty"
|
23
|
+
spec.add_dependency "json"
|
24
|
+
spec.add_dependency "nokogiri"
|
23
25
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
26
|
+
spec.add_development_dependency "awesome_print"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
+
spec.add_development_dependency "rspec"
|
31
|
+
spec.add_development_dependency "rubocop"
|
32
|
+
spec.add_development_dependency "simplecov", "~> 0.21"
|
33
|
+
spec.add_development_dependency "standard"
|
34
|
+
spec.add_development_dependency "vcr", "~> 6.1"
|
35
|
+
spec.add_development_dependency "webmock"
|
33
36
|
end
|
data/examples/batches.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Install batches (aka data updates)
|
4
|
+
# Based on:
|
5
|
+
# https://github.com/collectionspace/Tools/blob/master/scripts/install_batch_records.sh
|
6
|
+
# https://github.com/collectionspace/Tools/blob/master/scripts/create-batch-records.sh
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
9
|
+
require "awesome_print"
|
10
|
+
require "collectionspace/client"
|
11
|
+
require "pry"
|
12
|
+
|
13
|
+
STANDARD_TENANTS = [
|
14
|
+
:anthro,
|
15
|
+
:bonsai,
|
16
|
+
:botgarden,
|
17
|
+
:core,
|
18
|
+
:fcart,
|
19
|
+
:herbarium,
|
20
|
+
:lhmc,
|
21
|
+
:materials,
|
22
|
+
:publicart
|
23
|
+
]
|
24
|
+
|
25
|
+
STANDARD_BATCHES = CollectionSpace::Batch.all
|
26
|
+
|
27
|
+
STANDARD_TENANTS.each do |tenant|
|
28
|
+
client = CollectionSpace::Client.new(
|
29
|
+
CollectionSpace::Configuration.new(
|
30
|
+
base_uri: "https://#{tenant}.dev.collectionspace.org/cspace-services",
|
31
|
+
username: "admin@#{tenant}.collectionspace.org",
|
32
|
+
password: "Administrator"
|
33
|
+
)
|
34
|
+
)
|
35
|
+
base = client.config.base_uri
|
36
|
+
.delete_suffix("/cspace-services")
|
37
|
+
.delete_prefix("https://")
|
38
|
+
merge_doctypes = client.authority_doctypes
|
39
|
+
|
40
|
+
STANDARD_BATCHES.each do |batch|
|
41
|
+
batch[:doctype] = merge_doctypes if batch[:name] == "Merge Authority Items"
|
42
|
+
response = client.add_batch(batch)
|
43
|
+
if response.result.success?
|
44
|
+
puts "Added #{batch[:name]} to #{base}"
|
45
|
+
else
|
46
|
+
puts "FAILED TO ADD #{batch[:name]} to #{base}"
|
47
|
+
puts response.inspect
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/examples/demo.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
4
|
-
require
|
5
|
-
require
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
|
+
require "awesome_print"
|
5
|
+
require "collectionspace/client"
|
6
6
|
|
7
7
|
client = CollectionSpace::Client.new(
|
8
8
|
CollectionSpace::Configuration.new(
|
9
|
-
base_uri:
|
10
|
-
username:
|
11
|
-
password:
|
9
|
+
base_uri: "https://core.dev.collectionspace.org/cspace-services",
|
10
|
+
username: "admin@core.collectionspace.org",
|
11
|
+
password: "Administrator"
|
12
12
|
)
|
13
13
|
)
|
14
14
|
|
15
15
|
# GET REQUEST FOR CONDITIONCHECK RECORDS AND PRINT THE PARSED RESPONSE AND XML
|
16
|
-
response = client.get(
|
16
|
+
response = client.get("conditionchecks")
|
17
17
|
ap response.parsed if response.result.success?
|
18
18
|
|
19
19
|
# GET ALL PERSON RECORDS AND PROCESS PER PAGE (INSTEAD OF WAITING FOR ALL)
|
20
|
-
client.all(
|
20
|
+
client.all("personauthorities/urn:cspace:name(person)/items").each do |item|
|
21
21
|
puts item
|
22
22
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
4
|
-
require
|
5
|
-
require
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
|
+
require "awesome_print"
|
5
|
+
require "collectionspace/client"
|
6
6
|
|
7
7
|
client = CollectionSpace::Client.new(
|
8
8
|
CollectionSpace::Configuration.new(
|
9
|
-
base_uri:
|
10
|
-
username:
|
11
|
-
password:
|
9
|
+
base_uri: "https://core.dev.collectionspace.org/cspace-services",
|
10
|
+
username: "admin@core.collectionspace.org",
|
11
|
+
password: "Administrator"
|
12
12
|
)
|
13
13
|
)
|
14
14
|
client.config.throttle = 1
|
15
15
|
|
16
|
-
media_url =
|
16
|
+
media_url = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
|
17
17
|
media = <<-XML
|
18
18
|
<?xml version="1.0" encoding="UTF-8"?>
|
19
19
|
<document name="media">
|
@@ -24,5 +24,5 @@ media = <<-XML
|
|
24
24
|
</document>
|
25
25
|
XML
|
26
26
|
|
27
|
-
response = client.post(
|
28
|
-
puts response.result.headers[
|
27
|
+
response = client.post("media", media, query: {"blobUri" => media_url})
|
28
|
+
puts response.result.headers["location"] if response.result.success?
|
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
4
|
-
require
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
4
|
+
require "collectionspace/client"
|
5
5
|
|
6
6
|
client = CollectionSpace::Client.new(
|
7
7
|
CollectionSpace::Configuration.new(
|
8
|
-
base_uri:
|
9
|
-
username:
|
10
|
-
password:
|
8
|
+
base_uri: "https://core.dev.collectionspace.org/cspace-services",
|
9
|
+
username: "admin@core.collectionspace.org",
|
10
|
+
password: "Administrator"
|
11
11
|
)
|
12
12
|
)
|
13
13
|
client.config.throttle = 1
|
14
14
|
|
15
|
-
client.all(
|
16
|
-
uri = item[
|
15
|
+
client.all("vocabularies").each do |item|
|
16
|
+
uri = item["uri"]
|
17
17
|
puts "Checking vocabulary: #{uri}"
|
18
18
|
next unless client.count("#{uri}/items").zero?
|
19
19
|
|
20
|
-
puts "Purging empty vocabulary:\t#{item[
|
20
|
+
puts "Purging empty vocabulary:\t#{item["displayName"]} (#{item["csid"]})"
|
21
21
|
client.delete uri
|
22
22
|
end
|