ocfl 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: 9a442976eed04ea8bd466b2a423d99e18e3de2eace9950419102a26762a0f279
4
- data.tar.gz: 998da7270a92ba987015aed961ce9d07571c9e97bdd8fb739ebce53409f0f6cf
3
+ metadata.gz: 256cd51a71d4728f32b12904cd02153e92a3a054e0b7b9ee7f18f7aca7a34320
4
+ data.tar.gz: d8bfb5f8571e998710fb6e7e5f245e7723886d3db26c0c54537f2b172d456d46
5
5
  SHA512:
6
- metadata.gz: 9649b239dcd0d542e772eefcc1a177eb6c9a3367a347a05277661ff5605bfd1713f7610a8b0411852c2665b594a392d6db8f2248e3d9a3578bff7bce6b4f8240
7
- data.tar.gz: db00dc92ce3bad0b059f45f90d4ff59162d6a7532aee3160406d1088fbfcb4cf274617e4d1781577a3c1f47992f0b8109ac24226f00043b9aec0799984048189
6
+ metadata.gz: e3aad0f2020ef90a36b3fdf71129e9bd84fce068e665eecb08e00d37cd897d7d5c91298ed8dfaadc0b6d8a27060cb5306eb85bbbe630267fb8889989279a795f
7
+ data.tar.gz: '07609a37af93df25a2d836f46d42591972514265272f6a4fe3e1bf333198f7c98eae07e8ce5f21499967340627a2013f2f6e450433af3824f0146d855f0c03c8'
@@ -25,25 +25,38 @@ module OCFL
25
25
  FileUtils.mv(incoming_path, content_path)
26
26
  end
27
27
 
28
- def copy_file(incoming_path)
28
+ def copy_file(incoming_path, destination_path: '')
29
29
  prepare_content_directory
30
- add(incoming_path)
31
- FileUtils.cp(incoming_path, content_path)
30
+ copy_one(File.basename(incoming_path), incoming_path, destination_path)
32
31
  end
33
32
 
34
33
  # Copies files into the object and preserves their relative paths as logical directories in the object
35
- def copy_recursive(incoming_path)
34
+ def copy_recursive(incoming_path, destination_path: '')
36
35
  prepare_content_directory
37
36
  incoming_path = incoming_path.delete_suffix("/")
38
37
  Dir.glob("#{incoming_path}/**/*").reject { |fn| File.directory?(fn) }.each do |file|
39
- logical_file_path = file.delete_prefix(incoming_path).delete_prefix("/")
40
- add(file, logical_file_path:)
41
- parent_dir = (content_path + logical_file_path).parent
42
- FileUtils.mkdir_p(parent_dir)
43
- FileUtils.cp(file, content_path + logical_file_path)
38
+ copy_one(file.delete_prefix(incoming_path).delete_prefix("/"), file, destination_path)
44
39
  end
45
40
  end
46
41
 
42
+ def save
43
+ inventory = build_inventory
44
+ InventoryWriter.new(inventory:, path:).write
45
+ FileUtils.cp(path + "inventory.json", object_directory.object_root)
46
+ FileUtils.cp(path + "inventory.json.sha512", object_directory.object_root)
47
+ object_directory.reload
48
+ end
49
+
50
+ private
51
+
52
+ def copy_one(logical_file_path, incoming_path, destination_path)
53
+ logical_file_path = File.join(destination_path, logical_file_path) unless destination_path.empty?
54
+ add(incoming_path, logical_file_path:)
55
+ parent_dir = (content_path + logical_file_path).parent
56
+ FileUtils.mkdir_p(parent_dir) unless parent_dir == content_path
57
+ FileUtils.cp(incoming_path, content_path + logical_file_path)
58
+ end
59
+
47
60
  def add(incoming_path, logical_file_path: File.basename(incoming_path))
48
61
  digest = Digest::SHA512.file(incoming_path).to_s
49
62
  version_content_path = content_path.relative_path_from(object_directory.object_root)
@@ -95,14 +108,6 @@ module OCFL
95
108
  shas_in_versions = versions.values.flat_map { |v| v.state.keys }.uniq
96
109
  manifest.slice(*shas_in_versions)
97
110
  end
98
-
99
- def save
100
- inventory = build_inventory
101
- InventoryWriter.new(inventory:, path:).write
102
- FileUtils.cp(path + "inventory.json", object_directory.object_root)
103
- FileUtils.cp(path + "inventory.json.sha512", object_directory.object_root)
104
- object_directory.reload
105
- end
106
111
  end
107
112
  end
108
113
  end
data/lib/ocfl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OCFL
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocfl
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
  - Justin Coyne