[Groonga-commit] groonga/heroku-sample-rroonga-blog at 299112f [master] Add import tasks for testing

Back to archive index

Kouhei Sutou null+****@clear*****
Sun May 25 17:22:43 JST 2014


Kouhei Sutou	2014-05-25 17:22:43 +0900 (Sun, 25 May 2014)

  New Revision: 299112f91ee8cb60911483c4f361d4e0abd84bdd
  https://github.com/groonga/heroku-sample-rroonga-blog/commit/299112f91ee8cb60911483c4f361d4e0abd84bdd

  Message:
    Add import tasks for testing

  Added files:
    lib/tasks/import.rake

  Added: lib/tasks/import.rake (+43 -0) 100644
===================================================================
--- /dev/null
+++ lib/tasks/import.rake    2014-05-25 17:22:43 +0900 (dcd8611)
@@ -0,0 +1,43 @@
+require 'rss'
+
+def import_rss(url)
+  rss = RSS::Parser.parse(url)
+  rss.items.each do |item|
+    Post.create(title:   item.title,
+                content: item.description)
+  end
+end
+
+namespace :import do
+  task prepare: :environment
+
+  namespace :blogroonga do
+    desc 'Import blogroonga entries in English'
+    task en: 'import:prepare' do
+      import_rss('http://groonga.org/blog/index.rdf')
+    end
+
+    desc 'Import blogroonga entries in Japanese'
+    task ja: 'import:prepare' do
+      import_rss('http://groonga.org/ja/blog/index.rdf')
+    end
+  end
+
+  desc 'Import blogroonga entries'
+  task :blogroonga => ['import:blogroonga:en', 'import:blogroonga:ja']
+
+  namespace :ruby do
+    desc 'Import Ruby news in English'
+    task en: 'import:prepare' do
+      import_rss('https://www.ruby-lang.org/en/feeds/news.rss')
+    end
+
+    desc 'Import Ruby news in Japanese'
+    task ja: 'import:prepare' do
+      import_rss('https://www.ruby-lang.org/ja/feeds/news.rss')
+    end
+  end
+
+  desc 'Import Ruby news'
+  task :ruby => ['import:ruby:en', 'import:ruby:ja']
+end
-------------- next part --------------
HTML����������������������������...
下載 



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