mirror of
https://github.com/StrawberryMaster/wayback-machine-downloader.git
synced 2025-12-17 17:56:44 +00:00
Fix exact match logic and add a test
This commit is contained in:
parent
e166e9443d
commit
4af80adca6
@ -87,14 +87,12 @@ class WaybackMachineDownloader
|
|||||||
snapshot_list_to_consider += get_raw_list_from_api(@base_url, nil)
|
snapshot_list_to_consider += get_raw_list_from_api(@base_url, nil)
|
||||||
print "."
|
print "."
|
||||||
unless @exact_match
|
unless @exact_match
|
||||||
snapshot_list_to_consider += get_raw_list_from_api(@base_url + '/*', nil)
|
@maximum_pages.times do |page_index|
|
||||||
print "."
|
snapshot_list = get_raw_list_from_api(@base_url + '/*', page_index)
|
||||||
end
|
break if snapshot_list.empty?
|
||||||
@maximum_pages.times do |page_index|
|
snapshot_list_to_consider += snapshot_list
|
||||||
snapshot_list = get_raw_list_from_api(@base_url + '/*', page_index)
|
print "."
|
||||||
break if snapshot_list.empty?
|
end
|
||||||
snapshot_list_to_consider += snapshot_list
|
|
||||||
print "."
|
|
||||||
end
|
end
|
||||||
puts " found #{snapshot_list_to_consider.lines.count} snaphots to consider."
|
puts " found #{snapshot_list_to_consider.lines.count} snaphots to consider."
|
||||||
puts
|
puts
|
||||||
|
|||||||
@ -39,6 +39,16 @@ class WaybackMachineDownloaderTest < Minitest::Test
|
|||||||
assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-2]
|
assert_equal file_expected, @wayback_machine_downloader.get_file_list_by_timestamp[-2]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_without_exact_match
|
||||||
|
@wayback_machine_downloader.exact_match = false
|
||||||
|
assert @wayback_machine_downloader.get_file_list_curated.size > 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_exact_match
|
||||||
|
@wayback_machine_downloader.exact_match = true
|
||||||
|
assert_equal 1, @wayback_machine_downloader.get_file_list_curated.size
|
||||||
|
end
|
||||||
|
|
||||||
def test_file_list_only_filter_without_matches
|
def test_file_list_only_filter_without_matches
|
||||||
@wayback_machine_downloader.only_filter = 'abc123'
|
@wayback_machine_downloader.only_filter = 'abc123'
|
||||||
assert_equal 0, @wayback_machine_downloader.get_file_list_curated.size
|
assert_equal 0, @wayback_machine_downloader.get_file_list_curated.size
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user