bagit 0.6.0 → 0.7.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 +4 -4
- data/Gemfile +4 -0
- data/bagit.gemspec +2 -2
- data/lib/bagit/fetch.rb +1 -1
- data/lib/bagit/info.rb +1 -3
- data/lib/bagit/manifest.rb +11 -15
- data/lib/bagit/string.rb +1 -1
- data/lib/bagit/valid.rb +3 -3
- data/lib/bagit/version.rb +1 -1
- data/spec/fetch_spec.rb +1 -1
- data/spec/manifest_spec.rb +3 -3
- data/spec/tag_info_spec.rb +2 -2
- data/spec/util/bagit_matchers.rb +2 -2
- metadata +20 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8a18a014f06a83e944facc05aa938c8ea7f41144467187f2aac4b837f53b903
|
|
4
|
+
data.tar.gz: 5c67d9dd7be23e5a01c2f43cf20731ee5de4002dde56f4444ff448c966f63149
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9873a147b372cd47176a25712166287598138bd6fd4cf763351108b230d6cb20932a714bd573a7900878adc51904cc262092c9ad51fff1cc96fd2b9df6c2ec1
|
|
7
|
+
data.tar.gz: 82d34834c6f6ceb653a3255cb3a1b275bc4896d174afd8e42476408e786520d21275324092a9e625f6648ed72a5426a2239c24ef1a0997a041207f6387091fc3
|
data/Gemfile
CHANGED
data/bagit.gemspec
CHANGED
|
@@ -14,10 +14,11 @@ Gem::Specification.new do |spec|
|
|
|
14
14
|
spec.authors = ["Tom Johnson, Francesco Lazzarino, Jamie Little"]
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
|
-
spec.required_ruby_version = ">= 2.
|
|
17
|
+
spec.required_ruby_version = ">= 2.7", "< 4.1"
|
|
18
18
|
|
|
19
19
|
spec.add_dependency "validatable", "~> 1.6"
|
|
20
20
|
spec.add_dependency "docopt", "~> 0.5.0"
|
|
21
|
+
spec.add_dependency "logger", "~> 1.7"
|
|
21
22
|
|
|
22
23
|
spec.add_development_dependency "bundler"
|
|
23
24
|
spec.add_development_dependency "coveralls"
|
|
@@ -29,6 +30,5 @@ Gem::Specification.new do |spec|
|
|
|
29
30
|
|
|
30
31
|
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
31
32
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
32
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
33
33
|
spec.require_paths = ["lib"]
|
|
34
34
|
end
|
data/lib/bagit/fetch.rb
CHANGED
data/lib/bagit/info.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "set"
|
|
4
|
-
|
|
5
3
|
module BagIt
|
|
6
4
|
module Info
|
|
7
5
|
@@bag_info_headers = {
|
|
@@ -73,7 +71,7 @@ module BagIt
|
|
|
73
71
|
def write_info_file(file, hash)
|
|
74
72
|
dups = hash.keys.inject(Set.new) { |acc, key|
|
|
75
73
|
a = hash.keys.grep(/#{key}/i)
|
|
76
|
-
acc + (a.size > 1 ? a : [])
|
|
74
|
+
acc + ((a.size > 1) ? a : [])
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
raise "Multiple labels (#{dups.to_a.join ", "}) in #{file}" unless dups.empty?
|
data/lib/bagit/manifest.rb
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "pathname"
|
|
4
3
|
require "digest/sha1"
|
|
5
4
|
require "digest/md5"
|
|
6
5
|
|
|
@@ -8,17 +7,15 @@ module BagIt
|
|
|
8
7
|
# Requires response to bag_dir, tag_files, bag_files
|
|
9
8
|
module Manifest
|
|
10
9
|
def encode_filename(s)
|
|
11
|
-
s = s.gsub(
|
|
12
|
-
s
|
|
13
|
-
s
|
|
10
|
+
s = s.gsub("\r", "%0D")
|
|
11
|
+
s.gsub("\n", "%0A")
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
# All tag files that are bag manifest files (manifest-[algorithm].txt)
|
|
17
15
|
def manifest_files
|
|
18
|
-
|
|
16
|
+
Dir[File.join(@bag_dir, "*")].select { |f|
|
|
19
17
|
File.file?(f) && File.basename(f) =~ /^manifest-.*.txt$/
|
|
20
18
|
}
|
|
21
|
-
files
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
# A path to a manifest file of the specified algorithm
|
|
@@ -78,10 +75,9 @@ module BagIt
|
|
|
78
75
|
|
|
79
76
|
# All tag files that are bag manifest files (tagmanifest-[algorithm].txt)
|
|
80
77
|
def tagmanifest_files
|
|
81
|
-
|
|
78
|
+
Dir[File.join(@bag_dir, "*")].select { |f|
|
|
82
79
|
File.file?(f) && File.basename(f) =~ /^tagmanifest-.*.txt$/
|
|
83
80
|
}
|
|
84
|
-
files
|
|
85
81
|
end
|
|
86
82
|
|
|
87
83
|
# A path to a tagmanifest file of the specified algorithm
|
|
@@ -134,7 +130,7 @@ module BagIt
|
|
|
134
130
|
raise "Tag file already exists, will not overwrite: #{path}\n Use add_tag_file(path) to add an existing tag file."
|
|
135
131
|
end
|
|
136
132
|
|
|
137
|
-
data = File.
|
|
133
|
+
data = File.read(f)
|
|
138
134
|
rel_path = Pathname.new(f).relative_path_from(Pathname.new(bag_dir)).to_s
|
|
139
135
|
|
|
140
136
|
# sha1
|
|
@@ -169,12 +165,12 @@ module BagIt
|
|
|
169
165
|
mf =~ /manifest-(.+).txt$/
|
|
170
166
|
|
|
171
167
|
algo = case Regexp.last_match(1)
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
when /sha1/i
|
|
169
|
+
Digest::SHA1
|
|
170
|
+
when /md5/i
|
|
171
|
+
Digest::MD5
|
|
172
|
+
else
|
|
173
|
+
:unknown
|
|
178
174
|
end
|
|
179
175
|
|
|
180
176
|
# check it, an unknown algorithm is always true
|
data/lib/bagit/string.rb
CHANGED
data/lib/bagit/valid.rb
CHANGED
|
@@ -8,6 +8,7 @@ require "logger"
|
|
|
8
8
|
module BagIt
|
|
9
9
|
class Bag
|
|
10
10
|
include Validatable
|
|
11
|
+
|
|
11
12
|
validates_true_for :consistency, logic: proc { consistent? }
|
|
12
13
|
validates_true_for :completeness, logic: proc { complete? }
|
|
13
14
|
end
|
|
@@ -15,14 +16,13 @@ module BagIt
|
|
|
15
16
|
module Validity
|
|
16
17
|
def decode_filename(s)
|
|
17
18
|
s = s.gsub("%0D", "\r")
|
|
18
|
-
s
|
|
19
|
-
s
|
|
19
|
+
s.gsub("%0A", "\n")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# Return true if the manifest cover all files and all files are
|
|
23
23
|
# covered.
|
|
24
24
|
def complete?
|
|
25
|
-
logger = Logger.new(
|
|
25
|
+
logger = Logger.new($stdout)
|
|
26
26
|
|
|
27
27
|
errors.add :completeness, "there are no manifest files" if manifest_files == []
|
|
28
28
|
|
data/lib/bagit/version.rb
CHANGED
data/spec/fetch_spec.rb
CHANGED
data/spec/manifest_spec.rb
CHANGED
|
@@ -101,10 +101,10 @@ describe BagIt::Bag do
|
|
|
101
101
|
end
|
|
102
102
|
it "contains manifest and bag info files" do
|
|
103
103
|
@bag.tagmanifest_files.each do |mf|
|
|
104
|
-
expect(File.
|
|
105
|
-
expect(File.
|
|
104
|
+
expect(File.read(mf)).to include(File.basename(@bag.bag_info_txt_file))
|
|
105
|
+
expect(File.read(mf)).to include(File.basename(@bag.bagit_txt_file))
|
|
106
106
|
@bag.manifest_files.each do |man|
|
|
107
|
-
expect(File.
|
|
107
|
+
expect(File.read(mf)).to include(man)
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
end
|
data/spec/tag_info_spec.rb
CHANGED
|
@@ -98,7 +98,7 @@ describe BagIt::Bag do
|
|
|
98
98
|
@bag.write_bag_info "Source-Organization" => "Awesome Inc."
|
|
99
99
|
@bag.write_bag_info "Bagging-Date" => "1901-01-01"
|
|
100
100
|
@bag.write_bag_info
|
|
101
|
-
contents = File.
|
|
101
|
+
contents = File.read(path)
|
|
102
102
|
expect(contents).to include "Some Other Agent"
|
|
103
103
|
expect(contents).to include "Awesome Inc."
|
|
104
104
|
expect(contents).to include "1901-01-01"
|
|
@@ -107,7 +107,7 @@ describe BagIt::Bag do
|
|
|
107
107
|
path = File.join @bag_path, "bag-info.txt"
|
|
108
108
|
@bag.write_bag_info "Source-Organization" => "Awesome Inc."
|
|
109
109
|
@bag.write_bag_info "Source-Organization" => "Awesome LLC."
|
|
110
|
-
contents = File.
|
|
110
|
+
contents = File.read(path)
|
|
111
111
|
expect(contents).to include "Awesome LLC."
|
|
112
112
|
expect(contents).not_to include "Awesome Inc."
|
|
113
113
|
end
|
data/spec/util/bagit_matchers.rb
CHANGED
|
@@ -18,7 +18,7 @@ module BagitMatchers
|
|
|
18
18
|
def failure_message_when_negated
|
|
19
19
|
"expected <#{@target}> to not be in collection <#{@expected}>"
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
alias_method :negative_failure_message, :failure_message_when_negated
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def be_in(*expected_collection)
|
|
@@ -38,7 +38,7 @@ module BagitMatchers
|
|
|
38
38
|
def failure_message_when_negated
|
|
39
39
|
"expected <#{@target}> to not exist but it does"
|
|
40
40
|
end
|
|
41
|
-
|
|
41
|
+
alias_method :negative_failure_message, :failure_message_when_negated
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def exist_on_fs
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bagit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Johnson, Francesco Lazzarino, Jamie Little
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: validatable
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.5.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: logger
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.7'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.7'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -181,26 +195,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
181
195
|
requirements:
|
|
182
196
|
- - ">="
|
|
183
197
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: '2.
|
|
198
|
+
version: '2.7'
|
|
185
199
|
- - "<"
|
|
186
200
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: '
|
|
201
|
+
version: '4.1'
|
|
188
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
203
|
requirements:
|
|
190
204
|
- - ">="
|
|
191
205
|
- !ruby/object:Gem::Version
|
|
192
206
|
version: '0'
|
|
193
207
|
requirements: []
|
|
194
|
-
rubygems_version: 3.4
|
|
208
|
+
rubygems_version: 3.1.4
|
|
195
209
|
signing_key:
|
|
196
210
|
specification_version: 4
|
|
197
211
|
summary: BagIt package generation and validation
|
|
198
|
-
test_files:
|
|
199
|
-
- spec/bagit_spec.rb
|
|
200
|
-
- spec/fetch_spec.rb
|
|
201
|
-
- spec/manifest_spec.rb
|
|
202
|
-
- spec/spec_helper.rb
|
|
203
|
-
- spec/tag_info_spec.rb
|
|
204
|
-
- spec/tag_spec.rb
|
|
205
|
-
- spec/util/bagit_matchers.rb
|
|
206
|
-
- spec/validation_spec.rb
|
|
212
|
+
test_files: []
|