ocfl 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocfl/object/draft_version.rb +22 -17
- data/lib/ocfl/version.rb +1 -1
- data/lib/ocfl.rb +1 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664b853647982b285f37270e111f75fe19fce52217c50eebed68c6e23340c6fc
|
4
|
+
data.tar.gz: 32fa2fc95e646671dde3f4b0e3349ad84b77816f4087abe63623ae3d59028e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f023ae4faca8ac12ba46782a68a099c04a9623f9ed11ce26005ae96a1d259dfe7ca6c0cc2039c20154dda3bed64d9faa8f4181327920a5ebec8b6a597f4f7b1
|
7
|
+
data.tar.gz: 33db1c161b1e24ba2859c98c65a5071745f2815956903ca45ad7faff8f1c8046040156d42d2483fa832379fd4cf880b39880d40c1b231ba0b44c6a85dc6ddb60
|
@@ -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
|
-
|
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
|
-
|
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
data/lib/ocfl.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "ocfl/version"
|
4
3
|
require "zeitwerk"
|
5
4
|
require "json"
|
6
5
|
require "dry/monads"
|
@@ -9,17 +8,8 @@ require "dry-struct"
|
|
9
8
|
require "active_support"
|
10
9
|
require "active_support/core_ext/module/delegation"
|
11
10
|
|
12
|
-
# Custom zeitwerk inflector for OCFL
|
13
|
-
class OCFLInflector < Zeitwerk::Inflector
|
14
|
-
def camelize(basename, _abspath)
|
15
|
-
return "OCFL" if basename == "ocfl"
|
16
|
-
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
11
|
loader = Zeitwerk::Loader.for_gem
|
22
|
-
loader.inflector
|
12
|
+
loader.inflector.inflect("ocfl" => "OCFL")
|
23
13
|
loader.setup
|
24
14
|
|
25
15
|
module OCFL
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocfl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
rubygems_version: 3.5.
|
128
|
+
rubygems_version: 3.5.10
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A ruby library for interacting with the Oxford Common File Layout (OCFL)
|