signaly-notify 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/bin/signaly-notify.rb +1 -1
- data/bin/signaly-tray.rb +18 -0
- data/lib/signaly.rb +6 -23
- data/lib/signaly/cli.rb +130 -0
- data/lib/signaly/client.rb +9 -14
- data/lib/signaly/config.rb +44 -0
- data/lib/signaly/console_outputter.rb +34 -0
- data/lib/signaly/growl_outputter.rb +17 -0
- data/lib/signaly/libnotify_outputter.rb +17 -0
- data/lib/signaly/notify_app.rb +6 -150
- data/lib/signaly/notify_send_outputter.rb +14 -0
- data/lib/signaly/status_outputter.rb +0 -52
- metadata +31 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3bf603d022158b24c1caf75d0e0a9b6b5022071
|
4
|
+
data.tar.gz: e9041e6655295aed2d4030e1b6027d224373567c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b7a7c0a2cfa6843014e3029792bd1eb402973b8a7aa6687f95e6402ef1515b9e5f823cd2c7cec4b3c471a7dfab3c506609f8d37cd22108e212779511fff58c5
|
7
|
+
data.tar.gz: 59eb092b6f9510f2212f6061c3479027809365926c2aa9298dd0ee0894dedc919712a06a9f6f88cda9655274004a9066a9bac3d939501bd3a802f3b6072851a7
|
data/bin/signaly-notify.rb
CHANGED
data/bin/signaly-tray.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
|
3
|
+
require 'signaly'
|
4
|
+
require 'green_shoes'
|
5
|
+
|
6
|
+
::Shoes.app :title => "signaly.cz" do
|
7
|
+
systray do
|
8
|
+
syst_icon 'signaly.png'
|
9
|
+
|
10
|
+
syst_add_button "Login" do |state|
|
11
|
+
edit_conf()
|
12
|
+
end
|
13
|
+
|
14
|
+
syst_add_sepratator
|
15
|
+
|
16
|
+
syst_quit_button true
|
17
|
+
end
|
18
|
+
end
|
data/lib/signaly.rb
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
require '
|
2
|
-
require 'colorize'
|
3
|
-
require 'highline'
|
4
|
-
require 'optparse'
|
5
|
-
require 'yaml'
|
1
|
+
require 'autoloaded'
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
module Signaly
|
4
|
+
Autoloaded.module do |autoloading|
|
5
|
+
# hints for loading of non-conventional constants
|
6
|
+
autoloading.with :CLI
|
7
|
+
end
|
11
8
|
end
|
12
|
-
|
13
|
-
begin
|
14
|
-
require 'ruby-growl'
|
15
|
-
rescue LoadError
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
%w(
|
20
|
-
client
|
21
|
-
notifier
|
22
|
-
notify_app
|
23
|
-
status_outputter
|
24
|
-
status
|
25
|
-
).each {|l| require_relative "signaly/#{l}" }
|
data/lib/signaly/cli.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'highline'
|
2
|
+
require 'optparse'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Signaly
|
6
|
+
# collects configuration, starts NotifyApp
|
7
|
+
class CLI
|
8
|
+
DEFAULT_CONFIG_PATH = "#{ENV['HOME']}/.config/signaly-notify/config.yaml"
|
9
|
+
|
10
|
+
def call(argv)
|
11
|
+
options = process_options(argv)
|
12
|
+
config = Config.default
|
13
|
+
.merge(config_file(options.config_file))
|
14
|
+
.merge(options)
|
15
|
+
config = config.merge(find_available_notifier) if config.notify.nil?
|
16
|
+
request_config config
|
17
|
+
|
18
|
+
Signaly::NotifyApp.new.call config
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def process_options(argv)
|
24
|
+
config = Config.new
|
25
|
+
optparse = OptionParser.new do |opts|
|
26
|
+
opts.on "-u", "--user NAME", "user name used to log in" do |n|
|
27
|
+
config.login = n
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on "-p", "--password WORD", "user's password" do |p|
|
31
|
+
config.password = p
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.separator "If you don't provide any of the options above, "\
|
35
|
+
"the program will ask you to type the name and/or password on its start. "\
|
36
|
+
"(And especially "\
|
37
|
+
"for the password it's probably a bit safer to type it this way than "\
|
38
|
+
"to type it on the commandline.)\n\n"
|
39
|
+
|
40
|
+
opts.on "-s", "--sleep SECS", Integer, "how many seconds to sleep between two checks (default is #{config.sleep_seconds})" do |s|
|
41
|
+
config.sleep_seconds = s
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on "-r", "--remind SECS", Integer, "if I don't bother about the contents I recieved a notification about, remind me after X seconds (default is #{config.remind_after}; set to 0 to disable)" do |s|
|
45
|
+
config.remind_after = s
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on "--notify NOTIFIER", "choose visual notification engine (possible values: libnotify|growl|notifysend)" do |s|
|
49
|
+
config.notify = s.to_sym
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on "--console-only", "don't display any visual notifications" do
|
53
|
+
config.console_only = true
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on "-d", "--debug", "print debugging information to STDERR" do
|
57
|
+
config.debug_output = true
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on "--url URL", "check URL different from the default (for developmeng)" do |s|
|
61
|
+
config.url = s
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on "--skip-login", "don't login (for development)" do
|
65
|
+
config.skip_login = true
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on "-h", "--help", "print this help" do
|
69
|
+
puts opts
|
70
|
+
exit 0
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on "-c", "--config FILE", "configuration file" do |f|
|
74
|
+
config.config_file = f
|
75
|
+
end
|
76
|
+
end
|
77
|
+
optparse.parse! argv
|
78
|
+
|
79
|
+
|
80
|
+
unless argv.empty?
|
81
|
+
STDERR.puts "Warning: unused commandline arguments: "+ARGV.join(', ')
|
82
|
+
end
|
83
|
+
|
84
|
+
return config
|
85
|
+
end
|
86
|
+
|
87
|
+
# ask the user for missing essential information
|
88
|
+
def request_config(config)
|
89
|
+
cliio = HighLine.new
|
90
|
+
config.login ||= cliio.ask("login: ")
|
91
|
+
config.password ||= cliio.ask("password: ") {|q| q.echo = '*' }
|
92
|
+
end
|
93
|
+
|
94
|
+
# load configuration from config file
|
95
|
+
def config_file(path=nil)
|
96
|
+
path ||= DEFAULT_CONFIG_PATH
|
97
|
+
|
98
|
+
if File.exist? path then
|
99
|
+
cfg = YAML.load(File.open(path))
|
100
|
+
# symbolize keys
|
101
|
+
cfg = cfg.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
102
|
+
return cfg
|
103
|
+
end
|
104
|
+
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def find_available_notifier
|
109
|
+
config = Signaly::Config.new
|
110
|
+
|
111
|
+
begin
|
112
|
+
require 'libnotify'
|
113
|
+
|
114
|
+
config.notify = :libnotify
|
115
|
+
return config
|
116
|
+
rescue LoadError
|
117
|
+
end
|
118
|
+
|
119
|
+
begin
|
120
|
+
require 'ruby-growl'
|
121
|
+
|
122
|
+
config.notify = :growl
|
123
|
+
return config
|
124
|
+
rescue LoadError
|
125
|
+
end
|
126
|
+
|
127
|
+
return config
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/lib/signaly/client.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
|
1
3
|
module Signaly
|
2
4
|
# interaction with signaly.cz
|
5
|
+
# (through the regular web interface intended for humans)
|
3
6
|
class Client
|
4
7
|
|
5
8
|
def initialize(config)
|
6
|
-
@
|
7
|
-
@password = config.password
|
8
|
-
|
9
|
+
@config = config
|
9
10
|
@agent = Mechanize.new
|
10
11
|
|
11
12
|
@dbg_print_pages = config.debug_output || false # print raw html of all request results?
|
12
13
|
|
13
|
-
@checked_page = config.url || 'https://www.signaly.cz/'
|
14
|
+
@checked_page = @config.url || 'https://www.signaly.cz/'
|
14
15
|
end
|
15
16
|
|
16
17
|
USERMENU_XPATH = ".//div[contains(@class, 'section-usermenu')]"
|
@@ -25,20 +26,14 @@ module Signaly
|
|
25
26
|
unless login_form
|
26
27
|
raise "Login form not found on the index page!"
|
27
28
|
end
|
28
|
-
login_form['name'] = @
|
29
|
-
login_form['password'] = @password
|
29
|
+
login_form['name'] = @config.login
|
30
|
+
login_form['password'] = @config.password
|
30
31
|
|
31
32
|
page = @agent.submit(login_form)
|
32
33
|
debug_page_print "first logged in", page
|
33
34
|
|
34
|
-
errors = page.search(".//div[@class='alert alert-error']")
|
35
|
-
if errors.size > 0 then
|
36
|
-
msg = ''
|
37
|
-
errors.each {|e| msg += e.text.strip+"\n" }
|
38
|
-
raise "Login to signaly.cz failed: "+msg
|
39
|
-
end
|
40
|
-
|
41
35
|
usermenu = page.search(USERMENU_XPATH)
|
36
|
+
usermenu &&= usermenu.xpath("./div[@class='item username']")
|
42
37
|
if usermenu.empty? then
|
43
38
|
raise "User-menu not found. Login failed or signaly.cz UI changed again."
|
44
39
|
end
|
@@ -73,7 +68,7 @@ module Signaly
|
|
73
68
|
return if ! @dbg_print_pages
|
74
69
|
|
75
70
|
STDERR.puts
|
76
|
-
STDERR.puts ("# "+title).
|
71
|
+
STDERR.puts ColorizedString.new("# "+title).yellow
|
77
72
|
STDERR.puts
|
78
73
|
STDERR.puts page.search(".//div[@class='navbar navbar-fixed-top section-header']")
|
79
74
|
STDERR.puts
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Signaly
|
2
|
+
Config = Struct.new(
|
3
|
+
:sleep_seconds, # between checks
|
4
|
+
:remind_after, # the first notification
|
5
|
+
:notification_showtime,
|
6
|
+
:debug_output,
|
7
|
+
:login,
|
8
|
+
:password,
|
9
|
+
:url, # of the checked page
|
10
|
+
:skip_login,
|
11
|
+
:config_file,
|
12
|
+
:console_only,
|
13
|
+
:notify
|
14
|
+
)
|
15
|
+
|
16
|
+
class Config
|
17
|
+
def self.default
|
18
|
+
defaults = new
|
19
|
+
# how many seconds between two checks of the site
|
20
|
+
defaults.sleep_seconds = 60
|
21
|
+
# if there is some pending content and I don't look at it,
|
22
|
+
# remind me after X seconds
|
23
|
+
defaults.remind_after = 60*5
|
24
|
+
# for how long time the notification shows up
|
25
|
+
defaults.notification_showtime = 10
|
26
|
+
defaults.debug_output = false
|
27
|
+
defaults.password = nil
|
28
|
+
return defaults
|
29
|
+
end
|
30
|
+
|
31
|
+
# merges the config structs so that the last one
|
32
|
+
# in the argument list has the highest priority and value nil is considered
|
33
|
+
# empty
|
34
|
+
def merge(other)
|
35
|
+
merged = dup
|
36
|
+
|
37
|
+
merged.members.each do |key|
|
38
|
+
merged[key] = other[key] if other[key]
|
39
|
+
end
|
40
|
+
|
41
|
+
return merged
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'colorized_string'
|
2
|
+
|
3
|
+
module Signaly
|
4
|
+
class ConsoleOutputter < StatusOutputter
|
5
|
+
def output(new_status, old_status)
|
6
|
+
print_line new_status, old_status
|
7
|
+
set_console_title new_status
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def print_line(new_status, old_status)
|
13
|
+
t = Time.now
|
14
|
+
|
15
|
+
puts # start on a new line
|
16
|
+
print t.strftime("%H:%M:%S")
|
17
|
+
|
18
|
+
[:pm, :notifications, :invitations].each do |what|
|
19
|
+
num = new_status[what].to_s
|
20
|
+
if new_status.changed?(old_status, what) then
|
21
|
+
num = ColorizedString.new(num).red
|
22
|
+
end
|
23
|
+
print " #{what}: #{num}"
|
24
|
+
end
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
|
28
|
+
# doesn't work....
|
29
|
+
def set_console_title(status)
|
30
|
+
t = "signaly-notify: #{status[:pm]}/#{status[:notifications]}"
|
31
|
+
`echo -ne "\\033]0;#{t}\\007"`
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
begin
|
2
|
+
require 'ruby-growl'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
module Signaly
|
7
|
+
class GrowlOutputter < StatusOutputter
|
8
|
+
def output(new_status, old_status)
|
9
|
+
text = [:pm, :notifications, :invitations].collect do |what|
|
10
|
+
"#{what}: #{new_status[what]}"
|
11
|
+
end.join "\n"
|
12
|
+
|
13
|
+
notif = Growl.new 'localhost', 'ruby-growl', 'GNTP'
|
14
|
+
notif.notify('signaly.cz', 'signaly.cz', text)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# optional gems for visual notifications
|
2
|
+
begin
|
3
|
+
require 'libnotify'
|
4
|
+
rescue LoadError
|
5
|
+
end
|
6
|
+
|
7
|
+
module Signaly
|
8
|
+
class LibnotifyOutputter < StatusOutputter
|
9
|
+
def output(new_status, old_status)
|
10
|
+
text = [:pm, :notifications, :invitations].collect do |what|
|
11
|
+
"#{what}: #{new_status[what]}"
|
12
|
+
end.join "\n"
|
13
|
+
|
14
|
+
Libnotify.show(:body => text, :summary => "signaly.cz", :timeout => @config.notification_showtime)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/signaly/notify_app.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
1
|
module Signaly
|
2
2
|
class NotifyApp
|
3
|
-
|
4
|
-
SNConfig = Struct.new(:sleep_seconds, # between checks
|
5
|
-
:remind_after, # the first notification
|
6
|
-
:notification_showtime,
|
7
|
-
:debug_output,
|
8
|
-
:login,
|
9
|
-
:password,
|
10
|
-
:url, # of the checked page
|
11
|
-
:skip_login,
|
12
|
-
:config_file,
|
13
|
-
:console_only,
|
14
|
-
:notify)
|
15
|
-
|
16
|
-
DEFAULT_CONFIG_PATH = ".config/signaly-notify/config.yaml"
|
17
|
-
|
18
|
-
def call(argv)
|
19
|
-
options = process_options(argv)
|
20
|
-
config = merge_structs(
|
21
|
-
default_config,
|
22
|
-
config_file(options.config_file),
|
23
|
-
options
|
24
|
-
)
|
25
|
-
ask_config config
|
26
|
-
|
3
|
+
def call(config)
|
27
4
|
notifier = Notifier.new
|
28
5
|
prepare_outputters config, notifier
|
29
6
|
|
@@ -32,120 +9,19 @@ module Signaly
|
|
32
9
|
|
33
10
|
private
|
34
11
|
|
35
|
-
# load configuration from config file
|
36
|
-
def config_file(path=nil)
|
37
|
-
path ||= File.join ENV['HOME'], DEFAULT_CONFIG_PATH
|
38
|
-
|
39
|
-
if File.exist? path then
|
40
|
-
cfg = YAML.load(File.open(path))
|
41
|
-
# symbolize keys
|
42
|
-
cfg = cfg.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
43
|
-
return cfg
|
44
|
-
end
|
45
|
-
|
46
|
-
return nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def process_options(argv)
|
50
|
-
config = SNConfig.new
|
51
|
-
optparse = OptionParser.new do |opts|
|
52
|
-
opts.on "-u", "--user NAME", "user name used to log in" do |n|
|
53
|
-
config.login = n
|
54
|
-
end
|
55
|
-
|
56
|
-
opts.on "-p", "--password WORD", "user's password" do |p|
|
57
|
-
config.password = p
|
58
|
-
end
|
59
|
-
|
60
|
-
opts.separator "If you don't provide any of the options above, "\
|
61
|
-
"the program will ask you to type the name and/or password on its start. "\
|
62
|
-
"(And especially "\
|
63
|
-
"for the password it's probably a bit safer to type it this way than "\
|
64
|
-
"to type it on the commandline.)\n\n"
|
65
|
-
|
66
|
-
opts.on "-s", "--sleep SECS", Integer, "how many seconds to sleep between two checks (default is #{config.sleep_seconds})" do |s|
|
67
|
-
config.sleep_seconds = s
|
68
|
-
end
|
69
|
-
|
70
|
-
opts.on "-r", "--remind SECS", Integer, "if I don't bother about the contents I recieved a notification about, remind me after X seconds (default is #{config.remind_after}; set to 0 to disable)" do |s|
|
71
|
-
config.remind_after = s
|
72
|
-
end
|
73
|
-
|
74
|
-
opts.on "--notify NOTIFIER", "choose visual notification engine (possible values are 'libnotify' and 'growl')" do |s|
|
75
|
-
config.notify = s.to_sym
|
76
|
-
end
|
77
|
-
|
78
|
-
opts.on "--console-only", "don't display any visual notifications" do
|
79
|
-
config.console_only = true
|
80
|
-
end
|
81
|
-
|
82
|
-
opts.on "-d", "--debug", "print debugging information to STDERR" do
|
83
|
-
config.debug_output = true
|
84
|
-
end
|
85
|
-
|
86
|
-
opts.on "--url URL", "check URL different from the default (for developmeng)" do |s|
|
87
|
-
config.url = s
|
88
|
-
end
|
89
|
-
|
90
|
-
opts.on "--skip-login", "don't login (for development)" do
|
91
|
-
config.skip_login = true
|
92
|
-
end
|
93
|
-
|
94
|
-
opts.on "-h", "--help", "print this help" do
|
95
|
-
puts opts
|
96
|
-
exit 0
|
97
|
-
end
|
98
|
-
|
99
|
-
opts.on "-c", "--config FILE", "configuration file" do |f|
|
100
|
-
config.config_file = f
|
101
|
-
end
|
102
|
-
end
|
103
|
-
optparse.parse! argv
|
104
|
-
|
105
|
-
|
106
|
-
unless argv.empty?
|
107
|
-
STDERR.puts "Warning: unused commandline arguments: "+ARGV.join(', ')
|
108
|
-
end
|
109
|
-
|
110
|
-
return config
|
111
|
-
end
|
112
|
-
|
113
|
-
# ask the user for missing essential information
|
114
|
-
def ask_config(config)
|
115
|
-
cliio = HighLine.new
|
116
|
-
config.login ||= cliio.ask("login: ")
|
117
|
-
config.password ||= cliio.ask("password: ") {|q| q.echo = '*' }
|
118
|
-
end
|
119
|
-
|
120
|
-
# merges the config structs so that the last one
|
121
|
-
# in the argument list has the highest priority and value nil is considered
|
122
|
-
# empty
|
123
|
-
def merge_structs(*structs)
|
124
|
-
merged = structs.shift.dup
|
125
|
-
|
126
|
-
merged.each_pair do |key, value|
|
127
|
-
structs.each do |s|
|
128
|
-
next if s.nil?
|
129
|
-
if s[key] != nil then
|
130
|
-
merged[key] = s[key]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
return merged
|
136
|
-
end
|
137
|
-
|
138
12
|
def prepare_outputters(config, notifier)
|
139
|
-
notifier.add_outputter ConsoleOutputter.new(config), :checked
|
13
|
+
notifier.add_outputter Signaly::ConsoleOutputter.new(config), :checked
|
140
14
|
|
141
15
|
return if config.console_only
|
142
16
|
return unless config.notify
|
143
17
|
|
144
18
|
case config.notify.to_sym
|
145
19
|
when :libnotify
|
146
|
-
notifier.add_outputter
|
20
|
+
notifier.add_outputter Signaly::LibnotifyOutputter.new(config), :changed, :remind
|
147
21
|
when :growl
|
148
|
-
notifier.add_outputter GrowlOutputter.new(config), :changed, :remind
|
22
|
+
notifier.add_outputter Signaly::GrowlOutputter.new(config), :changed, :remind
|
23
|
+
when :notifysend
|
24
|
+
notifier.add_outputter Signaly::NotifySendOutputter.new(config), :changed, :remind
|
149
25
|
end
|
150
26
|
end
|
151
27
|
|
@@ -185,25 +61,5 @@ module Signaly
|
|
185
61
|
sleep config.sleep_seconds
|
186
62
|
end
|
187
63
|
end
|
188
|
-
|
189
|
-
def default_config
|
190
|
-
defaults = SNConfig.new
|
191
|
-
# how many seconds between two checks of the site
|
192
|
-
defaults.sleep_seconds = 60
|
193
|
-
# if there is some pending content and I don't look at it,
|
194
|
-
# remind me after X seconds
|
195
|
-
defaults.remind_after = 60*5
|
196
|
-
# for how long time the notification shows up
|
197
|
-
defaults.notification_showtime = 10
|
198
|
-
defaults.debug_output = false
|
199
|
-
defaults.password = nil
|
200
|
-
# use first available visual notification engine
|
201
|
-
if defined? Libnotify
|
202
|
-
defaults.notify = :libnotify
|
203
|
-
elsif defined? Growl
|
204
|
-
defaults.notify = :growl
|
205
|
-
end
|
206
|
-
return defaults
|
207
|
-
end
|
208
64
|
end
|
209
65
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Signaly
|
2
|
+
# sends desktop notification using the command-line utility
|
3
|
+
# notify-send (useful for those who have installed libnotify,
|
4
|
+
# but not the Ruby bindings)
|
5
|
+
class NotifySendOutputter < StatusOutputter
|
6
|
+
def output(new_status, old_status)
|
7
|
+
text = [:pm, :notifications, :invitations].collect do |what|
|
8
|
+
"#{what}: #{new_status[what]}"
|
9
|
+
end.join "\n"
|
10
|
+
|
11
|
+
`notify-send "#{text}"`
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -7,56 +7,4 @@ module Signaly
|
|
7
7
|
def output(new_status, old_status)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
|
11
|
-
class ConsoleOutputter < StatusOutputter
|
12
|
-
def output(new_status, old_status)
|
13
|
-
print_line new_status, old_status
|
14
|
-
set_console_title new_status
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def print_line(new_status, old_status)
|
20
|
-
t = Time.now
|
21
|
-
|
22
|
-
puts # start on a new line
|
23
|
-
print t.strftime("%H:%M:%S")
|
24
|
-
|
25
|
-
[:pm, :notifications, :invitations].each do |what|
|
26
|
-
num = new_status[what].to_s
|
27
|
-
if new_status.changed?(old_status, what) then
|
28
|
-
num = num.colorize(:red)
|
29
|
-
end
|
30
|
-
print " #{what}: #{num}"
|
31
|
-
end
|
32
|
-
puts
|
33
|
-
end
|
34
|
-
|
35
|
-
# doesn't work....
|
36
|
-
def set_console_title(status)
|
37
|
-
t = "signaly-notify: #{status[:pm]}/#{status[:notifications]}"
|
38
|
-
`echo -ne "\\033]0;#{t}\\007"`
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class LibNotifyOutputter < StatusOutputter
|
43
|
-
def output(new_status, old_status)
|
44
|
-
text = [:pm, :notifications, :invitations].collect do |what|
|
45
|
-
"#{what}: #{new_status[what]}"
|
46
|
-
end.join "\n"
|
47
|
-
|
48
|
-
Libnotify.show(:body => text, :summary => "signaly.cz", :timeout => @config.notification_showtime)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class GrowlOutputter < StatusOutputter
|
53
|
-
def output(new_status, old_status)
|
54
|
-
text = [:pm, :notifications, :invitations].collect do |what|
|
55
|
-
"#{what}: #{new_status[what]}"
|
56
|
-
end.join "\n"
|
57
|
-
|
58
|
-
notif = Growl.new 'localhost', 'ruby-growl', 'GNTP'
|
59
|
-
notif.notify('signaly.cz', 'signaly.cz', text)
|
60
|
-
end
|
61
|
-
end
|
62
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signaly-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Pavlík
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: highline
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,10 +52,25 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.7'
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: autoloaded
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
69
|
+
description: |-
|
70
|
+
signaly-notify.rb signs in with your credentials
|
71
|
+
to the social network https://signaly.cz
|
72
|
+
and triggers a desktop notification whenever something new happens.
|
73
|
+
It detects pending private messages, notifications and invitations.
|
59
74
|
email: jkb.pavlik@gmail.com
|
60
75
|
executables:
|
61
76
|
- signaly-notify.rb
|
@@ -63,10 +78,17 @@ extensions: []
|
|
63
78
|
extra_rdoc_files: []
|
64
79
|
files:
|
65
80
|
- bin/signaly-notify.rb
|
81
|
+
- bin/signaly-tray.rb
|
66
82
|
- lib/signaly.rb
|
83
|
+
- lib/signaly/cli.rb
|
67
84
|
- lib/signaly/client.rb
|
85
|
+
- lib/signaly/config.rb
|
86
|
+
- lib/signaly/console_outputter.rb
|
87
|
+
- lib/signaly/growl_outputter.rb
|
88
|
+
- lib/signaly/libnotify_outputter.rb
|
68
89
|
- lib/signaly/notifier.rb
|
69
90
|
- lib/signaly/notify_app.rb
|
91
|
+
- lib/signaly/notify_send_outputter.rb
|
70
92
|
- lib/signaly/status.rb
|
71
93
|
- lib/signaly/status_outputter.rb
|
72
94
|
homepage: http://github.com/igneus/signaly-notify
|
@@ -90,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
112
|
version: '0'
|
91
113
|
requirements: []
|
92
114
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.5.1
|
94
116
|
signing_key:
|
95
117
|
specification_version: 4
|
96
118
|
summary: notification script for signaly.cz (Czech christian social network)
|
97
119
|
test_files: []
|
98
|
-
has_rdoc:
|