Class: Checker
- Inherits:
-
Object
- Object
- Checker
- Defined in:
- lib/hubdate/checker.rb
Class Method Summary collapse
- .check_followers(connection) ⇒ Object
- .check_notifications(connection) ⇒ Object
- .check_watchers(type, connection) ⇒ Object
Class Method Details
.check_followers(connection) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/hubdate/checker.rb', line 53 def self.check_followers(connection) followers_file = File.join(Dir.home, ".hubdate", "followers.yaml") followers = Github::User.fetch(connection).followers.map {|follower| follower.login} begin file_followers = YAML.load_file(followers_file) rescue Storage.write_file(followers, followers_file) end if file_followers != followers begin added = (followers - file_followers) rescue added = [] end added.each do |login| TerminalNotifier.notify("", :title => 'New Follower!', :subtitle => "#{login} is now following you!") end Storage.write_file(followers, followers_file) end end |
.check_notifications(connection) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/hubdate/checker.rb', line 2 def self.check_notifications(connection) notifications = Github::User.fetch(connection).notifications.reverse notifications.each do |notif| TerminalNotifier.notify("#{notif.}", :title => "#{notif.reason[0] = notif.reason[0].capitalize; notif.reason}: #{notif.type}") end end |
.check_watchers(type, connection) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hubdate/checker.rb', line 10 def self.check_watchers(type, connection) watchers_file = File.join(Dir.home, ".hubdate", "stargazers.yaml") if type == :stargazer watchers_file = File.join(Dir.home, ".hubdate", "watchers.yaml") if type == :watcher watchers = Github::User.fetch(connection).watchers(type) begin file_watchers = YAML.load_file(watchers_file) rescue Storage.write_file(watchers, watchers_file) end if file_watchers != watchers new_gazers = {} watchers.each do |repo, gazers| begin added = (gazers - file_watchers[repo]) rescue added = [] end new_gazers[repo] = added end new_gazers.each do |repo, logins| if logins != [] case type when :stargazer action = "Starred" = "starred" when :watcher action = "Now Being Watched" = "now watching" end TerminalNotifier.notify("", :title => "Repository #{action}!", :subtitle => "#{logins.join(", ")} #{} your repository \"#{repo}\"!") end end Storage.write_file(watchers, watchers_file) end end |