[Groonga-commit] droonga/wikipedia-search at ae0b54c [master] Define tasks by class

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Apr 4 16:34:39 JST 2014


Kouhei Sutou	2014-04-04 16:34:39 +0900 (Fri, 04 Apr 2014)

  New Revision: ae0b54cf58e30dff59026a37cf299aafa0437f2c
  https://github.com/droonga/wikipedia-search/commit/ae0b54cf58e30dff59026a37cf299aafa0437f2c

  Message:
    Define tasks by class

  Added files:
    lib/wikipedia-search/task.rb
  Removed files:
    lib/wikipedia-search/task/download.rb
  Modified files:
    Rakefile

  Modified: Rakefile (+3 -1)
===================================================================
--- Rakefile    2014-04-04 16:24:03 +0900 (48ce133)
+++ Rakefile    2014-04-04 16:34:39 +0900 (8de3a21)
@@ -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

  Added: lib/wikipedia-search/task.rb (+44 -0) 100644
===================================================================
--- /dev/null
+++ lib/wikipedia-search/task.rb    2014-04-04 16:34:39 +0900 (f94c768)
@@ -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

  Deleted: lib/wikipedia-search/task/download.rb (+0 -18) 100644
===================================================================
--- lib/wikipedia-search/task/download.rb    2014-04-04 16:24:03 +0900 (c7d9a24)
+++ /dev/null
@@ -1,18 +0,0 @@
-require "wikipedia-search/downloader"
-
-namespace :data do
-  data_dir_path = Pathname.new("data")
-  directory data_dir_path.to_s
-
-  namespace :download do
-    base_name = "jawiki-latest-pages-articles.xml.bz2"
-    ja_data_path = data_dir_path + base_name
-    file ja_data_path.to_s => data_dir_path.to_s do
-      url = "http://dumps.wikimedia.org/jawiki/latest/#{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
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index