collectionspace-client 0.14.1 → 0.15.1

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: b9f5c5e51e9a99c4ac0ab4d9a9e0ac8cecac7bc38391c3cc57d3c987394110de
4
+ data.tar.gz: 3106c95bf948acacb6b109b2c672ef9e2e71d51b6d9ee16b40794c4c98b8d2d6
5
5
  SHA512:
6
- metadata.gz: 7d9d9989ff3272bffe9fc99c19036e72004b7e672bc3d02ce5556b69bb478a441a78768d394685534ba83144d76054903bac35fa4f715c50cff32b838e60132c
7
- data.tar.gz: 7bea83ddcadf1aa7019e196c8ede59cd9e9ffd6fdd9b23a90ff7d0f89666122cb6c865a0b422287cb8a04d4032718e493e48f23b6356d65039a1bde00626e53b
6
+ metadata.gz: 0aa8523a50202bebcaf3a09151e3376251b5575e7e344a32624016979f8e49de45193cb630f0a5be1acec660a94f959ef03e935ed1042a244a52fe076c92c067
7
+ data.tar.gz: 9074177d65643755b34380f53ecf3bcfd77ec3c5e7d1c8af92df2e11e0edeac89ae6223e4645f7aac75f6983e826a22055021017259c27b743c08a86eb610e40
@@ -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', '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
@@ -1,9 +1,10 @@
1
1
  *.gem
2
+ *.jpg
3
+ *.pdf
2
4
  *.swp
3
5
  /.bundle/
4
6
  /.vscode
5
7
  /.yardoc
6
- /Gemfile.lock
7
8
  /_yardoc/
8
9
  /coverage/
9
10
  /doc/
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/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 --tag
40
+ gem bump --version $VERSION
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
+ 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 '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,36 @@
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.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 = `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']
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 'httparty'
21
- spec.add_dependency 'json'
22
- spec.add_dependency 'nokogiri'
22
+ spec.add_dependency "httparty"
23
+ spec.add_dependency "json"
24
+ spec.add_dependency "nokogiri"
23
25
 
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'
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
@@ -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