blertr 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/blertr CHANGED
@@ -47,6 +47,11 @@ Commands:
47
47
  Example: blertr time email 5 minutes
48
48
  This would make blertr send an email only if
49
49
  the command executing took longer than 5 mins
50
+
51
+ set Pass in the notifier name, a configuration key, and
52
+ a value. Blertr will add this key / value to the
53
+ notifiers config file.
54
+ Example: blertr set mail to user@gmail.com
50
55
  EOS
51
56
  puts help_string
52
57
  end
@@ -132,6 +137,22 @@ def take_action action, parameters
132
137
  name = parameters.join(" ")
133
138
  puts "Excluding #{name} from Blertr alerts"
134
139
  Blertr::Blacklist.new.add(name)
140
+ when "set"
141
+ notifier_name = parameters.shift
142
+ if Blertr::Control::is_notifier? notifier_name
143
+ key = parameters.shift
144
+ value = parameters.shift
145
+ if key and value
146
+ puts "Setting #{notifier_name}'s #{key} to #{value}"
147
+ Blertr::Control::notifier_with_name(notifier_name).set_option(key,value)
148
+ else
149
+ puts "set command requires a key and a value to set it to"
150
+ puts "example blertr set email to user@gmail.com"
151
+ end
152
+ else
153
+ puts "Sorry, #{action} isn't a notifier."
154
+ puts "Use blertr status for a list of all notifiers"
155
+ end
135
156
  when "time"
136
157
  notifier_found = false
137
158
  notifiers = parameters.shift.split(",")
@@ -10,18 +10,24 @@ module Blertr
10
10
 
11
11
  def alert message
12
12
  username = options[:username]
13
+ blert_user = "#{username}@gmail.com"
13
14
  password = options[:password]
14
15
  receiver = options[:to]
15
- msg = create_message(message)
16
+ msg = create_message(message, receiver, blert_user)
16
17
  smtp = Net::SMTP.new 'smtp.gmail.com', 587
17
18
  smtp.enable_starttls
18
- smtp.start('gmail.com', username, password, :login) do
19
- smtp.send_message(msg, "#{username}@gmail.com", receiver)
19
+ smtp.start('smtp.gmail.com', blert_user, password, :plain) do
20
+ smtp.send_message(msg, blert_user, receiver)
20
21
  end
21
22
  end
22
23
 
23
- def create_message message
24
- msg = "Subject: #{message.command_short_name} is done!\n"
24
+ def create_message message, to, from
25
+ date = Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
26
+ msg = "Date: #{date}\n"
27
+ msg += "From: Blertr App <#{from}>\n"
28
+ msg += "To: #{to} <#{to}>\n"
29
+ msg += "Subject: #{message.command_short_name} is done!\n"
30
+ msg += "\n"
25
31
  msg += "#{message.command_short_name} has completed.\nCommand: #{message.command}\nTime: #{message.time_string}\n"
26
32
  msg
27
33
  end
@@ -19,8 +19,12 @@ module Blertr
19
19
  end
20
20
 
21
21
  def set_time new_time
22
+ set_option :time, new_time
23
+ end
24
+
25
+ def set_option key, value
22
26
  opts = options
23
- opts[:time] = new_time
27
+ opts[key.to_sym] = value
24
28
  Options::save_options_for name, opts
25
29
  end
26
30
 
@@ -1,3 +1,3 @@
1
1
  module Blertr
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.2.3".freeze
3
3
  end
data/scripts/blertr CHANGED
@@ -18,8 +18,8 @@
18
18
 
19
19
  export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME
20
20
 
21
- if [[ -z "${blertr_path:-}" ]]
22
- then
21
+ #if [[ -z "${blertr_path:-}" ]]
22
+ #then
23
23
 
24
24
  if [[ -z "${blertr_prefix:-}" ]]
25
25
  then
@@ -50,7 +50,7 @@ then
50
50
  # the scripts/cli file
51
51
  export blertr_path="${blertr_path%%+(\/)}"
52
52
  export blertr_bin_path="${blertr_bin_path%%+(\/)}"
53
- fi
53
+ #fi
54
54
 
55
55
  # load the bash files that add hooks for executing commands
56
56
  if [[ -n "${blertr_path}" && -d "$blertr_path" ]]
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.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-26 00:00:00.000000000Z
12
+ date: 2011-07-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &2735430 !ruby/object:Gem::Requirement
16
+ requirement: &868650 !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: *2735430
24
+ version_requirements: *868650
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &2735110 !ruby/object:Gem::Requirement
27
+ requirement: &867670 !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: *2735110
35
+ version_requirements: *867670
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &2734800 !ruby/object:Gem::Requirement
38
+ requirement: &867160 !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: *2734800
46
+ version_requirements: *867160
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: simplecov
49
- requirement: &2734520 !ruby/object:Gem::Requirement
49
+ requirement: &866270 !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: *2734520
57
+ version_requirements: *866270
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: twitter
60
- requirement: &2734230 !ruby/object:Gem::Requirement
60
+ requirement: &865450 !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: *2734230
68
+ version_requirements: *865450
69
69
  description: Automatic alerts for when bash scripts and commands complete
70
70
  email: vvv@gmail.com
71
71
  executables: