titech-pubnet-auth 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/titech-pubnet-auth +10 -3
- data/lib/titech_pubnet_auth/version.rb +1 -1
- metadata +1 -1
data/bin/titech-pubnet-auth
CHANGED
@@ -8,8 +8,6 @@ require 'titech_pubnet_auth'
|
|
8
8
|
require 'optparse'
|
9
9
|
require 'terminal-notifier' if OS_X
|
10
10
|
|
11
|
-
notifier = ->{TerminalNotifier.notify(nil,:title => 'Titech Punet Auth',:subtitle => 'Connected!') if OS_X}
|
12
|
-
|
13
11
|
opt = OptionParser.new
|
14
12
|
|
15
13
|
interval = TitechPubnetAuth::INTERVAL
|
@@ -57,14 +55,23 @@ if daemon
|
|
57
55
|
Process.daemon
|
58
56
|
end
|
59
57
|
|
58
|
+
|
59
|
+
notifier = ->{TerminalNotifier.notify(nil,:title => 'Titech Punet Auth', :subtitle => 'Connected!') if OS_X}
|
60
|
+
error_notifier = ->(e){TerminalNotifier.notify(e.inspect,:title => 'Titech Punet Auth',:subtitle => 'Caught an unexpected error!') if OS_X}
|
61
|
+
|
60
62
|
pubnet_auth = TitechPubnetAuth.new
|
61
63
|
loop do
|
62
64
|
begin
|
65
|
+
no_such_method
|
63
66
|
mputs 'network_available?', pubnet_auth.network_available?
|
64
67
|
mputs 'is_connected?', pubnet_auth.is_connected? if pubnet_auth.network_available?
|
65
68
|
mputs 'auth', pubnet_auth.auth and notifier.call if pubnet_auth.network_available? and not pubnet_auth.is_connected?
|
66
69
|
rescue => e
|
67
|
-
|
70
|
+
mputs 'unexpected error', e.class and error_notifier.call(e)
|
71
|
+
puts " == Message =="
|
72
|
+
puts " #{e.message}"
|
73
|
+
puts " == Stack Trace =="
|
74
|
+
puts e.backtrace.map{|l| " #{l}"}.join("\n")
|
68
75
|
ensure
|
69
76
|
print "\n"
|
70
77
|
$stdout.flush
|