blertr 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/blertr CHANGED
@@ -30,6 +30,10 @@ Commands:
30
30
  information it is using to send notifications
31
31
  Example: blertr info email
32
32
 
33
+ status For each notifier, Blertr lists if it currently can
34
+ send notifications and then lists any error messages
35
+ if it cannot. Useful for debuggin problems with notifiers
36
+
33
37
  exclude Pass in a shell command to prevent Blertr from
34
38
  sending notifications when that command is
35
39
  executed
@@ -71,9 +75,33 @@ def take_action action, parameters
71
75
  puts "ERROR: it doesn't look like Blertr is installed"
72
76
  end
73
77
  when "info"
74
- puts "getting info"
78
+ raw_name = parameters.shift
79
+ if Blertr::Control::is_notifier? raw_name
80
+ name = Blertr::Control::notifier_with_name(raw_name).name
81
+ info_hash = Blertr::Options.options_for name
82
+ puts "Configuration for: #{name}"
83
+ if info_hash.empty?
84
+ puts "No configuration file for #{name} or config file is empty"
85
+ else
86
+ info_hash.each do |key,value|
87
+ puts "#{key}: #{value}"
88
+ end
89
+ end
90
+ else
91
+ if !raw_name or (raw_name and raw_name.empty?)
92
+ puts "info requires the name of a notifier"
93
+ else
94
+ puts "Sorry, #{raw_name} is not a notifier"
95
+ end
96
+ end
75
97
  when "status"
76
- puts "getting status"
98
+ Blertr::Control::notifiers.each do |notifier|
99
+ notify_message = notifier.can_alert? ? "can alert" : "cannot alert"
100
+ puts "#{notifier.name}: #{notify_message}"
101
+ if !notifier.error_messages.empty?
102
+ notifier.error_messages.each {|err| puts " #{err}"}
103
+ end
104
+ end
77
105
  when "exclude"
78
106
  name = parameters.join(" ")
79
107
  puts "Excluding #{name} from Blertr alerts"
@@ -8,12 +8,13 @@ module Blertr
8
8
  end
9
9
 
10
10
  def alert message
11
- #TODO: look to supporting other growl frameworks on other OSs
12
11
  system("growlnotify -n \"Terminal\" -m \"took #{message.time_string}\" \"#{message.command}\"")
13
12
  end
14
13
 
15
14
  def can_alert?
16
- system("which growlnotify > /dev/null 2>&1")
15
+ rtn = system("which growlnotify > /dev/null 2>&1")
16
+ error_messages << "growlnotify not availible from $PATH" unless rtn
17
+ rtn
17
18
  end
18
19
  end
19
20
  end
@@ -29,8 +29,11 @@ module Blertr
29
29
  def can_alert?
30
30
  rtn = true
31
31
  rtn &= options[:username]
32
+ error_messages << "No :username option in config file" if !options[:username]
32
33
  rtn &= options[:password]
34
+ error_messages << "No :password option in config file" if !options[:password]
33
35
  rtn &= options[:to]
36
+ error_messages << "No :to option in config file" if !options[:to]
34
37
  rtn
35
38
  end
36
39
  end
@@ -3,9 +3,10 @@ require 'blertr/options'
3
3
 
4
4
  module Blertr
5
5
  class Notifier
6
- attr_reader :names
6
+ attr_reader :names, :error_messages
7
7
  def initialize
8
8
  @names = []
9
+ @error_messages = []
9
10
  end
10
11
 
11
12
  def name
@@ -44,6 +45,7 @@ module Blertr
44
45
  end
45
46
 
46
47
  def can_alert?
48
+ error_messages << "Unknown Error"
47
49
  false
48
50
  end
49
51
  end
@@ -8,12 +8,13 @@ module Blertr
8
8
  end
9
9
 
10
10
  def alert message
11
- #TODO: look to supporting other growl frameworks on other OSs
12
11
  system("notify-send \"#{message.command}\" \"took #{message.time_string}\" 2> /dev/null")
13
12
  end
14
13
 
15
14
  def can_alert?
16
- system("which notify-send > /dev/null 2>&1")
15
+ rtn = system("which notify-send > /dev/null 2>&1")
16
+ error_messages << "notify-send not availible from $PATH" unless rtn
17
+ rtn
17
18
  end
18
19
  end
19
20
  end
@@ -32,9 +32,13 @@ module Blertr
32
32
  require 'twitter'
33
33
  rescue LoadError => e
34
34
  rtn = false
35
+ error_messages << "twitter gem cannot be found"
35
36
  end
36
37
  if rtn
37
- [:consumer_key, :consumer_secret, :oauth_token, :oauth_token_secret].each { |key| rtn &= options[key]}
38
+ [:consumer_key, :consumer_secret, :oauth_token, :oauth_token_secret].each do |key|
39
+ rtn &= options[key]
40
+ error_messages << "No #{key} in config file"
41
+ end
38
42
  end
39
43
  rtn
40
44
  end
@@ -1,3 +1,3 @@
1
1
  module Blertr
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.1.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blertr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-07-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2788290 !ruby/object:Gem::Requirement
16
+ requirement: &2788410 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2788290
24
+ version_requirements: *2788410
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &2788010 !ruby/object:Gem::Requirement
27
+ requirement: &2788140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.5'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2788010
35
+ version_requirements: *2788140
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2787760 !ruby/object:Gem::Requirement
38
+ requirement: &2787890 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2787760
46
+ version_requirements: *2787890
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: simplecov
49
- requirement: &2787520 !ruby/object:Gem::Requirement
49
+ requirement: &2787650 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.4'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2787520
57
+ version_requirements: *2787650
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: twitter
60
- requirement: &2787250 !ruby/object:Gem::Requirement
60
+ requirement: &2787380 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.6.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2787250
68
+ version_requirements: *2787380
69
69
  description: Automatic alerts for when bash scripts and commands complete
70
70
  email: vvv@gmail.com
71
71
  executables: