preservation-client 0.3.0 → 0.4.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: 4a3cb6037f122064b3cdf68406c4115c396b37cd91a54c4ea81e2f47dbff1cf9
4
- data.tar.gz: 2ab77f39a12d58589282865ff8f764f455b384f91d83a3eec334fe9c7943a100
3
+ metadata.gz: 4c390947fedbff620ee7ff2afa122451db405591f54fae1c1772bbcb80b563fc
4
+ data.tar.gz: 180421d85a8c49b9a32d9d7ca4de3d57c186451d3097a8dd4c6d4044f96ce1f1
5
5
  SHA512:
6
- metadata.gz: 6f57b21ddc5a6f4ed4935be2b5a156b08fe616c99972b7321c7af63c988190b8d75fd2f100714cfce70f61b457f388d8adfa896e151510c9672d42eed26ca6f4
7
- data.tar.gz: b5bb602b1d94216dc7de1b2fe6a871be1f9e410c7261471794f1500f3217e0f2c380c4ab1170dadcd53244dd87aa59042c9f79ae17477d544f24a9cb29333306
6
+ metadata.gz: b95502f28aecd1f92bb58a1b4c61910f7bbd2eca0f4afab19a8c7b1610f2a4f42245dbf6a2eda9e6e0ab7fd1e15f5076ad4a862f7d7d53e89b10dca57d421789
7
+ data.tar.gz: 2bd69f1bbe51930ebac3bb02629cc1053e807ab36c73b5c1aa62f737cba104eed3a3457d154cc41e9d44a40c448fcea9edfe1d953048ade738014b6a158ef314
data/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/00d2d8957226777105b3/maintainability)](https://codeclimate.com/github/sul-dlss/preservation-client/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/00d2d8957226777105b3/test_coverage)](https://codeclimate.com/github/sul-dlss/preservation-client/test_coverage)
5
5
 
6
- # Preservation::Client
6
+ # preservation-client
7
7
 
8
- Preservation::Client is a Ruby gem that acts as a client to the RESTful HTTP APIs provided by [preservation_catalog](https://github.com/sul-dlss/preservation_catalog).
8
+ preservation-client is a Ruby gem that acts as a client to the RESTful HTTP APIs provided by [preservation_catalog](https://github.com/sul-dlss/preservation_catalog).
9
9
 
10
10
  ## Installation
11
11
 
@@ -25,14 +25,11 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
- To configure and use the client, here's an example:
29
-
30
28
  ```ruby
31
29
  require 'preservation/client'
32
30
 
33
31
  def do_the_thing
34
- # This API endpoint returns an integer
35
- current_version_as_integer = client.current_version(params: { druid: 'druid:123' })
32
+ current_version_as_integer = client.current_version('druid:oo000oo0000')
36
33
  end
37
34
 
38
35
  private
@@ -48,16 +45,37 @@ Note that the preservation service is behind a firewall.
48
45
 
49
46
  ## API Coverage
50
47
 
51
- - Preservation::Client.objects.current_version('oo000oo0000') (can also be 'druid:oo000oo0000')
52
- - Preservation::Client.objects.checksums(druids: druids) - will return raw csv
53
- - Preservation::Client.objects.checksums(druids: druids, format: 'json') - will return json
54
- - Preservation::Client.objects.content(druid: 'oo000oo0000', filepath: 'my_file.pdf') - will return contents of my_file.pdf in most recent version of Moab object
55
- - Preservation::Client.objects.content(druid: 'oo000oo0000', filepath: 'my_file.pdf', version: '1') - will return contents of my_file.pdf in version 1 of Moab object
56
- - Preservation::Client.objects.manifest(druid: 'oo000oo0000', filepath: 'versionInventory.xml') - will return contents of versionInventory.xml in most recent version of Moab object
57
- - Preservation::Client.objects.manifest(druid: 'oo000oo0000', filepath: 'versionInventory.xml', version: '3') - will return contents of versionInventory.xml in version 3 of Moab object
58
- - Preservation::Client.objects.metadata(druid: 'oo000oo0000', filepath: 'identityMetadata.xml') - will return contents of identityMetadata.xml in most recent version of Moab object
59
- - Preservation::Client.objects.metadata(druid: 'oo000oo0000', filepath: 'identityMetadata.xml', version: '8') - will return contents of identityMetadata.xml in version 8 of Moab object
60
- - Preservation::Client.objects.signature_catalog(druid: 'oo000oo0000') - will return contents of latest version of signatureCatalog.xml from Moab object
48
+ druids may be with or without the "druid:" prefix - 'oo000oo0000' or 'druid:oo000oo0000'
49
+
50
+ ### Get the current version of a preserved object (Moab)
51
+
52
+ - `client.objects.current_version('oo000oo0000')` - returns latest version as an Integer
53
+
54
+ ### Retrieve file signature (checksum) information
55
+
56
+ - `client.objects.checksums(druids: druids)` - returns info as raw csv
57
+ - `client.objects.checksums(druids: druids, format: 'json')` - returns info as json
58
+
59
+ ### Retrieve individual files from preservation
60
+
61
+ - `client.objects.content(druid: 'oo000oo0000', filepath: 'my_file.pdf')` - returns contents of my_file.pdf in most recent version of Moab object
62
+ - You may specify the version:
63
+ - `client.objects.content(druid: 'oo000oo0000', filepath: 'my_file.pdf', version: '1')` - returns contents of my_file.pdf in version 1 of Moab object
64
+ - `client.objects.manifest(druid: 'oo000oo0000', filepath: 'versionInventory.xml')` - returns contents of versionInventory.xml in most recent version of Moab object
65
+ - You may specify the version:
66
+ - `client.objects.manifest(druid: 'oo000oo0000', filepath: 'versionInventory.xml', version: '3')` - returns contents of versionInventory.xml in version 3 of Moab object
67
+ - `client.objects.metadata(druid: 'oo000oo0000', filepath: 'identityMetadata.xml')` - returns contents of identityMetadata.xml in most recent version of Moab object
68
+ - You may specify the version:
69
+ - `client.objects.metadata(druid: 'oo000oo0000', filepath: 'identityMetadata.xml', version: '8')` - returns contents of identityMetadata.xml in version 8 of Moab object
70
+ - `client.objects.signature_catalog(druid: 'oo000oo0000')` - returns contents of latest version of signatureCatalog.xml from Moab object
71
+
72
+ ### Get difference information between passed contentMetadata.xml and files in the Moab
73
+
74
+ - `client.objects.content_inventory_diff(druid: 'oo000oo0000', content_metadata: '<contentMetadata>...</contentMetadata>')` - returns Moab::FileInventoryDifference containing differences between passed content metadata and latest version for subset 'all'
75
+ - you may specify the subset (all|shelve|preserve|publish) and/or the version:
76
+ - `client.objects.content_inventory_diff(druid: 'oo000oo0000', subset: 'publish', version: '1', content_metadata: '<contentMetadata>...</contentMetadata>')`
77
+
78
+ - `client.objects.shelve_content_diff(druid: 'oo000oo0000', content_metadata: '<contentMetadata>...</contentMetadata>')` - returns Moab::FileGroupDifference containing differences between passed content metadata and latest version for subset 'shelve'
61
79
 
62
80
  ## Development
63
81
 
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'moab'
4
+
5
+ # NOTE: this class makes use of data structures from moab-versioning gem,
6
+ # but it does NOT directly access any preservation storage roots
3
7
  module Preservation
4
8
  class Client
5
9
  # API calls that are about Preserved Objects
@@ -11,6 +15,30 @@ module Preservation
11
15
  post('objects/checksums', druids: druids, format: resp_format)
12
16
  end
13
17
 
18
+ # @param [String] druid - with or without prefix: 'druid:bb123cd4567' OR 'bb123cd4567'
19
+ # @param [String] content_metadata - contentMetadata.xml to be compared against a version of Moab
20
+ # @param [String] subset - (default: 'all') which subset of files to compare (all|shelve|preserve|publish)
21
+ # @param [String] version - version of Moab to be compared against (defaults to nil for latest version)
22
+ # @return [Moab::FileInventoryDifference] differences of passed contentMetadata.xml
23
+ # with latest (or specified) version in Moab for all files (default) or
24
+ # a specified subset (shelve|preserve|publish)
25
+ def content_inventory_diff(druid:, content_metadata:, subset: 'all', version: nil)
26
+ result = post("objects/#{druid}/content_diff",
27
+ content_metadata: content_metadata, subset: subset, version: version)
28
+ Moab::FileInventoryDifference.parse(result)
29
+ end
30
+
31
+ # convenience method for retrieving the differences in content files that should be "shelved" (altered in stacks)
32
+ # (or nil if no such differences)
33
+ # @param [String] druid - with or without prefix: 'druid:bb123cd4567' OR 'bb123cd4567'
34
+ # @param [String] content_metadata - most recent contentMetadata.xml to be compared against latest version of Moab
35
+ # @return [Moab::FileGroupDifference] differences in content files that should be "shelved" (altered in stacks)
36
+ # (or nil if not found)
37
+ def shelve_content_diff(druid:, content_metadata:)
38
+ inventory_diff = content_inventory_diff(druid: druid, content_metadata: content_metadata, subset: 'shelve')
39
+ inventory_diff.group_difference('content')
40
+ end
41
+
14
42
  # @param [String] druid - with or without prefix: 'druid:ab123cd4567' OR 'ab123cd4567'
15
43
  # @return [Integer] the current version of the Preserved Object
16
44
  def current_version(druid)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Preservation
4
4
  class Client
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
@@ -30,13 +30,14 @@ Gem::Specification.new do |spec|
30
30
 
31
31
  spec.add_dependency 'activesupport', '>= 4.2', '< 7'
32
32
  spec.add_dependency 'faraday', '~> 0.15'
33
+ spec.add_dependency 'moab-versioning', '~> 4.3'
33
34
  spec.add_dependency 'zeitwerk', '~> 2.1'
34
35
 
35
36
  spec.add_development_dependency 'bundler', '~> 2.0'
36
37
  spec.add_development_dependency 'pry-byebug'
37
38
  spec.add_development_dependency 'rake', '~> 10.0'
38
39
  spec.add_development_dependency 'rspec', '~> 3.0'
39
- spec.add_development_dependency 'rubocop', '~> 0.74.0'
40
+ spec.add_development_dependency 'rubocop', '~> 0.77.0'
40
41
  spec.add_development_dependency 'simplecov'
41
42
  spec.add_development_dependency 'webmock'
42
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preservation-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.15'
47
+ - !ruby/object:Gem::Dependency
48
+ name: moab-versioning
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '4.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '4.3'
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: zeitwerk
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +134,14 @@ dependencies:
120
134
  requirements:
121
135
  - - "~>"
122
136
  - !ruby/object:Gem::Version
123
- version: 0.74.0
137
+ version: 0.77.0
124
138
  type: :development
125
139
  prerelease: false
126
140
  version_requirements: !ruby/object:Gem::Requirement
127
141
  requirements:
128
142
  - - "~>"
129
143
  - !ruby/object:Gem::Version
130
- version: 0.74.0
144
+ version: 0.77.0
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: simplecov
133
147
  requirement: !ruby/object:Gem::Requirement