Navigation Menu

Skip to content

Commit

Permalink
Define tasks by class
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 4, 2014
1 parent 7fd702d commit ae0b54c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Rakefile
Expand Up @@ -7,4 +7,6 @@ lib_dir_path = base_dir_path + "lib"

$LOAD_PATH.unshift(lib_dir_path.to_s)

require "wikipedia-search/task/download"
require "wikipedia-search/task"

WikipediaSearch::Task.define
44 changes: 44 additions & 0 deletions lib/wikipedia-search/task.rb
@@ -0,0 +1,44 @@
require "wikipedia-search/downloader"

module WikipediaSearch
class Task
class << self
def define
new.define
end
end
include Rake::DSL

def define
namespace :data do
directory data_dir_path.to_s
define_download_tasks
end
end

private
def define_download_tasks
namespace :download do
file ja_data_path.to_s => data_dir_path.to_s do
url = "http://dumps.wikimedia.org/jawiki/latest/#{ja_data_base_name}"
WikipediaSearch::Downloader.download(url, ja_data_path)
end

desc "Download the latest Japanese Wikipedia data."
task :ja => ja_data_path.to_s
end
end

def data_dir_path
@data_dir_path ||= Pathname.new("data")
end

def ja_data_path
@ja_data_path ||= data_dir_path + ja_data_base_name
end

def ja_data_base_name
"jawiki-latest-pages-articles.xml.bz2"
end
end
end
18 changes: 0 additions & 18 deletions lib/wikipedia-search/task/download.rb

This file was deleted.

0 comments on commit ae0b54c

Please sign in to comment.