minitest-libnotify 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/example.rb CHANGED
@@ -9,3 +9,5 @@ reporter.config[:fail][:icon_path] = "face-crying*"
9
9
 
10
10
  reporter.puts "0 failures, 1 errors"
11
11
  reporter.puts "0 failures, 0 errors"
12
+
13
+ reporter.puts "other"
@@ -30,6 +30,7 @@ module MiniTest
30
30
  # Default configuration
31
31
  self.default_config = {
32
32
  :global => {
33
+ :regexp => /(\d+) failures, (\d+) errors/,
33
34
  :timeout => 2.5,
34
35
  :append => false,
35
36
  :description => proc { [ defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby", RUBY_VERSION, RUBY_PLATFORM ].join(" ") },
@@ -48,22 +49,14 @@ module MiniTest
48
49
 
49
50
  attr_accessor :config
50
51
 
51
- def initialize io, config = self.class.default_config
52
+ def initialize(io, config = self.class.default_config)
52
53
  @io = io
53
54
  @libnotify = nil
54
55
  @config = config.dup
55
56
  end
56
57
 
57
58
  def puts(*o)
58
- if libnotify && ((body = o.first) =~ /(\d+) failures, (\d+) errors/)
59
- default_description = config_for(:description)
60
- state = $1.to_i > 0 || $2.to_i > 0 ? :fail : :pass
61
- libnotify.body = config_for(:body, state, body)
62
- libnotify.summary = config_for(:description, state, default_description)
63
- libnotify.urgency = config_for(:urgency, state)
64
- libnotify.icon_path = config_for(:icon_path, state)
65
- libnotify.show!
66
- end
59
+ notify(o.first) if libnotify
67
60
  @io.puts(*o)
68
61
  end
69
62
 
@@ -71,8 +64,25 @@ module MiniTest
71
64
  @io.send(msg, *args, &block)
72
65
  end
73
66
 
67
+ def respond_to?(msg)
68
+ @io.respond_to?(msg) || super
69
+ end
70
+
74
71
  private
75
72
 
73
+ def notify(body)
74
+ match = config_for(:regexp).match(body)
75
+ return unless match
76
+ state = match.captures.any? { |c| c.to_i > 0 } ? :fail : :pass
77
+
78
+ default_description = config_for(:description)
79
+ libnotify.body = config_for(:body, state, body)
80
+ libnotify.summary = config_for(:description, state, default_description)
81
+ libnotify.urgency = config_for(:urgency, state)
82
+ libnotify.icon_path = config_for(:icon_path, state)
83
+ libnotify.show!
84
+ end
85
+
76
86
  def libnotify
77
87
  if @libnotify.nil?
78
88
  @libnotify = begin
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  class Libnotify
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-libnotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &16710480 !ruby/object:Gem::Requirement
16
+ requirement: &16603000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16710480
24
+ version_requirements: *16603000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: libnotify
27
- requirement: &16710020 !ruby/object:Gem::Requirement
27
+ requirement: &16602440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *16710020
35
+ version_requirements: *16602440
36
36
  description: Display graphical notfications when testing with minitest.
37
37
  email:
38
38
  - peter-minitest-libnotify@suschlik.de