Skip to content

Commit 3800784

Browse files
committed
test wikipedia: don't override #download
1 parent 26b4248 commit 3800784

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lib/datasets/wikipedia.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ def each(&block)
5353
end
5454

5555
private
56+
def base_name
57+
"#{@language}wiki-latest-#{type_in_path}.xml.bz2"
58+
end
59+
60+
def data_path
61+
cache_dir_path + base_name
62+
end
63+
5664
def open_data(&block)
57-
base_name = "#{@language}wiki-latest-#{type_in_path}.xml.bz2"
58-
data_path = cache_dir_path + base_name
5965
data_url = "https://dumps.wikimedia.org/#{@language}wiki/latest/#{base_name}"
6066
bz2 = Enumerator.new do |yielder|
6167
download(data_path, data_url) do |bz2_chunk|

test/test-wikipedia.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def teardown
2121
end
2222

2323
test("#each") do
24-
def @dataset.download(output_path, url)
25-
xml_path = output_path.sub_ext("")
26-
xml_path.open("w") do |xml_file|
27-
xml_file.puts(<<-XML)
24+
data_path = @dataset.__send__(:data_path)
25+
xml_path = data_path.sub_ext("")
26+
xml_path.open("w") do |xml_file|
27+
xml_file.puts(<<-XML)
2828
<mediawiki
2929
xmlns="http://www.mediawiki.org/xml/export-0.10/"
3030
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -55,11 +55,10 @@ def @dataset.download(output_path, url)
5555
</revision>
5656
</page>
5757
</mediawiki>
58-
XML
59-
end
60-
unless system("bzip2", xml_path.to_s)
61-
raise "failed to run bzip2"
62-
end
58+
XML
59+
end
60+
unless system("bzip2", xml_path.to_s)
61+
raise "failed to run bzip2"
6362
end
6463

6564
contributor = Datasets::Wikipedia::Contributor.new("user", 10)

0 commit comments

Comments
 (0)