Guest User

Untitled

a guest
Jun 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1.  
  2. require 'rubygems'
  3. require 'octopi'
  4. require 'ruby-growl'
  5. require 'simple-daemon'
  6.  
  7. include Octopi
  8.  
  9. class Git
  10.  
  11. def initialize
  12. @stash = {}
  13. end
  14.  
  15. def growl(repo, branch, commits)
  16. g = Growl.new "localhost", "ruby-growl", ["ruby-growl Notification"]
  17. g.notify "ruby-growl Notification", "#{commits.author['name']} commited to \"#{repo.name}\" on branch \"#{branch.name}\"", "#{comms.message}"
  18. @stash[repos.name] = comms.id
  19. end
  20.  
  21. def get_git(purr = true)
  22. authenticated_with :config => "/Users/menthol/Desktop/git_hubble/github.yml" do |auth|
  23. user = auth.user
  24. repos = user.repositories
  25. repos.each do |repo|
  26. repo = repo.name
  27. branch = repo(branch.name)
  28. commits = branch.commits.first
  29.  
  30. id = @stash[commit.id, branch.name, repo.name]
  31. unless commits.id == id
  32. growl(repo, branch, commits) unless purr
  33. end
  34. end
  35. end
  36. end
  37.  
  38. end
  39.  
  40. class CommitFetcher < SimpleDaemon::Base
  41. SimpleDaemon::WORKING_DIRECTORY = File.dirname(__FILE__) + '/log'
  42.  
  43. def self.start
  44. puts "Go Go Gadget CommitFetcher! at #{Time.now}"
  45. g = Git.new
  46. g.get_git("purr")
  47. loop do
  48. puts "**************************\nwe're on a road to nowhere...\n**************************"
  49. sleep(30)
  50. g.get_git
  51. end
  52. end
  53.  
  54. def self.stop
  55. puts "Ok CommitFetcher, take a break kid. #{Time.now}"
  56. end
  57. end
  58.  
  59. CommitFetcher.daemonize
  60.  
  61. # each do |fork|
  62. # branch = fork.branches
  63. # end
  64. # branch.
Add Comment
Please, Sign In to add comment