hatchet-hipchat 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,11 +42,15 @@ module Hatchet
42
42
  #
43
43
  # Returns messages in the format:
44
44
  #
45
- # LEVEL - CONTEXT - MESSAGE
45
+ # LEVEL - CONTEXT NDC - MESSAGE
46
46
  #
47
47
  def format(level, context, message)
48
- message = message.to_s.strip
49
- "#{LEVEL_EMOTICON_MAP[level]} - #{context} - #{message}"
48
+ msg = message.to_s.strip
49
+ if message.ndc.any?
50
+ "#{LEVEL_EMOTICON_MAP[level]} - #{context} #{message.ndc.join(' ')} - #{msg}"
51
+ else
52
+ "#{LEVEL_EMOTICON_MAP[level]} - #{context} - #{msg}"
53
+ end
50
54
  end
51
55
 
52
56
  end
@@ -1,5 +1,5 @@
1
1
  module Hatchet
2
2
  module Hipchat
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -25,7 +25,7 @@ describe HipChatAppender do
25
25
  end
26
26
 
27
27
  before do
28
- subject.add :warn, 'Custom::Context', 'Hello, World'
28
+ subject.add :warn, 'Custom::Context', Message.new('Hello, World')
29
29
  end
30
30
 
31
31
  let(:message) { subject.client.messages.last }
@@ -36,7 +36,7 @@ describe HipChatAppender do
36
36
 
37
37
  it 'sends a formatted message to the configured room' do
38
38
  assert 'ROOM_ID' == message.room_id
39
- formatted_message = subject.formatter.format(:warn, 'Custom::Context', 'Hello, World')
39
+ formatted_message = subject.formatter.format(:warn, 'Custom::Context', Message.new('Hello, World'))
40
40
  assert 'Hatchet' == message.from
41
41
  assert formatted_message == message.message
42
42
  assert 0 == message.notify
@@ -49,7 +49,7 @@ describe HipChatAppender do
49
49
  end
50
50
 
51
51
  before do
52
- subject.add :warn, 'Custom::Context', 'Hello, World'
52
+ subject.add :warn, 'Custom::Context', Message.new('Hello, World')
53
53
  end
54
54
 
55
55
  it 'sends a message with the configured name' do
@@ -59,27 +59,27 @@ describe HipChatAppender do
59
59
 
60
60
  describe 'message colors' do
61
61
  it 'sends a debug message with a gray background' do
62
- subject.add :debug, 'Custom::Context', 'Hello, World'
62
+ subject.add :debug, 'Custom::Context', Message.new('Hello, World')
63
63
  assert 'gray' == message.color
64
64
  end
65
65
 
66
66
  it 'sends an info message with a gray background' do
67
- subject.add :info, 'Custom::Context', 'Hello, World'
67
+ subject.add :info, 'Custom::Context', Message.new('Hello, World')
68
68
  assert 'gray' == message.color
69
69
  end
70
70
 
71
71
  it 'sends a warn message with a yellow background' do
72
- subject.add :warn, 'Custom::Context', 'Hello, World'
72
+ subject.add :warn, 'Custom::Context', Message.new('Hello, World')
73
73
  assert 'yellow' == message.color
74
74
  end
75
75
 
76
76
  it 'sends an error message with a red background' do
77
- subject.add :error, 'Custom::Context', 'Hello, World'
77
+ subject.add :error, 'Custom::Context', Message.new('Hello, World')
78
78
  assert 'red' == message.color
79
79
  end
80
80
 
81
81
  it 'sends a fatal message with a red background' do
82
- subject.add :fatal, 'Custom::Context', 'Hello, World'
82
+ subject.add :fatal, 'Custom::Context', Message.new('Hello, World')
83
83
  assert 'red' == message.color
84
84
  end
85
85
  end
@@ -3,25 +3,25 @@ require_relative 'spec_helper'
3
3
  describe HipChatEmoticonFormatter do
4
4
  let(:formatter) { HipChatEmoticonFormatter.new }
5
5
  let(:context) { 'Context' }
6
- let(:message) { 'Hello, World' }
6
+ let(:message) { Hatchet::Message.new(ndc: [:one, :two], message: 'Hello, World') }
7
7
 
8
8
  it 'maps debug to (content)' do
9
- assert '(content) - Context - Hello, World' == formatter.format(:debug, context, message)
9
+ assert '(content) - Context one two - Hello, World' == formatter.format(:debug, context, message)
10
10
  end
11
11
 
12
12
  it 'maps info to (wat)' do
13
- assert '(wat) - Context - Hello, World' == formatter.format(:info, context, message)
13
+ assert '(wat) - Context one two - Hello, World' == formatter.format(:info, context, message)
14
14
  end
15
15
 
16
16
  it 'maps warn to (ohcrap)' do
17
- assert '(ohcrap) - Context - Hello, World' == formatter.format(:warn, context, message)
17
+ assert '(ohcrap) - Context one two - Hello, World' == formatter.format(:warn, context, message)
18
18
  end
19
19
 
20
20
  it 'maps debug to (omg)' do
21
- assert '(omg) - Context - Hello, World' == formatter.format(:error, context, message)
21
+ assert '(omg) - Context one two - Hello, World' == formatter.format(:error, context, message)
22
22
  end
23
23
 
24
24
  it 'maps debug to (boom)' do
25
- assert '(boom) - Context - Hello, World' == formatter.format(:fatal, context, message)
25
+ assert '(boom) - Context one two - Hello, World' == formatter.format(:fatal, context, message)
26
26
  end
27
27
  end
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.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-29 00:00:00.000000000 Z
12
+ date: 2013-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hatchet
16
- requirement: &70201466984260 !ruby/object:Gem::Requirement
16
+ requirement: &70285042908380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0.0'
21
+ version: '0.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70201466984260
24
+ version_requirements: *70285042908380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hipchat-api
27
- requirement: &70201466983620 !ruby/object:Gem::Requirement
27
+ requirement: &70285042926760 !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: *70201466983620
35
+ version_requirements: *70285042926760
36
36
  description: Hatchet appender that sends messages to HipChat
37
37
  email:
38
38
  - garry@robustsoftware.co.uk