hatchet-hipchat 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,8 @@ module Hatchet
2
2
 
3
3
  # Public: Class for sending log messages to a HipChat room.
4
4
  #
5
+ # API reference: https://www.hipchat.com/docs/api/method/rooms/message
6
+ #
5
7
  class HipChatAppender
6
8
  include LevelManager
7
9
 
@@ -9,6 +11,10 @@ module Hatchet
9
11
  #
10
12
  CLIENT = HipChat::API
11
13
 
14
+ # Internal: Map for log level to message color.
15
+ #
16
+ COLOR_MAP = { debug: 'gray', info: 'gray', warn: 'yellow', error: 'red', fatal: 'red' }
17
+
12
18
  # Public: The formatter used to format messages before sending them to the
13
19
  # HipChat room.
14
20
  #
@@ -49,7 +55,7 @@ module Hatchet
49
55
  #
50
56
  def add(level, context, message)
51
57
  message = @formatter.format(level, context, message)
52
- client.rooms_message @room_id, @name, message, 0, 'yellow', 'text'
58
+ client.rooms_message @room_id, @name, message, 0, COLOR_MAP[level], 'text'
53
59
  end
54
60
 
55
61
  # Internal: Returns the client used to send messages to HipChat.
@@ -1,5 +1,5 @@
1
1
  module Hatchet
2
2
  module Hipchat
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -40,7 +40,6 @@ describe HipChatAppender do
40
40
  assert 'Hatchet' == message.from
41
41
  assert formatted_message == message.message
42
42
  assert 0 == message.notify
43
- assert 'yellow' == message.color
44
43
  assert 'text' == message.format
45
44
  end
46
45
 
@@ -57,6 +56,33 @@ describe HipChatAppender do
57
56
  assert 'CustomName' == message.from
58
57
  end
59
58
  end
59
+
60
+ describe 'message colors' do
61
+ it 'sends a debug message with a gray background' do
62
+ subject.add :debug, 'Custom::Context', 'Hello, World'
63
+ assert 'gray' == message.color
64
+ end
65
+
66
+ it 'sends an info message with a gray background' do
67
+ subject.add :info, 'Custom::Context', 'Hello, World'
68
+ assert 'gray' == message.color
69
+ end
70
+
71
+ it 'sends a warn message with a yellow background' do
72
+ subject.add :warn, 'Custom::Context', 'Hello, World'
73
+ assert 'yellow' == message.color
74
+ end
75
+
76
+ it 'sends an error message with a red background' do
77
+ subject.add :error, 'Custom::Context', 'Hello, World'
78
+ assert 'red' == message.color
79
+ end
80
+
81
+ it 'sends a fatal message with a red background' do
82
+ subject.add :fatal, 'Custom::Context', 'Hello, World'
83
+ assert 'red' == message.color
84
+ end
85
+ end
60
86
  end
61
87
  end
62
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatchet-hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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: 2012-07-25 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hatchet
16
- requirement: &70367079335100 !ruby/object:Gem::Requirement
16
+ requirement: &70223605017060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70367079335100
24
+ version_requirements: *70223605017060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hipchat-api
27
- requirement: &70367079334600 !ruby/object:Gem::Requirement
27
+ requirement: &70223605016560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.0.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70367079334600
35
+ version_requirements: *70223605016560
36
36
  description: Hatchet appender that sends messages to HipChat
37
37
  email:
38
38
  - garry@robustsoftware.co.uk