ocfl 0.5.0 → 0.6.0

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: 734c2a614db8c30eb86ddd0c7a32b6c10d813adb9ae5244d50614f35244c64cd
4
- data.tar.gz: 4b5daffdbd581fe38974975a7f9e6dfcef734d078833b0eb030d750aacc7b18e
3
+ metadata.gz: b32346d0bd14e71b28385a1e34ad4f4af73335ab64345fa374c890ccf07e4f83
4
+ data.tar.gz: 4f9f6bc929cdee4f24e3b8b4bca167d69219d34fb74de00ff75414a68ee66ad2
5
5
  SHA512:
6
- metadata.gz: 8c67987902f4adc67c8c250af66568872b9f3e9ca9cd9a3df60f26702e4ac16bfb6aea9e44628f427fe910af548ebc534436005e857f15cc3d47e4a31cc667a3
7
- data.tar.gz: 857a0a20ee5a57c6b7087ef43264dbe2d3fd9b258175cc9449885a4b0eb1d56823cfe87eccad9bb86c5efc26ce5c2433e0465d6c5b0e425523668a18a7131e6a
6
+ metadata.gz: e9a520d6bf056649a3b4c261ea27fb6d5a994d8f0bd274f5a8aca19751e24fa4c1ca08de57ee7971b927081f4dcb941a514570deba8088580579613123a1d1f1
7
+ data.tar.gz: a3df7b8ae6913eee74a0bea12474ee4c7ebe937bd1b92c28c8918e2a00c46d82191e99a360dacd780b1be65f1bdab25dbca7edfa47f3d03b8d4cf8e3ef534ebe
data/README.md CHANGED
@@ -44,20 +44,12 @@ directory.path(filepath: "ocfl.rbs", version: "v2")
44
44
  # => <Pathname:/files/[object_root]/v2/content/ocfl.rbs>
45
45
 
46
46
  # Get the path of a file in the head version
47
- directory.path(filepath: "ocfl.rbs", version: :head)
48
- # => <Pathname:/files/[object_root]/v2/content/ocfl.rbs>
49
-
50
- # Get the path of a file from the latest version in which it was changed
51
47
  directory.path(filepath: "ocfl.rbs")
52
48
  # => <Pathname:/files/[object_root]/v2/content/ocfl.rbs>
53
49
 
54
50
  new_version = directory.overwrite_current_version
55
51
  new_version.copy_file('sig/ocfl.rbs')
56
52
  new_version.save
57
-
58
- new_version = directory.clone_current_version
59
- new_version.copy_file('Gemfile')
60
- new_version.save
61
53
  ```
62
54
 
63
55
  ## Development
@@ -18,14 +18,10 @@ module OCFL
18
18
  delegate :head, :versions, :manifest, to: :inventory
19
19
 
20
20
  def path(filepath:, version: nil)
21
- version = head if version == :head
22
- relative_path = if version
23
- version_inventory(version).path(filepath)
24
- else
25
- inventory.path(filepath)
26
- end
21
+ version ||= head
22
+ relative_path = version_inventory(version).path(filepath)
27
23
 
28
- raise FileNotFound, "Path '#{filepath}' not found in #{version || "object"} inventory" if relative_path.nil?
24
+ raise FileNotFound, "Path '#{filepath}' not found in #{version} inventory" if relative_path.nil?
29
25
 
30
26
  object_root / relative_path
31
27
  end
@@ -69,10 +65,6 @@ module OCFL
69
65
  end
70
66
 
71
67
  def begin_new_version
72
- DraftVersion.new(object_directory: self)
73
- end
74
-
75
- def clone_current_version
76
68
  DraftVersion.new(object_directory: self, state: head_inventory.state)
77
69
  end
78
70
 
@@ -34,13 +34,11 @@ module OCFL
34
34
 
35
35
  # @return [String,nil] the path to the file relative to the object root. (e.g. v2/content/image.tiff)
36
36
  def path(logical_path)
37
- matching_paths = manifest.values.flatten.select do |path|
38
- path.match(%r{\Av\d+/#{content_directory}/#{logical_path}\z})
39
- end
37
+ digest, = state.find { |_, logical_paths| logical_paths.include?(logical_path) }
40
38
 
41
- return if matching_paths.empty?
39
+ return unless digest
42
40
 
43
- matching_paths.max_by { |path| path[/\d+/].to_i }
41
+ manifest[digest].find { |content_path| content_path.match(%r{\Av\d+/#{content_directory}/#{logical_path}\z}) }
44
42
  end
45
43
 
46
44
  def head_version
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.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
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.5.0
4
+ version: 0.6.0
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-05-23 00:00:00.000000000 Z
11
+ date: 2024-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport