Class: RcrNotify::Notifier
- Inherits:
-
Object
- Object
- RcrNotify::Notifier
- Defined in:
- lib/rcr-notify.rb
Instance Attribute Summary collapse
-
#last_projects ⇒ Object
readonly
Returns the value of attribute last_projects.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize ⇒ Notifier
constructor
A new instance of Notifier.
- #poll ⇒ Object
Constructor Details
#initialize ⇒ Notifier
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_projects ⇒ Object (readonly)
Returns the value of attribute last_projects.
9 10 11 |
# File 'lib/rcr-notify.rb', line 9 def last_projects @last_projects end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/rcr-notify.rb', line 9 def settings @settings end |
Instance Method Details
#poll ⇒ Object
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 |