sum-notify 1.0.0
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/bin/sum-notify +51 -0
- data/resource/sum.png +0 -0
- metadata +99 -0
data/bin/sum-notify
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
require 'daemons'
|
6
|
+
require 'uri'
|
7
|
+
require 'net/https'
|
8
|
+
|
9
|
+
def get(since = nil)
|
10
|
+
uri = "https://secure.atechmedia.com/api/v1/events/feed"
|
11
|
+
uri += "?since_id=#{since}" if since
|
12
|
+
uri = URI.parse(uri)
|
13
|
+
req = Net::HTTP::Get.new(uri.path + '?' + uri.query.to_s)
|
14
|
+
res = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
res.use_ssl = true
|
16
|
+
res.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
17
|
+
|
18
|
+
Timeout.timeout(5) do
|
19
|
+
case res = res.request(req)
|
20
|
+
when Net::HTTPSuccess
|
21
|
+
JSON.parse(res.body)
|
22
|
+
else
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
rescue Timeout::Error
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
if `which growlnotify` && $?.exitstatus != 0
|
32
|
+
$stderr.puts "growlnotify is not installed on this machine. Please install and try again."
|
33
|
+
Process.exit(1)
|
34
|
+
end
|
35
|
+
|
36
|
+
icon_path = File.expand_path('resource/sum.png', __FILE__ + '/../../')
|
37
|
+
|
38
|
+
Daemons.run_proc('sum-notify') do
|
39
|
+
last_id = nil
|
40
|
+
loop do
|
41
|
+
if events = get(since = last_id)
|
42
|
+
for event in events.reverse.map{|e| e['feed_event']}
|
43
|
+
message = event['message'].gsub(/[\[\]\{\}]/, '')
|
44
|
+
title = event['event_type'].capitalize.gsub('_', ' ').gsub(/[\A\s]([a-z])/) {" #{$1.upcase}"}
|
45
|
+
system("growlnotify -n 'Sum Notify' --image '#{icon_path}' -m '#{message}' '#{title}'")
|
46
|
+
last_id = event['id'].to_i
|
47
|
+
end
|
48
|
+
end
|
49
|
+
sleep 10
|
50
|
+
end
|
51
|
+
end
|
data/resource/sum.png
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sum-notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Adam Cooke
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-09-01 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: json
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 11
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
- 6
|
34
|
+
version: 1.4.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: daemons
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
- 10
|
50
|
+
version: 1.0.10
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
description:
|
54
|
+
email: adam@atechmedia.com
|
55
|
+
executables:
|
56
|
+
- sum-notify
|
57
|
+
extensions: []
|
58
|
+
|
59
|
+
extra_rdoc_files: []
|
60
|
+
|
61
|
+
files:
|
62
|
+
- bin/sum-notify
|
63
|
+
- resource/sum.png
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://www.atechmedia.com
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.3.7
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Notification system for being notified when things happen on the aTech Management Interface. Authtorised users only (don't waste your time...)
|
98
|
+
test_files: []
|
99
|
+
|