Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/verifier/hathifiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ def verify_hathifile(date: current_date)
path = derivative.path
next unless verify_file(path: path)
contents_verifier = verify_hathifile_contents(path: path)
catalog_path = Derivative::CatalogArchive.new(date: date - 1, full: derivative.full).path
catalog_path = catalog_source(hathifile: derivative).path
verify_hathifile_linecount(contents_verifier.line_count, catalog_path: catalog_path)
end
end

# The post-Zephir catalog whence the hathifile was derived
# @param hathifile [Derivative::Hathifile]
# @return [Derivative::CatalogArchive]
def catalog_source(hathifile:)
Derivative::CatalogArchive.new(date: hathifile.date, full: hathifile.full)
end

def verify_hathifile_linecount(linecount, catalog_path:)
catalog_linecount = gzip_linecount(path: catalog_path)
if linecount < catalog_linecount
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/verifier/hathifiles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,13 @@ module PostZephirProcessing
expect_not_ok(:verify_hathifile_contents, contents, errmsg: /.*columns.*/, gzipped: true)
end
end

describe "#catalog_source" do
it "has the correct datestamp" do
hathifile_derivative = Derivative::Hathifile.new(date: Date.today, full: false)
catalog_derivative = described_class.new.catalog_source(hathifile: hathifile_derivative)
expect(catalog_derivative.datestamp).to eq(hathifile_derivative.datestamp - 1)
end
end
end
end
Loading