Add mjolnir rakefile

This commit is contained in:
Henrik Lissner 2015-01-20 03:10:38 -05:00
parent ac4e9a96fd
commit 5b79d209af
2 changed files with 13 additions and 57 deletions

View file

@ -1,57 +0,0 @@
#!/usr/bin/env ruby
# A quick script to watch a list of RSS feeds and report new entries
# to Growl, which is chained to Prowl and my home network. Never miss
# a notification again!
# require 'prowl'
require 'net/http'
require 'simple-rss'
require 'ruby-growl'
GUID_FILE = "#{Dir.home}/.watch-rss"
FEEDS_URL = "https://dl.dropboxusercontent.com/u/2908279/public/feeds"
def open_url(uri)
Net::HTTP.get(URI(uri))
end
begin
guids = File.exists?(GUID_FILE) ? File.open(GUID_FILE).read.split("\n") : []
feeds = open_url(FEEDS_URL).split("\n")
g = Growl.new("localhost", "RSS Watcher")
g.add_notification("RSS Watcher")
feeds.each do |feed|
url,terms = feed.split("|")
feed = SimpleRSS.parse(open_url(url))
feed.items.each do |item|
guid = item.id || item.link
if not terms.nil? and not item.title.index(terms)
p "Skipped: #{item.title}"
next
end
unless guids.include? guid
g.notify("RSS Watcher", "New RSS entry!", "#{item.title}")
guids << guid
p "Found: #{item.title}"
else
p "Ignored: #{item.title}"
end
end
end
File.open(GUID_FILE, 'w').write(guids.join("\n"))
rescue Exception => e
STDERR.puts e.message
# STDERR.puts e.backtrace.inspect.join("\n")
end

13
rake/pkg/mjolnir.rake Normal file
View file

@ -0,0 +1,13 @@
task :mjolnir => 'mjolnir:update'
namespace :mjolnir do
task :install do
Package.install "lua", "luarocks"
sh "mkdir -p ~/.luarocks"
sh "echo 'rocks_servers = { \"http://rocks.moonscript.org\" }' > ~/.luarocks/config.lua"
sh "luarocks install mjolnir.hotkey"
sh "luarocks install mjolnir.application"
sh "luarocks install mjolnir._asm.modal_hotkey"
end
end