checkzilla 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/checkzilla/notifier/twitter.rb +50 -0
- metadata +19 -2
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'twitter'
|
2
|
+
|
3
|
+
module CheckZilla
|
4
|
+
module Notifier
|
5
|
+
class Twitter
|
6
|
+
|
7
|
+
attr_accessor :consumer_key
|
8
|
+
attr_accessor :consumer_secret
|
9
|
+
attr_accessor :oauth_token
|
10
|
+
attr_accessor :oauth_token_secret
|
11
|
+
|
12
|
+
# TODO: add a `template` accessor so you can pimp your tweet (with mentions by exemple)
|
13
|
+
def initialize &block
|
14
|
+
instance_eval(&block) if block_given?
|
15
|
+
[:consumer_secret, :consumer_key, :oauth_token, :oauth_token_secret].each do |required|
|
16
|
+
if self.send(required).nil? || self.send(required).strip.empty?
|
17
|
+
raise "Notifier Twitter: you need to provide a #{required}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def perform! checkers
|
24
|
+
init_twitter!
|
25
|
+
checkers.each do |checker|
|
26
|
+
checker_name = checker.class.name.split("::").last
|
27
|
+
title = "#{checker_name} Updates:"
|
28
|
+
|
29
|
+
body = []
|
30
|
+
checker.results.each do |name, versions|
|
31
|
+
local_version = versions[0]
|
32
|
+
newer_version = versions[1]
|
33
|
+
body << "#{name}(#{local_version}->#{newer_version})"
|
34
|
+
end
|
35
|
+
::Twitter.update("(checkzilla) #{title} #{body.join(', ')}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def init_twitter!
|
41
|
+
::Twitter.configure do |config|
|
42
|
+
config.consumer_key = consumer_key
|
43
|
+
config.consumer_secret = consumer_secret
|
44
|
+
config.oauth_token = oauth_token
|
45
|
+
config.oauth_token_secret = oauth_token_secret
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkzilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: twitter
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: hipchat
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,6 +101,7 @@ extensions: []
|
|
85
101
|
extra_rdoc_files: []
|
86
102
|
files:
|
87
103
|
- ./lib/checkzilla.rb
|
104
|
+
- ./lib/checkzilla/notifier/twitter.rb
|
88
105
|
- ./lib/checkzilla/notifier/email.rb
|
89
106
|
- ./lib/checkzilla/notifier/notify_send.rb
|
90
107
|
- ./lib/checkzilla/notifier/console.rb
|