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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94cc64f9a3a9193d68ed54cdee5dce6dd6f645388eb8224499a73cb71e20ebcb
4
- data.tar.gz: e92f1c0acf2881e9ceb15a21b85fa08068e00b0f119eb0f00fd49c45be9f8559
3
+ metadata.gz: e8a18a014f06a83e944facc05aa938c8ea7f41144467187f2aac4b837f53b903
4
+ data.tar.gz: 5c67d9dd7be23e5a01c2f43cf20731ee5de4002dde56f4444ff448c966f63149
5
5
  SHA512:
6
- metadata.gz: '080f9b88a1f78604d802ca085809889562d1659a7d538db49d90b86effe5b3d6b70abe12f7257ad9bf685d5578ab6963d79f37636c97b44318db437af024291d'
7
- data.tar.gz: 936250ded0d415be65eaa95b421bbf647537fff92354b1b7de33d440a66254fe6dc6dea67e6899ad022fdb10edba1717afe052425bfed244e42ac38bd17ff7f8
6
+ metadata.gz: a9873a147b372cd47176a25712166287598138bd6fd4cf763351108b230d6cb20932a714bd573a7900878adc51904cc262092c9ad51fff1cc96fd2b9df6c2ec1
7
+ data.tar.gz: 82d34834c6f6ceb653a3255cb3a1b275bc4896d174afd8e42476408e786520d21275324092a9e625f6648ed72a5426a2239c24ef1a0997a041207f6387091fc3
data/Gemfile CHANGED
@@ -3,3 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ group :development do
8
+ gem "rdoc"
9
+ end
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.0", "< 3.4"
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
@@ -21,7 +21,7 @@ module BagIt
21
21
  (url, _length, path) = line.chomp.split(/\s+/, 3)
22
22
 
23
23
  add_file(path) do |file_io|
24
- file_io.write URI.open(url)
24
+ file_io.write URI.parse(url).open
25
25
  end
26
26
  end
27
27
  end
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?
@@ -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(/\r/, "%0D")
12
- s = s.gsub(/\n/, "%0A")
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
- files = Dir[File.join(@bag_dir, "*")].select { |f|
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
- files = Dir[File.join(@bag_dir, "*")].select { |f|
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.open(f, &:read)
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
- when /sha1/i
173
- Digest::SHA1
174
- when /md5/i
175
- Digest::MD5
176
- else
177
- :unknown
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
@@ -8,7 +8,7 @@ class String
8
8
  s = gsub(/\s+/, " ").strip
9
9
 
10
10
  if s.length > width
11
- s[0...width] + '\n' + s[width..-1].wrap(width)
11
+ s[0...width] + '\n' + s[width..].wrap(width)
12
12
  else
13
13
  s
14
14
  end
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 = s.gsub("%0A", "\n")
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(STDOUT)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BagIt
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/spec/fetch_spec.rb CHANGED
@@ -40,7 +40,7 @@ describe BagIt::Bag do
40
40
 
41
41
  it "contains manifested files" do
42
42
  path = File.join @bag_path, "manifest-sha1.txt"
43
- data = File.open(path, &:read)
43
+ data = File.read(path)
44
44
  expect(data).to include("gnu.png")
45
45
  end
46
46
 
@@ -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.open(mf).read).to include(File.basename(@bag.bag_info_txt_file))
105
- expect(File.open(mf).read).to include(File.basename(@bag.bagit_txt_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.open(mf).read).to include(man)
107
+ expect(File.read(mf)).to include(man)
108
108
  end
109
109
  end
110
110
  end
@@ -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.open(path).read
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.open(path).read
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
@@ -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
- alias negative_failure_message failure_message_when_negated
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
- alias negative_failure_message failure_message_when_negated
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.6.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: 2024-09-17 00:00:00.000000000 Z
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.0'
198
+ version: '2.7'
185
199
  - - "<"
186
200
  - !ruby/object:Gem::Version
187
- version: '3.4'
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.19
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: []