ocfl 0.8.0 → 0.8.1

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: 9b1b7553fa1d862a3aa1f6a7f63b148f424f1448c321f7b534776c857ce932f2
4
- data.tar.gz: 8408cf71f4a08fc2c44485ea69e6f77eb5e49366a80d460d20e7ab7961ef9442
3
+ metadata.gz: c21578c64e68d5bdab7fcea3b08bf8210a967a52d0d6b0f2ecdc203a4f2eaca4
4
+ data.tar.gz: 48503dd0f9011c88bbf20bc6adf073d2b1ff422ac1ed06063c332f7c3bbf619e
5
5
  SHA512:
6
- metadata.gz: 5420543eb4d07840970600fbc1f4a475e2ae3f09dea57de76087e626ed87a99ec9b02cf4dd38598398fb75aaa1e8eb61fb20d2af4d4b2b9939a269cf811d7b13
7
- data.tar.gz: f3f6b84156e307897c3be76ed247043ce5d5f161536267b2ee5cfb8a91b50c6080da57ba6fc5c063349603784a13689ef4bbc74c624cbf302ec3f50810b53307
6
+ metadata.gz: 74169c05ca7d91082db0198d252234956c7a47139d57419f5be14e8e23168af39e75b9d9e78d397bd1b65fbc688834ee84cd1456d452795163c777c6c7da15c7
7
+ data.tar.gz: acd185ad8a09d1b016d9c6867d5b4b68005fbe1227abe8848912f917c3d71f4d535cd1847cc4422606fec0d5fc01b9dbf59b6b613c4e5701dfca1703ebae79dc
data/.rubocop.yml CHANGED
@@ -22,6 +22,9 @@ Metrics/BlockLength:
22
22
  - describe
23
23
  - context
24
24
 
25
+ Metrics/ClassLength:
26
+ Max: 110
27
+
25
28
  RSpec/MultipleExpectations:
26
29
  Enabled: false
27
30
 
@@ -21,7 +21,9 @@ module OCFL
21
21
 
22
22
  def move_file(incoming_path)
23
23
  prepare_content_directory
24
- add(incoming_path)
24
+ already_stored = add(incoming_path)
25
+ return if already_stored
26
+
25
27
  FileUtils.mv(incoming_path, content_path)
26
28
  end
27
29
 
@@ -80,18 +82,26 @@ module OCFL
80
82
  # @param [String] logical_file_path where we're going to store the file (e.g. 'object/directory_builder_spec.rb')
81
83
  # @param [String] incoming_path where's this file from (e.g. 'spec/ocfl/object/directory_builder_spec.rb')
82
84
  def copy_one(logical_file_path, incoming_path)
83
- add(incoming_path, logical_file_path:)
85
+ already_stored = add(incoming_path, logical_file_path:)
86
+ return if already_stored
87
+
84
88
  parent_dir = (content_path / logical_file_path).parent
85
89
  FileUtils.mkdir_p(parent_dir) unless parent_dir == content_path
86
90
  FileUtils.cp(incoming_path, content_path / logical_file_path)
87
91
  end
88
92
 
93
+ # @return [Boolean] true if the file already existed in this object. If false, the object must be
94
+ # moved to the content directory.
89
95
  def add(incoming_path, logical_file_path: File.basename(incoming_path))
90
96
  digest = Digest::SHA512.file(incoming_path).to_s
91
97
  version_content_path = content_path.relative_path_from(object_directory.object_root)
92
98
  file_path_relative_to_root = (version_content_path / logical_file_path).to_s
93
- @manifest[digest] = [file_path_relative_to_root]
94
- @state[digest] = [logical_file_path]
99
+ result = @manifest.key?(digest)
100
+ @manifest[digest] ||= []
101
+ @state[digest] ||= []
102
+ @manifest[digest].push(file_path_relative_to_root)
103
+ @state[digest].push(logical_file_path)
104
+ result
95
105
  end
96
106
 
97
107
  def prepare_content_directory
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.8.0"
4
+ VERSION = "0.8.1"
5
5
  end
data/tmp/.keep ADDED
File without changes
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -103,6 +103,7 @@ files:
103
103
  - lib/ocfl/object/version.rb
104
104
  - lib/ocfl/version.rb
105
105
  - sig/ocfl.rbs
106
+ - tmp/.keep
106
107
  homepage: https://github.com/sul-dlss/ocfl-rb
107
108
  licenses: []
108
109
  metadata: