archivesspace-client 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: 2c49aac54a1b49b27bbff319aa83e0a6f7dd711a1e644324ae9d96155b06d417
4
- data.tar.gz: bf2fa7e423165f8e03282c718fe819fa7c5836e9090ceacbcf58e642e6ea1938
3
+ metadata.gz: 2087a90bf94b94f918d9b1453442e8e7a682ef75a76092fcd7dbe63d21816b83
4
+ data.tar.gz: 3f8e168c3e7a04e6dbb67e3bef8227f77d46ea3b9c009f08eddd24de3441f736
5
5
  SHA512:
6
- metadata.gz: 7ba30d239390c5066bc5a673e532fb75a3d1fc4f994a8d2726494363f919e3656a5f0d1e7cb730797cbfcf24d404c0447ea1a2243aef6fe4bb9ac1af61117dc4
7
- data.tar.gz: 385795fdc7c63144d96696be8a39a3e6f6e4f6c95fa5040be5e9be8d7db7c6a03b4db066bc3900299bb4e05e8d3446a8fa69b9628452beb0b65b477302702ee6
6
+ metadata.gz: f6977881509e613d26e24bbfa7b20204d20aac113a3d3297d798ba3b5c2f0cc673d217d77f9c161a906229a69a8710cdf9745e9c96b27262f8b0f2ac20583e51
7
+ data.tar.gz: 2480484be2b5ec0379b3c7c280e8473897a9930cb5a6abc2ec7b28decb81722478e70703a1d8bd38992866d6adaf94492e06480679126213bf500205e948a749
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in archivesspace-client.gemspec
data/README.md CHANGED
@@ -110,7 +110,7 @@ bundle exec rake
110
110
  Bump version in `lib/archivesspace/client/version.rb` then:
111
111
 
112
112
  ```bash
113
- VERSION=0.1.6
113
+ VERSION=0.1.7
114
114
  gem build archivesspace-client
115
115
  git add . && git commit -m "Bump to $VERSION"
116
116
  git tag v$VERSION
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -1,31 +1,32 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'archivesspace/client/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "archivesspace-client"
8
+ spec.name = 'archivesspace-client'
8
9
  spec.version = ArchivesSpace::Client::VERSION
9
- spec.authors = ["Mark Cooper"]
10
- spec.email = ["mark.c.cooper@outlook.com"]
11
- spec.summary = %q{Interact with ArchivesSpace via its RESTful API.}
12
- spec.description = %q{Interact with ArchivesSpace via its RESTful API.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
10
+ spec.authors = ['Mark Cooper']
11
+ spec.email = ['mark.c.cooper@outlook.com']
12
+ spec.summary = 'Interact with ArchivesSpace via the API.'
13
+ spec.description = 'Interact with ArchivesSpace via the API.'
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
20
21
 
21
- spec.add_development_dependency "bundler"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "3.6.0"
24
- spec.add_development_dependency "vcr", "3.0.3"
25
- spec.add_development_dependency "webmock", "3.0.1"
26
- spec.add_development_dependency "awesome_print", "~> 1.8.0"
22
+ spec.add_development_dependency 'awesome_print', '~> 1.8.0'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '3.6.0'
26
+ spec.add_development_dependency 'vcr', '3.0.3'
27
+ spec.add_development_dependency 'webmock', '3.0.1'
27
28
 
28
- spec.add_dependency "httparty", "0.14.0"
29
- spec.add_dependency "json", "2.0.3"
30
- spec.add_dependency "nokogiri", "1.10.10"
29
+ spec.add_dependency 'httparty', '~> 0.14'
30
+ spec.add_dependency 'json', '~> 2.0'
31
+ spec.add_dependency 'nokogiri', '~> 1.10'
31
32
  end
data/examples/export.rb CHANGED
@@ -1,33 +1,36 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'awesome_print'
3
5
  require 'archivesspace/client'
4
6
 
5
7
  # official sandbox
6
- config = ArchivesSpace::Configuration.new({
7
- base_uri: "http://sandbox.archivesspace.org/api",
8
- base_repo: "",
9
- username: "admin",
10
- password: "admin",
11
- page_size: 50,
12
- throttle: 0,
13
- verify_ssl: false,
14
- })
8
+ config = ArchivesSpace::Configuration.new(
9
+ {
10
+ base_uri: 'http://test.archivesspace.org/staff/api',
11
+ base_repo: '',
12
+ username: 'admin',
13
+ password: 'admin',
14
+ page_size: 50,
15
+ throttle: 0,
16
+ verify_ssl: false
17
+ }
18
+ )
15
19
 
16
20
  client = ArchivesSpace::Client.new(config).login
17
21
  client.config.throttle = 0.5
18
- client.config.base_repo = "repositories/2"
22
+ client.config.base_repo = 'repositories/2'
19
23
 
20
24
  begin
21
- # date -d '2015-07-01 00:00:00' +'%s' # 1435734000
22
- client.resources.each(query: { modified_since: "1435734000"}) do |resource|
25
+ # date -d '2021-02-01 00:00:00' +'%s' # 1612166400
26
+ client.resources(query: { modified_since: '1612166400' }).each do |resource|
23
27
  # for now we are just printing ...
24
28
  # but you would actually write to a zip file or whatever
25
29
  id = resource['uri'].split('/')[-1]
26
30
  opts = { include_unpublished: false }
27
31
  response = client.get("resource_descriptions/#{id}.xml", opts)
28
32
  puts Nokogiri::XML(response.body).to_xml
29
- break
30
33
  end
31
- rescue ArchivesSpace::RequestError => ex
32
- puts ex.message
33
- end
34
+ rescue ArchivesSpace::RequestError => e
35
+ puts e.message
36
+ end
@@ -1,15 +1,17 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'awesome_print'
3
5
  require 'archivesspace/client'
4
6
 
5
- username = "mrx"
6
- password = "123456"
7
+ username = 'mrx'
8
+ password = '123456'
7
9
 
8
10
  # default client connection: localhost:8089, admin, admin
9
11
  client = ArchivesSpace::Client.new.login
10
12
  begin
11
13
  client.password_reset username, password
12
14
  puts "Successfully updated password for #{username}."
13
- rescue Exception => ex
14
- puts "Failed to update password for #{username},\n#{ex.message}"
15
+ rescue StandardError => e
16
+ puts "Failed to update password for #{username},\n#{e.message}"
15
17
  end
@@ -1,17 +1,21 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'awesome_print'
3
5
  require 'archivesspace/client'
4
6
 
5
7
  # official sandbox
6
- config = ArchivesSpace::Configuration.new({
7
- base_uri: "http://sandbox.archivesspace.org/api",
8
- base_repo: "",
9
- username: "admin",
10
- password: "admin",
11
- page_size: 50,
12
- throttle: 0,
13
- verify_ssl: false,
14
- })
8
+ config = ArchivesSpace::Configuration.new(
9
+ {
10
+ base_uri: 'http://sandbox.archivesspace.org/api',
11
+ base_repo: '',
12
+ username: 'admin',
13
+ password: 'admin',
14
+ page_size: 50,
15
+ throttle: 0,
16
+ verify_ssl: false
17
+ }
18
+ )
15
19
 
16
20
  # default client connection: localhost:8089, admin, admin
17
21
  client = ArchivesSpace::Client.new(config).login
@@ -19,26 +23,26 @@ client = ArchivesSpace::Client.new(config).login
19
23
  ap ArchivesSpace::Template.list # view available templates
20
24
 
21
25
  repo_data = {
22
- repo_code: "XYZ",
23
- name: "XYZ Archive",
24
- agent_contact_name: "John Doe",
26
+ repo_code: 'XYZ',
27
+ name: 'XYZ Archive',
28
+ agent_contact_name: 'John Doe'
25
29
  }
26
30
 
27
31
  user_data = {
28
- username: "lmessi",
29
- name: "Lionel Messi",
30
- is_admin: true,
32
+ username: 'lmessi',
33
+ name: 'Lionel Messi',
34
+ is_admin: true
31
35
  }
32
- user_password = "123456"
36
+ user_password = '123456'
33
37
 
34
38
  repository = ArchivesSpace::Template.process_template(:repository_with_agent, repo_data)
35
39
 
36
40
  begin
37
41
  response = client.post('/repositories/with_agent', repository)
38
42
  if response.status_code.to_s =~ /^2/
39
- repository = client.repositories.find { |r| r["repo_code"] == "XYZ" }
43
+ repository = client.repositories.find { |r| r['repo_code'] == 'XYZ' }
40
44
  ap repository
41
- ap client.delete(repository["uri"])
45
+ ap client.delete(repository['uri'])
42
46
  else
43
47
  ap response.parsed
44
48
  end
@@ -46,12 +50,12 @@ begin
46
50
  user = ArchivesSpace::Template.process_template(:user, user_data)
47
51
  response = client.post('users', user, { password: user_password })
48
52
  if response.status_code.to_s =~ /^2/
49
- user = client.users.find { |r| r["username"] == "lmessi" }
53
+ user = client.users.find { |r| r['username'] == 'lmessi' }
50
54
  ap user
51
- ap client.delete user["uri"]
55
+ ap client.delete user['uri']
52
56
  else
53
57
  ap response.parsed
54
58
  end
55
- rescue ArchivesSpace::RequestError => ex
56
- puts ex.message
59
+ rescue ArchivesSpace::RequestError => e
60
+ puts e.message
57
61
  end
@@ -1,17 +1,21 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'awesome_print'
3
5
  require 'archivesspace/client'
4
6
 
5
7
  # official sandbox
6
- config = ArchivesSpace::Configuration.new({
7
- base_uri: "http://sandbox.archivesspace.org/api",
8
- base_repo: "",
9
- username: "admin",
10
- password: "admin",
11
- page_size: 50,
12
- throttle: 0,
13
- verify_ssl: false,
14
- })
8
+ config = ArchivesSpace::Configuration.new(
9
+ {
10
+ base_uri: 'http://sandbox.archivesspace.org/api',
11
+ base_repo: '',
12
+ username: 'admin',
13
+ password: 'admin',
14
+ page_size: 50,
15
+ throttle: 0,
16
+ verify_ssl: false
17
+ }
18
+ )
15
19
 
16
20
  client = ArchivesSpace::Client.new(config).login
17
- puts client.get("version").body
21
+ puts client.get('version').body
@@ -1,22 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'httparty'
2
4
  require 'json'
3
5
  require 'nokogiri'
4
6
 
5
7
  # mixins required first
6
- require "archivesspace/client/helpers"
8
+ require 'archivesspace/client/helpers'
7
9
 
8
- require "archivesspace/client/client"
9
- require "archivesspace/client/configuration"
10
- require "archivesspace/client/request"
11
- require "archivesspace/client/response"
12
- require "archivesspace/client/template"
13
- require "archivesspace/client/version"
10
+ require 'archivesspace/client/client'
11
+ require 'archivesspace/client/configuration'
12
+ require 'archivesspace/client/request'
13
+ require 'archivesspace/client/response'
14
+ require 'archivesspace/client/template'
15
+ require 'archivesspace/client/version'
14
16
 
15
17
  module ArchivesSpace
16
-
17
- class ConnectionError < Exception ; end
18
- class ContextError < Exception ; end
19
- class ParamsError < Exception ; end
20
- class RequestError < Exception ; end
21
-
22
- end
18
+ class ConnectionError < RuntimeError; end
19
+ class ContextError < RuntimeError; end
20
+ class ParamsError < RuntimeError; end
21
+ class RequestError < RuntimeError; end
22
+ end
@@ -1,14 +1,14 @@
1
- module ArchivesSpace
1
+ # frozen_string_literal: true
2
2
 
3
+ module ArchivesSpace
3
4
  class Client
4
5
  include Helpers
5
6
  attr_accessor :token
6
7
  attr_reader :config
7
8
 
8
9
  def initialize(config = Configuration.new)
9
- unless config.kind_of? ArchivesSpace::Configuration
10
- raise "Invalid configuration object"
11
- end
10
+ raise 'Invalid configuration object' unless config.is_a? ArchivesSpace::Configuration
11
+
12
12
  @config = config
13
13
  @token = nil
14
14
  end
@@ -33,11 +33,9 @@ module ArchivesSpace
33
33
 
34
34
  def request(method, path, options = {})
35
35
  sleep config.throttle
36
- options[:headers] = { "X-ArchivesSpace-Session" => token } if token
36
+ options[:headers] = { 'X-ArchivesSpace-Session' => token } if token
37
37
  result = Request.new(config, method, path, options).execute
38
38
  Response.new result
39
39
  end
40
-
41
40
  end
42
-
43
41
  end
@@ -1,16 +1,16 @@
1
- module ArchivesSpace
1
+ # frozen_string_literal: true
2
2
 
3
+ module ArchivesSpace
3
4
  class Configuration
4
-
5
5
  def defaults
6
6
  {
7
- base_uri: "http://localhost:8089",
8
- base_repo: "",
9
- username: "admin",
10
- password: "admin",
7
+ base_uri: 'http://localhost:8089',
8
+ base_repo: '',
9
+ username: 'admin',
10
+ password: 'admin',
11
11
  page_size: 50,
12
12
  throttle: 0,
13
- verify_ssl: true,
13
+ verify_ssl: true
14
14
  }
15
15
  end
16
16
 
@@ -18,11 +18,10 @@ module ArchivesSpace
18
18
  settings = defaults.merge(settings)
19
19
  settings.each do |property, value|
20
20
  next unless defaults.keys.include? property
21
+
21
22
  instance_variable_set("@#{property}", value)
22
23
  self.class.send(:attr_accessor, property)
23
24
  end
24
25
  end
25
-
26
26
  end
27
-
28
- end
27
+ end
@@ -1,15 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # needed for roundtrip hash merging
2
4
  class ::Hash
3
5
  def deep_merge(second)
4
- merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
5
- self.merge(second, &merger)
6
+ merger = proc { |_key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
7
+ merge(second, &merger)
6
8
  end
7
9
  end
8
10
 
9
11
  module ArchivesSpace
10
-
11
12
  module Helpers
12
-
13
13
  def accessions(options = {})
14
14
  all('accessions', options)
15
15
  end
@@ -19,7 +19,9 @@ module ArchivesSpace
19
19
  page = 1
20
20
  unlimited_listing = false
21
21
  loop do
22
- result = get(path, options.merge(query: { page: page }))
22
+ options[:query] ||= {}
23
+ options[:query][:page] = page
24
+ result = get(path, options)
23
25
  results = []
24
26
 
25
27
  if result.parsed.respond_to?(:key) && result.parsed.key?('results')
@@ -44,7 +46,7 @@ module ArchivesSpace
44
46
  end
45
47
 
46
48
  def backend_version
47
- get "version"
49
+ get 'version'
48
50
  end
49
51
 
50
52
  def batch_import(payload, params = {})
@@ -65,49 +67,52 @@ module ArchivesSpace
65
67
  changed = false
66
68
 
67
69
  users_with_roles.each do |user, roles|
68
- if roles.include? group["group_code"]
69
- unless group["member_usernames"].include? user
70
- group["member_usernames"] << user
70
+ if roles.include? group['group_code']
71
+ unless group['member_usernames'].include? user
72
+ group['member_usernames'] << user
71
73
  changed = true
72
74
  end
73
75
  else
74
- if group["member_usernames"].include? user
75
- group["member_usernames"].delete user
76
+ if group['member_usernames'].include? user
77
+ group['member_usernames'].delete user
76
78
  changed = true
77
79
  end
78
80
  end
79
81
  end
80
82
 
81
- if changed
82
- id = group["uri"].split("/")[-1]
83
- response = post( "/groups/#{id}", group, params )
84
- updated << response.parsed
85
- end
83
+ next unless changed
84
+
85
+ id = group['uri'].split('/')[-1]
86
+ response = post("/groups/#{id}", group, params)
87
+ updated << response.parsed
86
88
  end
87
89
  updated
88
90
  end
89
91
 
90
92
  def login
91
- username, password = config.username, config.password
93
+ username = config.username
94
+ password = config.password
92
95
  result = request('POST', "/users/#{username}/login", { query: { password: password } })
93
- raise ConnectionError.new "Failed to connect to ArchivesSpace backend as #{username} #{password}" unless result.parsed["session"]
94
- @token = result.parsed["session"]
96
+ unless result.parsed['session']
97
+ raise ConnectionError, "Failed to connect to ArchivesSpace backend as #{username} #{password}"
98
+ end
99
+
100
+ @token = result.parsed['session']
95
101
  self
96
102
  end
97
103
 
98
104
  def password_reset(username, password)
99
- user = all('users').find { |u| u["username"] == username }
100
- raise RequestError.new(user.status) unless user
101
- post(user["uri"], user, { password: password })
105
+ user = all('users').find { |u| u['username'] == username }
106
+ raise RequestError, user.status unless user
107
+
108
+ post(user['uri'], user, { password: password })
102
109
  end
103
110
 
104
111
  def repositories(options = {})
105
112
  all('repositories', options)
106
113
  end
107
114
 
108
- def repositories_with_agent
109
- #
110
- end
115
+ def repositories_with_agent; end
111
116
 
112
117
  def resources(options = {})
113
118
  all('resources', options)
@@ -120,7 +125,5 @@ module ArchivesSpace
120
125
  def users(options = {})
121
126
  all('users', options)
122
127
  end
123
-
124
128
  end
125
-
126
129
  end
@@ -1,5 +1,6 @@
1
- module ArchivesSpace
1
+ # frozen_string_literal: true
2
2
 
3
+ module ArchivesSpace
3
4
  class Request
4
5
  include HTTParty
5
6
  attr_reader :config, :headers, :method, :path, :options
@@ -9,29 +10,27 @@ module ArchivesSpace
9
10
  delete: {},
10
11
  get: {},
11
12
  post: {
12
- "Content-Type" => "application/json",
13
- "Content-Length" => "nnnn",
13
+ 'Content-Type' => 'application/json',
14
+ 'Content-Length' => 'nnnn'
14
15
  },
15
16
  put: {
16
- "Content-Type" => "application/json",
17
- "Content-Length" => "nnnn",
17
+ 'Content-Type' => 'application/json',
18
+ 'Content-Length' => 'nnnn'
18
19
  }
19
20
  }
20
21
  headers[method]
21
22
  end
22
23
 
23
- def initialize(config, method = "GET", path = "", options = {})
24
+ def initialize(config, method = 'GET', path = '', options = {})
24
25
  @config = config
25
26
  @method = method.downcase.to_sym
26
- @path = path.gsub(/^\/+/, '')
27
+ @path = path.gsub(%r{^/+}, '')
27
28
  @options = options
28
29
  @options[:headers] = options[:headers] ? default_headers(@method).merge(options[:headers]) : default_headers(@method)
29
30
  @options[:verify] = config.verify_ssl
30
- @options[:query] = {} unless options.has_key? :query
31
+ @options[:query] = {} unless options.key? :query
31
32
 
32
- base_uri = (
33
- config.base_repo.nil? or config.base_repo.empty?
34
- ) ? config.base_uri : "#{config.base_uri}/#{config.base_repo}"
33
+ base_uri = config.base_repo&.length&.positive? ? File.join(config.base_uri, config.base_repo) : config.base_uri
35
34
 
36
35
  self.class.base_uri base_uri
37
36
  end
@@ -39,7 +38,5 @@ module ArchivesSpace
39
38
  def execute
40
39
  self.class.send method, "/#{path}", options
41
40
  end
42
-
43
41
  end
44
-
45
42
  end
@@ -1,5 +1,6 @@
1
- module ArchivesSpace
1
+ # frozen_string_literal: true
2
2
 
3
+ module ArchivesSpace
3
4
  class Response
4
5
  attr_reader :result, :parsed, :body, :headers, :status, :status_code, :xml
5
6
 
@@ -12,7 +13,5 @@ module ArchivesSpace
12
13
  @status = result.response
13
14
  @status_code = result.code.to_i
14
15
  end
15
-
16
16
  end
17
-
18
- end
17
+ end
@@ -1,25 +1,23 @@
1
- module ArchivesSpace
1
+ # frozen_string_literal: true
2
2
 
3
+ module ArchivesSpace
3
4
  module Template
4
-
5
5
  def self.list
6
6
  []
7
7
  end
8
8
 
9
9
  def self.process_template(template, data)
10
- t = ERB.new(self.read_template(template))
11
- r = t.result(binding).gsub(/\n+/,"\n")
10
+ t = ERB.new(read_template(template))
11
+ r = t.result(binding).gsub(/\n+/, "\n")
12
12
  JSON.parse(r)
13
13
  end
14
14
 
15
15
  def self.read_template(file)
16
- File.read("#{self.templates_path}/#{file.to_s}.json.erb")
16
+ File.read("#{templates_path}/#{file}.json.erb")
17
17
  end
18
18
 
19
19
  def self.templates_path
20
20
  File.join(File.dirname(File.expand_path(__FILE__)), 'templates')
21
21
  end
22
-
23
22
  end
24
-
25
- end
23
+ end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArchivesSpace
2
4
  class Client
3
- VERSION = "0.1.6"
5
+ VERSION = '0.1.7'
4
6
  end
5
7
  end
@@ -1,43 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ArchivesSpace::Client do
4
-
5
6
  let(:client) { ArchivesSpace::Client.new }
6
7
  let(:login) { -> { client.login } }
7
8
 
8
- describe "Configuration" do
9
-
9
+ describe 'Configuration' do
10
10
  it 'will use the default configuration if none is provided' do
11
11
  client = ArchivesSpace::Client.new
12
12
  expect(client.config.base_uri).to eq DEFAULT_BASE_URI
13
13
  end
14
14
 
15
15
  it 'will raise an error if supplied configuration is of invalid type' do
16
- expect{ ArchivesSpace::Client.new({ base_uri: CUSTOM_BASE_URI }) }.to raise_error(RuntimeError)
16
+ expect { ArchivesSpace::Client.new({ base_uri: CUSTOM_BASE_URI }) }.to raise_error(RuntimeError)
17
17
  end
18
18
 
19
19
  it 'will allow a configuration object to be provided' do
20
20
  client = ArchivesSpace::Client.new(ArchivesSpace::Configuration.new({ base_uri: CUSTOM_BASE_URI }))
21
21
  expect(client.config.base_uri).to eq CUSTOM_BASE_URI
22
22
  end
23
-
24
23
  end
25
24
 
26
- describe "Version information" do
27
-
25
+ describe 'Version information' do
28
26
  it 'has a version number' do
29
27
  expect(ArchivesSpace::Client::VERSION).not_to be nil
30
28
  end
31
29
 
32
- it "can retrieve the backend version info" do
30
+ it 'can retrieve the backend version info' do
33
31
  VCR.use_cassette('backend_version') do
34
32
  login.call
35
- response = client.get "version"
33
+ response = client.get 'version'
36
34
  expect(response.status_code).to eq(200)
37
35
  expect(response.body).to match(/ArchivesSpace \(.*\)/)
38
36
  end
39
37
  end
40
-
41
38
  end
42
-
43
- end
39
+ end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ArchivesSpace::Configuration do
4
-
5
6
  it 'uses the default profile for configuration settings' do
6
7
  config = ArchivesSpace::Configuration.new
7
8
  expect(config.base_uri).to eq DEFAULT_BASE_URI
@@ -9,8 +10,8 @@ describe ArchivesSpace::Configuration do
9
10
 
10
11
  it 'allows configuration settings to be provided' do
11
12
  config = ArchivesSpace::Configuration.new({
12
- base_uri: CUSTOM_BASE_URI,
13
- })
13
+ base_uri: CUSTOM_BASE_URI
14
+ })
14
15
  expect(config.base_uri).to eq CUSTOM_BASE_URI
15
16
  end
16
17
 
@@ -22,7 +23,6 @@ describe ArchivesSpace::Configuration do
22
23
 
23
24
  it 'ignores unrecognized configuration properties' do
24
25
  config = ArchivesSpace::Configuration.new({ xyz: 123 })
25
- expect{ config.xyz }.to raise_error(NoMethodError)
26
+ expect { config.xyz }.to raise_error(NoMethodError)
26
27
  end
27
-
28
- end
28
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,16 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
4
  require 'archivesspace/client'
3
5
  require 'vcr'
4
6
  require 'webmock/rspec'
5
7
 
6
8
  # GLOBAL VALUES FOR SPECS
7
- DEFAULT_BASE_URI = "http://localhost:8089"
8
- CUSTOM_BASE_URI = "https://archives.university.edu/api"
9
+ DEFAULT_BASE_URI = 'http://localhost:8089'
10
+ CUSTOM_BASE_URI = 'https://archives.university.edu/api'
9
11
 
10
12
  VCR.configure do |c|
11
- c.cassette_library_dir = "spec/fixtures/cassettes"
13
+ c.cassette_library_dir = 'spec/fixtures/cassettes'
12
14
  c.hook_into :webmock
13
- c.default_cassette_options = { :record => :once }
14
- end
15
+ c.default_cassette_options = { record: :once }
16
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: archivesspace-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-12 00:00:00.000000000 Z
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,63 +94,49 @@ dependencies:
80
94
  - - '='
81
95
  - !ruby/object:Gem::Version
82
96
  version: 3.0.1
83
- - !ruby/object:Gem::Dependency
84
- name: awesome_print
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.8.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 1.8.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: httparty
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '='
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.14.0
103
+ version: '0.14'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '='
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.14.0
110
+ version: '0.14'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '='
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 2.0.3
117
+ version: '2.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '='
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 2.0.3
124
+ version: '2.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: nokogiri
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '='
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.10.10
131
+ version: '1.10'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '='
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.10.10
139
- description: Interact with ArchivesSpace via its RESTful API.
138
+ version: '1.10'
139
+ description: Interact with ArchivesSpace via the API.
140
140
  email:
141
141
  - mark.c.cooper@outlook.com
142
142
  executables: []
@@ -190,10 +190,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  - !ruby/object:Gem::Version
191
191
  version: '0'
192
192
  requirements: []
193
- rubygems_version: 3.0.3
193
+ rubygems_version: 3.1.4
194
194
  signing_key:
195
195
  specification_version: 4
196
- summary: Interact with ArchivesSpace via its RESTful API.
196
+ summary: Interact with ArchivesSpace via the API.
197
197
  test_files:
198
198
  - spec/archivesspace/client_spec.rb
199
199
  - spec/archivesspace/configuration_spec.rb