collectionspace-client 0.14.1 → 0.15.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
  SHA256:
3
- metadata.gz: 89651eb1e87693f52f835cbe34eccc510f40888db54696a41082ae114a084817
4
- data.tar.gz: e3c161e2a64848a1f0065e18da8aa23ad6117995daf62538cf5437bc0192cfc6
3
+ metadata.gz: d797561c0b44c79ce0bda224d05ff05de6fa7c932b2c33d4a9c888116c6d6fbb
4
+ data.tar.gz: bfbd46caa314f5fc6620b468e14e262983f3f52a444622ef55669c60ad5c4f84
5
5
  SHA512:
6
- metadata.gz: 7d9d9989ff3272bffe9fc99c19036e72004b7e672bc3d02ce5556b69bb478a441a78768d394685534ba83144d76054903bac35fa4f715c50cff32b838e60132c
7
- data.tar.gz: 7bea83ddcadf1aa7019e196c8ede59cd9e9ffd6fdd9b23a90ff7d0f89666122cb6c865a0b422287cb8a04d4032718e493e48f23b6356d65039a1bde00626e53b
6
+ metadata.gz: 697f5207854022997a0acf1e2249113c763447a5597677d4b7f7b157244467a2c0bee0d163d152ee2191950e41c9478a21443f967087c87e85a765c137542865
7
+ data.tar.gz: 71d59341de8048599691df601042915c803c10c6710982c76eeda366684aab1ba27ce694a285bcf349d9de08faba78d4951838114ff96059f24c417dc6b9f1a8
@@ -0,0 +1,8 @@
1
+ # Appease standard
2
+ 63444da90ce50afd5d282c6cfb5ca6dc3210be7d
3
+ # Lint/format
4
+ 0dc6263edaed69d0d472626974a1317c059b3337
5
+ # Make standard happy
6
+ 5cbdb2d41997f05e6cbad814c11e2893706ac152
7
+ # Use standard for linting
8
+ e5ba9f76a333609734079c3ec6102c2cbe4974b7
@@ -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']
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
@@ -1,4 +1,6 @@
1
1
  *.gem
2
+ *.jpg
3
+ *.pdf
2
4
  *.swp
3
5
  /.bundle/
4
6
  /.vscode
data/.rubocop.yml CHANGED
@@ -1,8 +1,4 @@
1
- # .rubocop.yml
2
- AllCops:
3
- Exclude:
4
- - '*.gemspec'
5
- - '*.rake'
6
- Metrics/BlockLength:
7
- Exclude:
8
- - !ruby/regexp /_spec.rb/
1
+ require: standard
2
+
3
+ inherit_gem:
4
+ standard: config/base.yml
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.4
1
+ 3.2.1
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in collectionspace-client.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -39,8 +39,8 @@ gem install gem-release
39
39
  # https://github.com/svenfuchs/gem-release#gem-bump
40
40
  gem bump --version $VERSION --tag
41
41
  # i.e.
42
- gem bump --version minor --tag --pretend # dryrun
43
- gem bump --version minor --tag # do it for real
42
+ gem bump --version minor --pretend # dryrun
43
+ gem bump --version minor # do it for real
44
44
  # PR and merge will publish new version
45
45
  ```
46
46
 
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'base64'
6
- require 'collectionspace/client'
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 = args[:endpoint]
20
- admin = args[:admin]
21
- password = args[:password]
22
- user = args[: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('accounts').each do |account|
41
- if account['email'] == user
42
- puts client.put(account['uri'], payload).parsed
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 'bundler/setup'
4
+ require "bundler/setup"
5
5
  Bundler.require(:tools)
6
6
 
7
- require_relative '../lib/collectionspace/client'
8
- require 'irb'
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: 'https://core.dev.collectionspace.org/cspace-services',
19
- username: 'admin@core.collectionspace.org',
20
- password: 'Administrator'
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 File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
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,34 @@
1
- lib = File.expand_path('lib', __dir__)
1
+ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'collectionspace/client/version'
3
+ require "collectionspace/client/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'collectionspace-client'
7
- spec.version = CollectionSpace::Client::VERSION
8
- spec.authors = ['Mark Cooper']
9
- spec.email = ['mark.cooper@lyrasis.org']
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 = 'CollectionSpace API client.'
12
- spec.homepage = 'https://github.com/lyrasis/collectionspace-client.git'
13
- spec.license = 'MIT'
11
+ spec.summary = "CollectionSpace API client."
12
+ spec.homepage = "https://github.com/lyrasis/collectionspace-client.git"
13
+ spec.license = "MIT"
14
14
 
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
- spec.bindir = 'exe'
17
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
- spec.require_paths = ['lib']
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency 'httparty'
21
- spec.add_dependency 'json'
22
- spec.add_dependency 'nokogiri'
20
+ spec.add_dependency "httparty"
21
+ spec.add_dependency "json"
22
+ spec.add_dependency "nokogiri"
23
23
 
24
- spec.add_development_dependency 'awesome_print'
25
- spec.add_development_dependency 'bundler'
26
- spec.add_development_dependency 'pry'
27
- spec.add_development_dependency 'rake', '~> 10.0'
28
- spec.add_development_dependency 'rspec'
29
- spec.add_development_dependency 'rubocop'
30
- spec.add_development_dependency 'simplecov', '~> 0.21'
31
- spec.add_development_dependency 'vcr'
32
- spec.add_development_dependency 'webmock'
24
+ spec.add_development_dependency "awesome_print"
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "rubocop"
30
+ spec.add_development_dependency "simplecov", "~> 0.21"
31
+ spec.add_development_dependency "standard"
32
+ spec.add_development_dependency "vcr", "~> 6.1"
33
+ spec.add_development_dependency "webmock"
33
34
  end
@@ -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('../lib', __dir__)
4
- require 'awesome_print'
5
- require 'collectionspace/client'
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: 'https://core.dev.collectionspace.org/cspace-services',
10
- username: 'admin@core.collectionspace.org',
11
- password: 'Administrator'
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('conditionchecks')
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('personauthorities/urn:cspace:name(person)/items').each do |item|
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('../lib', __dir__)
4
- require 'awesome_print'
5
- require 'collectionspace/client'
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: 'https://core.dev.collectionspace.org/cspace-services',
10
- username: 'admin@core.collectionspace.org',
11
- password: 'Administrator'
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 = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'
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('media', media, query: { 'blobUri' => media_url })
28
- puts response.result.headers['location'] if response.result.success?
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('../lib', __dir__)
4
- require 'collectionspace/client'
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: 'https://core.dev.collectionspace.org/cspace-services',
9
- username: 'admin@core.collectionspace.org',
10
- password: 'Administrator'
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('vocabularies').each do |item|
16
- uri = item['uri']
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['displayName']} (#{item['csid']})"
20
+ puts "Purging empty vocabulary:\t#{item["displayName"]} (#{item["csid"]})"
21
21
  client.delete uri
22
22
  end
data/examples/reports.rb CHANGED
@@ -1,178 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
- require 'awesome_print'
5
- require 'collectionspace/client'
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "awesome_print"
5
+ require "collectionspace/client"
6
6
 
7
- client = CollectionSpace::Client.new(
8
- CollectionSpace::Configuration.new(
9
- base_uri: 'https://core.dev.collectionspace.org/cspace-services',
10
- username: 'admin@core.collectionspace.org',
11
- password: 'Administrator'
12
- )
13
- )
7
+ STANDARD_TENANTS = [
8
+ :anthro,
9
+ :bonsai,
10
+ :botgarden,
11
+ :core,
12
+ :fcart,
13
+ :herbarium,
14
+ :lhmc,
15
+ :materials,
16
+ :publicart
17
+ ]
14
18
 
15
19
  # https://github.com/collectionspace/Tools/blob/master/scripts/install_report_records.sh
16
20
  # https://github.com/collectionspace/Tools/blob/master/scripts/create-report-records.sh
17
21
 
18
- STANDARD_REPORTS = [
19
- {
20
- name: 'Acquisition Summary',
21
- notes: 'An acquisition summary report. Runs on a single record only.',
22
- doctype: 'Acquisition',
23
- supports_single_doc: 'true',
24
- supports_doc_list: 'false',
25
- supports_group: 'false',
26
- supports_no_context: 'false',
27
- filename: 'acq_basic.jrxml',
28
- mimetype: 'application/pdf'
29
- },
30
- {
31
- name: 'Acquisition Basic List',
32
- notes: 'Catalog info for objects related to an acquisition record. Runs on a single record only.',
33
- doctype: 'Acquisition',
34
- supports_single_doc: 'true',
35
- supports_doc_list: 'false',
36
- supports_group: 'false',
37
- supports_no_context: 'false',
38
- filename: 'Acq_List_Basic.jrxml',
39
- mimetype: 'application/pdf'
40
- },
41
- {
42
- name: 'Condition Check Basic List',
43
- notes: 'Catalog info for objects related to a condition check record. Runs on a single record only.',
44
- doctype: 'Conditioncheck',
45
- supports_single_doc: 'true',
46
- supports_doc_list: 'false',
47
- supports_group: 'false',
48
- supports_no_context: 'false',
49
- filename: 'CC_List_Basic.jrxml',
50
- mimetype: 'application/pdf'
51
- },
52
- {
53
- name: 'Exhibition Basic List',
54
- notes: 'Catalog info for objects related to a exhibition record. Runs on a single record only.',
55
- doctype: 'Exhibition',
56
- supports_single_doc: 'true',
57
- supports_doc_list: 'false',
58
- supports_group: 'false',
59
- supports_no_context: 'false',
60
- filename: 'Exhibition_List_Basic.jrxml',
61
- mimetype: 'application/pdf'
62
- },
63
- {
64
- name: 'Group Basic List',
65
- notes: 'Catalog info for objects related to a group record. Runs on a single record only.',
66
- doctype: 'Group',
67
- supports_single_doc: 'true',
68
- supports_doc_list: 'false',
69
- supports_group: 'false',
70
- supports_no_context: 'false',
71
- filename: 'Group_List_Basic.jrxml',
72
- mimetype: 'application/pdf'
73
- },
74
- {
75
- name: 'Loan In Basic List',
76
- notes: 'Catalog info for objects related to a loan in record. Runs on a single record only.',
77
- doctype: 'Loanin',
78
- supports_single_doc: 'true',
79
- supports_doc_list: 'false',
80
- supports_group: 'false',
81
- supports_no_context: 'false',
82
- filename: 'LoansIn_List_Basic.jrxml',
83
- mimetype: 'application/pdf'
84
- },
85
- {
86
- name: 'Loan Out Basic List',
87
- notes: 'Catalog info for objects related to a loan out record. Runs on a single record only.',
88
- doctype: 'Loanout',
89
- supports_single_doc: 'true',
90
- supports_doc_list: 'false',
91
- supports_group: 'false',
92
- supports_no_context: 'false',
93
- filename: 'LoansOut_List_Basic.jrxml',
94
- mimetype: 'application/pdf'
95
- },
96
- {
97
- name: 'Acquisition Ethnographic Object List',
98
- notes: 'Core acquisition report. Runs on a single record only.',
99
- doctype: 'Acquisition',
100
- supports_single_doc: 'true',
101
- supports_doc_list: 'false',
102
- supports_group: 'false',
103
- supports_no_context: 'false',
104
- filename: 'coreAcquisition.jrxml',
105
- mimetype: 'application/pdf'
106
- },
107
- {
108
- name: 'Group Object Ethnographic Object List',
109
- notes: 'Core group object report. Runs on a single record only.',
110
- doctype: 'Group',
111
- supports_single_doc: 'true',
112
- supports_doc_list: 'false',
113
- supports_group: 'false',
114
- supports_no_context: 'false',
115
- filename: 'coreGroupObject.jrxml',
116
- mimetype: 'application/pdf'
117
- },
118
- {
119
- name: 'Intake Ethnographic Object List',
120
- notes: 'Core intake report. Runs on a single record only.',
121
- doctype: 'Intake',
122
- supports_single_doc: 'true',
123
- supports_doc_list: 'false',
124
- supports_group: 'false',
125
- supports_no_context: 'false',
126
- filename: 'coreIntake.jrxml',
127
- mimetype: 'application/pdf'
128
- },
129
- {
130
- name: 'Loan In Ethnographic Object List',
131
- notes: 'Core loan in report. Runs on a single record only.',
132
- doctype: 'Loanin',
133
- supports_single_doc: 'true',
134
- supports_doc_list: 'false',
135
- supports_group: 'false',
136
- supports_no_context: 'false',
137
- filename: 'coreLoanIn.jrxml',
138
- mimetype: 'application/pdf'
139
- },
140
- {
141
- name: 'Loan Out Ethnographic Object List',
142
- notes: 'Core loan out report. Runs on a single record only.',
143
- doctype: 'Loanout',
144
- supports_single_doc: 'true',
145
- supports_doc_list: 'false',
146
- supports_group: 'false',
147
- supports_no_context: 'false',
148
- filename: 'coreLoanOut.jrxml',
149
- mimetype: 'application/pdf'
150
- },
151
- {
152
- name: 'Object Exit Ethnographic Object List',
153
- notes: 'Core object exit report. Runs on a single record only.',
154
- doctype: 'ObjectExit',
155
- supports_single_doc: 'true',
156
- supports_doc_list: 'false',
157
- supports_group: 'false',
158
- supports_no_context: 'false',
159
- filename: 'coreObjectExit.jrxml',
160
- mimetype: 'application/pdf'
161
- },
162
- {
163
- name: 'Systematic Inventory',
164
- notes: 'Generate a checklist for performing an inventory on a range of storage locations. Runs on all records, using the provided start and end locations.',
165
- doctype: 'Locationitem',
166
- supports_single_doc: 'false',
167
- supports_doc_list: 'false',
168
- supports_group: 'false',
169
- supports_no_context: 'true',
170
- filename: 'systematicInventory.jrxml',
171
- mimetype: 'application/pdf'
172
- }
173
- ]
22
+ STANDARD_REPORTS = CollectionSpace::Report.all
23
+
24
+ STANDARD_TENANTS.each do |tenant|
25
+ client = CollectionSpace::Client.new(
26
+ CollectionSpace::Configuration.new(
27
+ base_uri: "https://#{tenant}.dev.collectionspace.org/cspace-services",
28
+ username: "admin@#{tenant}.collectionspace.org",
29
+ password: "Administrator"
30
+ )
31
+ )
32
+ base = client.config.base_uri
33
+ .delete_suffix("/cspace-services")
34
+ .delete_prefix("https://")
174
35
 
175
- STANDARD_REPORTS.each do |report|
176
- response = client.add_report(report)
177
- puts response.inspect
36
+ STANDARD_REPORTS.each do |report|
37
+ response = client.add_report(report)
38
+ if response.result.success?
39
+ puts "Added #{report[:name]} to #{base}"
40
+ else
41
+ puts "FAILED TO ADD #{report[:name]} to #{base}"
42
+ puts response.inspect
43
+ end
44
+ end
178
45
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "awesome_print"
5
+ require "collectionspace/client"
6
+ require "csv"
7
+
8
+ client = CollectionSpace::Client.new(
9
+ CollectionSpace::Configuration.new(
10
+ base_uri: "https://core.dev.collectionspace.org/cspace-services",
11
+ username: "admin@core.collectionspace.org",
12
+ password: "Administrator"
13
+ )
14
+ )
15
+ client.config.throttle = 1
16
+
17
+ path = File.expand_path("~/your/path/here.csv")
18
+
19
+ CSV.foreach(path, headers: true) do |row|
20
+ client.reset_media_blob(
21
+ id: row["identificationnumber"],
22
+ url: row["mediafileuri"],
23
+ verbose: true,
24
+ # client files are on same server as CS instance, and ingestable
25
+ # file paths do not all parse as URIs safely
26
+ ensure_safe_url: false,
27
+ # This example script used to fix media where the blobs had already
28
+ # been deleted, but the blobcsid value was not removed from the
29
+ # media record. Attempts to delete the media failed, so this option
30
+ # was used to add new blobs without attempting to delete the already
31
+ # deleted old blobs (and erroring out)
32
+ delete_existing_blob: false
33
+ )
34
+ sleep 1.5
35
+ end