Class: RcrNotify::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/rcr-notify.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNotifier

Returns a new instance of Notifier.



11
12
13
14
# File 'lib/rcr-notify.rb', line 11

def initialize
  @settings = {:interval => 30}
  @growl = Growl.new "localhost", "run>code>run notifier", %w(success failure)
end

Instance Attribute Details

#last_projectsObject (readonly)

Returns the value of attribute last_projects.



9
10
11
# File 'lib/rcr-notify.rb', line 9

def last_projects
  @last_projects
end

#settingsObject (readonly)

Returns the value of attribute settings.



9
10
11
# File 'lib/rcr-notify.rb', line 9

def settings
  @settings
end

Instance Method Details

#pollObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rcr-notify.rb', line 16

def poll
  data = JSON::parse open(url).read
  print '.'

  
  projects = data["user"]["projects"].inject({}) do |hash, project|
    hash.merge project.delete("name") => project
  end

  if last_projects
    projects.each do |name, this_time|
      notify_for name, last_projects[name], this_time if notify_for? name
    end
  end
  
  @last_projects = projects
rescue
  print 'o'
end