airblade-fyi 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -51,7 +51,7 @@ A notifier must:
51
51
  * subclass Fyi::Notifier
52
52
  * accept an options hash at initialisation (populated from
53
53
  configuration).
54
- * respond to `notify(command, result, output, error = '')`
54
+ * respond to `notify(command, result, duration, output, error = '')`
55
55
 
56
56
 
57
57
  ## Installation
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
data/fyi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fyi}
8
- s.version = "1.0.0"
8
+ s.version = "1.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Stewart"]
12
- s.date = %q{2009-08-10}
12
+ s.date = %q{2009-08-12}
13
13
  s.default_executable = %q{fyi}
14
14
  s.email = %q{boss@airbladesoftware.com}
15
15
  s.executables = ["fyi"]
data/lib/fyi.rb CHANGED
@@ -17,6 +17,7 @@ class Fyi
17
17
  end
18
18
 
19
19
  def run
20
+ start_stopwatch
20
21
  # Borrowed from CI Joe.
21
22
  out, err, status = '', '', nil
22
23
  status = Open4.popen4(@command) do |@pid, stdin, stdout, stderr|
@@ -30,16 +31,18 @@ class Fyi
30
31
  private
31
32
 
32
33
  def run_succeeded output
33
- notify :success, output
34
+ stop_stopwatch
35
+ notify :success, duration, output
34
36
  end
35
37
 
36
38
  def run_failed output, error
37
- notify :failure, output, error
39
+ stop_stopwatch
40
+ notify :failure, duration, output, error
38
41
  end
39
42
 
40
- def notify result, output, error = ''
43
+ def notify result, duration, output, error = ''
41
44
  notifiers.each do |notifier|
42
- notifier.notify @command, result, output, error
45
+ notifier.notify @command, result, duration, output, error
43
46
  end
44
47
  end
45
48
 
@@ -52,4 +55,16 @@ class Fyi
52
55
  end
53
56
  end
54
57
 
58
+ def duration
59
+ @stop - @start
60
+ end
61
+
62
+ def start_stopwatch
63
+ @start = Time.now
64
+ end
65
+
66
+ def stop_stopwatch
67
+ @stop = Time.now
68
+ end
69
+
55
70
  end
@@ -33,8 +33,8 @@ class Fyi
33
33
  @on_failure = options.has_key?('on_failure') ? options['on_failure'] : true
34
34
  end
35
35
 
36
- def notify command, result, output, error = ''
37
- send_email(command, result, output, error) if should_notify?(result)
36
+ def notify command, result, duration, output, error = ''
37
+ send_email(command, result, duration, output, error) if should_notify?(result)
38
38
  end
39
39
 
40
40
  private
@@ -43,11 +43,11 @@ class Fyi
43
43
  (result == :success && @on_success) || (result == :failure && @on_failure)
44
44
  end
45
45
 
46
- def send_email command, result, output, error
46
+ def send_email command, result, duration, output, error
47
47
  Pony.mail :to => @to,
48
48
  :from => @from,
49
49
  :subject => subject(command, result),
50
- :body => body(command, output, error),
50
+ :body => body(command, duration, output, error),
51
51
  :via => :smtp,
52
52
  :smtp => @smtp
53
53
  end
@@ -56,10 +56,12 @@ class Fyi
56
56
  "[#{result.to_s.upcase}] #{truncate command}"
57
57
  end
58
58
 
59
- def body command, output, error
59
+ def body command, duration, output, error
60
60
  <<END
61
61
  command: #{command}
62
62
 
63
+ duration: #{duration}s
64
+
63
65
  stdout: #{output}
64
66
 
65
67
  stderr: #{error}
@@ -17,8 +17,8 @@ class Fyi
17
17
  @logger = Logger.new log_file
18
18
  end
19
19
 
20
- def notify command, result, output, error = ''
21
- logger.log severity(result), message(command, result, output, error)
20
+ def notify command, result, duration, output, error = ''
21
+ logger.log severity(result), message(command, result, duration, output, error)
22
22
  end
23
23
 
24
24
  private
@@ -27,9 +27,10 @@ class Fyi
27
27
  result == :success ? Logger::INFO : Logger::WARN
28
28
  end
29
29
 
30
- def message command, result, output, error
30
+ def message command, result, duration, output, error
31
31
  <<END
32
32
  command: #{command}
33
+ duration: #{duration}s
33
34
  status: #{result.to_s.upcase}
34
35
  stdout: #{output}
35
36
  stderr: #{error}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airblade-fyi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-10 00:00:00 -07:00
12
+ date: 2009-08-12 00:00:00 -07:00
13
13
  default_executable: fyi
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency