Permalink
Browse files

updater task

  • Loading branch information...
1 parent 0de0438 commit b05c515d404527e182a12665af581aaff2ab87ab @mfilej committed Oct 24, 2011
Showing with 29 additions and 1 deletion.
  1. +9 −1 Rakefile
  2. +20 −0 lib/updater.rb
View
@@ -1,5 +1,6 @@
+$LOAD_PATH << File.expand_path("../lib", __FILE__)
+
namespace :episodes do
- $LOAD_PATH << File.expand_path("../lib", __FILE__)
require "zero"
Zero.db = ENV["MONGOHQ_URL"] || "zerop_development"
@@ -8,7 +9,14 @@ namespace :episodes do
Parsed.build_index(STDIN.read)
end
+ desc "Updates the index with new episodes"
task :update do
Parsed.update_index(open Parsed::FEED_URL)
end
end
+
+desc "Pings the web app to check for updates"
+task :updater do
+ require "updater"
+ Updater.new.perform
+end
View
@@ -0,0 +1,20 @@
+require "net/http"
+
+class Updater
+ include Net
+
+ def perform
+ HTTP.post_form uri, token: token
+ end
+
+ protected
+
+ def uri
+ URI.parse "http://zerop.heroku.com/update"
+ end
+
+ def token
+ ENV["episodes_update_token"]
+ end
+
+end

0 comments on commit b05c515

Please sign in to comment.