Class: CheckZilla::Notifier::Twitter
- Inherits:
-
Object
- Object
- CheckZilla::Notifier::Twitter
- Defined in:
- lib/checkzilla/notifier/twitter.rb
Instance Attribute Summary collapse
-
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
-
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
-
#oauth_token_secret ⇒ Object
Returns the value of attribute oauth_token_secret.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Twitter
constructor
TODO: add a ‘template` accessor so you can pimp your tweet (with mentions by exemple).
- #perform!(checkers) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Twitter
TODO: add a ‘template` accessor so you can pimp your tweet (with mentions by exemple)
13 14 15 16 17 18 19 20 21 |
# File 'lib/checkzilla/notifier/twitter.rb', line 13 def initialize &block instance_eval(&block) if block_given? [:consumer_secret, :consumer_key, :oauth_token, :oauth_token_secret].each do |required| if self.send(required).nil? || self.send(required).strip.empty? raise "Notifier Twitter: you need to provide a #{required}" end end self end |
Instance Attribute Details
#consumer_key ⇒ Object
Returns the value of attribute consumer_key.
7 8 9 |
# File 'lib/checkzilla/notifier/twitter.rb', line 7 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object
Returns the value of attribute consumer_secret.
8 9 10 |
# File 'lib/checkzilla/notifier/twitter.rb', line 8 def consumer_secret @consumer_secret end |
#oauth_token ⇒ Object
Returns the value of attribute oauth_token.
9 10 11 |
# File 'lib/checkzilla/notifier/twitter.rb', line 9 def oauth_token @oauth_token end |
#oauth_token_secret ⇒ Object
Returns the value of attribute oauth_token_secret.
10 11 12 |
# File 'lib/checkzilla/notifier/twitter.rb', line 10 def oauth_token_secret @oauth_token_secret end |
Instance Method Details
#perform!(checkers) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/checkzilla/notifier/twitter.rb', line 23 def perform! checkers init_twitter! checkers.each do |checker| checker_name = checker.class.name.split("::").last title = "#{checker_name} Updates:" body = [] checker.results.each do |name, versions| local_version = versions[0] newer_version = versions[1] body << "#{name}(#{local_version}->#{newer_version})" end ::Twitter.update("(checkzilla) #{title} #{body.join(', ')}") end end |