Skip to content

Commit

Permalink
Updated to meet latest foreverb.
Browse files Browse the repository at this point in the history
  • Loading branch information
DAddYE committed Jan 25, 2012
1 parent d8598f4 commit 8e1490d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
39 changes: 16 additions & 23 deletions bin/githubwatcher
@@ -1,43 +1,36 @@
#!/usr/bin/ruby
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)

$:.unshift File.expand_path('../../lib', __FILE__)
require 'rubygems' unless defined?(Gem)
require 'bundler/setup'
require 'forever'
require 'githubwatcher'

while ARGV.size > 0
case arg = ARGV.shift
when "configure"
editor = `which mate`.chomp! || `which vim`.chomp!
puts "Im unable to find an editor, open manually ~/.githubwatcher/repos.yaml" and exit unless editor
system editor, File.expand_path('~/.githubwatcher/repos.yaml') and exit
when "reset"
system "rm -rf ~/.githubwatcher"
end
case arg = ARGV[0]
when "configure"
editor = `which mate`.chomp! || `which vim`.chomp!
puts "Im unable to find an editor, open manually ~/.githubwatcher/repos.yaml" and exit unless editor
system editor, File.expand_path('~/.githubwatcher/repos.yaml') and exit
when "reset"
system "rm -rf ~/.githubwatcher"
end

Forever.run do
# Our working directory, here we store pids/logs and obviously our list of repo to watch
dir File.expand_path('~/.githubwatcher')

on_error do |e|
unless (@_errors ||= []).include?(e.message)
Githubwatcher.notify("Error!", e.message, false)
@_errors << e.message
end
Githubwatcher.notify("Error!", e.message) unless @_errors.include?(e.message)
end

on_ready do
before :all do
Githubwatcher.setup
Githubwatcher.notify("GitHub Watcher", "was started...", false)
end

on_exit do
Githubwatcher.notify("GitHub Watcher", "was stopped...", false)
Githubwatcher.notify("GitHub Watcher", "was started...")
@_errors = [] # Store common errors
end

every 5.seconds do
Githubwatcher.run
end

after :all do
Githubwatcher.notify("GitHub Watcher", "was stopped...")
end
end
2 changes: 1 addition & 1 deletion githubwatcher.gemspec
Expand Up @@ -19,5 +19,5 @@ Gem::Specification.new do |s|
s.require_paths = %w[lib]
s.add_dependency 'httparty', '~>0.7.8'
s.add_dependency 'growl', '~>1.0.3'
s.add_dependency 'foreverb', '~>0.2.6'
s.add_dependency 'foreverb', '~>0.3.0'
end
4 changes: 2 additions & 2 deletions lib/githubwatcher.rb
Expand Up @@ -31,8 +31,8 @@ def setup
end

@_watch = YAML.load_file(WATCH)
@_repos = YAML.load_file(DB) if File.exist?(DB)
@base_uri, @api_version = YAML.load_file(API)
@_repos = YAML.load_file(DB) if File.exist?(DB)

base_uri @base_uri
end
Expand Down Expand Up @@ -93,7 +93,7 @@ def watch
@_watch ||= []
end

def notify(title, text, sticky=true)
def notify(title, text, sticky=false)
Growl.notify(text, :title => title, :icon => File.expand_path("../../images/icon.png", __FILE__), :sticky => sticky); sleep 0.2
puts "=> #{title}: #{text}"
end
Expand Down

0 comments on commit 8e1490d

Please sign in to comment.