fluent-plugin-hipchat 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41892c64df61d3496d02924d73f14089e969ab09
4
- data.tar.gz: 4d7545f990da26894984c0eb2e7148a7bf98567b
3
+ metadata.gz: 7e1eaf019c429076398ea4723cfeb6c5d6db6dc5
4
+ data.tar.gz: 7cfe131f2ebb925e8d5de5787114301c9c0e37f2
5
5
  SHA512:
6
- metadata.gz: 0645335bd45ddafe75bd9fd034568a05083ef691408f2ab954ecd37b52b7f476744090b2ba3262b9c196444259e0e2528e03d71795eb484cf56e47f758d73476
7
- data.tar.gz: f8883ccf6e965bf0eb74b24c64a224d005a8f4eefb09637405308f516613e1eb524ae1eca7a5b414369973e2fc5085507a1a575a783ff236ca9b900beeed3192
6
+ metadata.gz: 9198b96a460c242756c0d6f324f6e2b52e2c1e1aedfb843ed78e3f357f7196eff45bdf671813cfa1d44145149b66ce93ef66ba4da3efced2ec77e4aca0d714a7
7
+ data.tar.gz: 6e47b1a66401e702ee17bc76541229a3dc485cb4da56e172dcbe27c37edac9d5ea4dcc23d4026abb72dffd189fbb8b0163295fb82a8ecf7fbfef54b1ba58f496
data/README.rdoc CHANGED
@@ -16,6 +16,8 @@
16
16
  default_color yellow
17
17
  default_notify 0
18
18
  default_format html
19
+ default_timeout 3 # HipChat API Request Timeout Seconds (default 3)
20
+ key_name message
19
21
 
20
22
  # proxy settings
21
23
  # http_proxy_host localhost
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -11,6 +11,8 @@ module Fluent
11
11
  config_param :default_from, :string, :default => nil
12
12
  config_param :default_notify, :bool, :default => nil
13
13
  config_param :default_format, :string, :default => nil
14
+ config_param :key_name, :string, :default => 'message'
15
+ config_param :default_timeout, :time, :default => nil
14
16
  config_param :http_proxy_host, :string, :default => nil
15
17
  config_param :http_proxy_port, :integer, :default => nil
16
18
  config_param :http_proxy_user, :string, :default => nil
@@ -33,6 +35,7 @@ module Fluent
33
35
  @default_notify = conf['default_notify'] || 0
34
36
  @default_color = conf['default_color'] || 'yellow'
35
37
  @default_format = conf['default_format'] || 'html'
38
+ @default_timeout = conf['default_timeout']
36
39
  if conf['http_proxy_host']
37
40
  HipChat::API.http_proxy(
38
41
  conf['http_proxy_host'],
@@ -49,7 +52,7 @@ module Fluent
49
52
  def write(chunk)
50
53
  chunk.msgpack_each do |(tag,time,record)|
51
54
  begin
52
- send_message(record) if record['message']
55
+ send_message(record) if record[@key_name]
53
56
  set_topic(record) if record['topic']
54
57
  rescue => e
55
58
  $log.error("HipChat Error:", :error_class => e.class, :error => e.message)
@@ -60,7 +63,7 @@ module Fluent
60
63
  def send_message(record)
61
64
  room = record['room'] || @default_room
62
65
  from = record['from'] || @default_from
63
- message = record['message']
66
+ message = record[@key_name]
64
67
  if record['notify'].nil?
65
68
  notify = @default_notify
66
69
  else
@@ -68,8 +71,9 @@ module Fluent
68
71
  end
69
72
  color = COLORS.include?(record['color']) ? record['color'] : @default_color
70
73
  message_format = FORMAT.include?(record['format']) ? record['format'] : @default_format
74
+ @hipchat.set_timeout(@default_timeout.to_i) unless @default_timeout.nil?
71
75
  response = @hipchat.rooms_message(room, from, message, notify, color, message_format)
72
- raise StandardError, response['error']['message'].to_s if defined?(response['error']['message'])
76
+ raise StandardError, response['error'][@key_name].to_s if defined?(response['error'][@key_name])
73
77
  end
74
78
 
75
79
  def set_topic(record)
@@ -77,7 +81,7 @@ module Fluent
77
81
  from = record['from'] || @default_from
78
82
  topic = record['topic']
79
83
  response = @hipchat.rooms_topic(room, topic, from)
80
- raise StandardError, response['error']['message'].to_s if defined?(response['error']['message'])
84
+ raise StandardError, response['error'][@key_name].to_s if defined?(response['error'][@key_name])
81
85
  end
82
86
  end
83
87
  end
@@ -39,6 +39,17 @@ class HipchatOutputTest < Test::Unit::TestCase
39
39
  d.run
40
40
  end
41
41
 
42
+ def test_set_default_timeout
43
+ d = create_driver(<<-EOF)
44
+ type hipchat
45
+ api_token xxx
46
+ default_timeout 5
47
+ EOF
48
+ stub(d.instance.hipchat).set_timeout(5)
49
+ d.emit({'message' => 'foo'})
50
+ d.run
51
+ end
52
+
42
53
  def test_message
43
54
  d = create_driver
44
55
  stub(d.instance.hipchat).rooms_message('testroom', 'testuser', 'foo', 0, 'red', 'html')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-hipchat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichi Tateno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd