lib/bagit/valid.rb in bagit-0.3.1 vs lib/bagit/valid.rb in bagit-0.3.2.pre

- old
+ new

@@ -2,12 +2,12 @@ module BagIt class Bag include Validatable - validates_true_for :consistency, :logic => Proc.new { complete? } - validates_true_for :completeness, :logic => Proc.new { consistent? } + validates_true_for :consistency, :logic => Proc.new { consistent? } + validates_true_for :completeness, :logic => Proc.new { complete? } end module Validity # Return true if the manifest cover all files and all files are @@ -22,11 +22,11 @@ errors.add :completeness, "#{file} is manifested but not present" end tag_empty_manifests.each do |file| errors.add :completeness, "#{file} is a manifested tag but not present" end - + errors.on(:completeness).nil? end # Return true if all manifested files message digests match. def consistent? @@ -40,11 +40,11 @@ Digest::MD5 else :unknown end # Check every file in the manifest - open(mf) do |io| + File.open(mf) do |io| io.each_line do |line| expected, path = line.chomp.split /\s+/, 2 file = File.join(bag_dir, path) if File.exist? file actual = algo.file(file).hexdigest @@ -53,12 +53,12 @@ end end end end end - + errors.on(:consistency).nil? end # Checks for validity against Payload-Oxum def valid_oxum? @@ -91,11 +91,11 @@ # Returns a list of all files present in the manifest files def manifested_files manifest_files.inject([]) do |acc, mf| - files = open(mf) do |io| + files = File.open(mf) do |io| io.readlines.map do |line| digest, path = line.chomp.split /\s+/, 2 path end @@ -107,10 +107,10 @@ end # Returns a list of all files in the tag manifest files def tag_manifested_files tagmanifest_files.inject([]) do |acc, mf| - files = open(mf) do |io| + files = File.open(mf) do |io| io.readlines.map do |line| digest, path = line.chomp.split /\s+/, 2 path end end