Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'octopi'
- require 'ruby-growl'
- require 'simple-daemon'
- include Octopi
- class Git
- def initialize
- @stash = {}
- end
- def growl(repo, branch, commits)
- g = Growl.new "localhost", "ruby-growl", ["ruby-growl Notification"]
- g.notify "ruby-growl Notification", "#{commits.author['name']} commited to \"#{repo.name}\" on branch \"#{branch.name}\"", "#{comms.message}"
- @stash[repos.name] = comms.id
- end
- def get_git(purr = true)
- authenticated_with :config => "/Users/menthol/Desktop/git_hubble/github.yml" do |auth|
- user = auth.user
- repos = user.repositories
- repos.each do |repo|
- repo = repo.name
- branch = repo(branch.name)
- commits = branch.commits.first
- id = @stash[commit.id, branch.name, repo.name]
- unless commits.id == id
- growl(repo, branch, commits) unless purr
- end
- end
- end
- end
- end
- class CommitFetcher < SimpleDaemon::Base
- SimpleDaemon::WORKING_DIRECTORY = File.dirname(__FILE__) + '/log'
- def self.start
- puts "Go Go Gadget CommitFetcher! at #{Time.now}"
- g = Git.new
- g.get_git("purr")
- loop do
- puts "**************************\nwe're on a road to nowhere...\n**************************"
- sleep(30)
- g.get_git
- end
- end
- def self.stop
- puts "Ok CommitFetcher, take a break kid. #{Time.now}"
- end
- end
- CommitFetcher.daemonize
- # each do |fork|
- # branch = fork.branches
- # end
- # branch.
Add Comment
Please, Sign In to add comment