fluent-plugin-slack 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63a07a1d2026c16d55cd088092f69953404b202e
4
- data.tar.gz: 33f8b2de136067d8e0e7adfa69457bb676d97eaa
3
+ metadata.gz: 9728adc795ffb5913a6a95b430a9f32cfa6a348b
4
+ data.tar.gz: 2b4644f289d44272a7ce2b06a4d7fa9b523afa2b
5
5
  SHA512:
6
- metadata.gz: 429287c6ea93b6a2af9371e7c50624142295be16a2e81e2ba27f3d293dc310eed431a0481f33b349c52384839db415401285f38ee7a4dbbcc778dc2f5017ad06
7
- data.tar.gz: 50b5c8f83db6ef873cc448c85106b63e6dd7c6ff547f960701ec0634077d9539d09cbb5adfea347448c17982c538f87c5cfd37a44876eb5f90c2e91d43c3dfc6
6
+ metadata.gz: e133acd3966eca01bde5fe1a5dae574fd58761dd49066bac8a08ec46322e936cf20d7710c689bdbc135a6a438039e4d23c6bfcf3bff43ecae1be9091957038ef
7
+ data.tar.gz: e1c18bf9fe6fef99314522bfb94a8d092f430375ff69e3d2a2cb995185de5419f09dbaee50b3fd4528fbd329a427936578f6055c2133c4b3179b2d8b7b2cda87
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.1 (2015/05/17)
2
+
3
+ Fixes:
4
+
5
+ * Support ruby 1.9.3
6
+
1
7
  ## 0.6.0 (2015/04/02)
2
8
 
3
9
  This version has impcompatibility with previous versions in default option values
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -38,7 +38,7 @@ module Fluent
38
38
  end
39
39
 
40
40
  # for test
41
- attr_reader :slack, :time_format, :localtime, :timef, :mrkdwn_in
41
+ attr_reader :slack, :time_format, :localtime, :timef, :mrkdwn_in, :post_message_opts
42
42
 
43
43
  def initialize
44
44
  super
@@ -117,7 +117,11 @@ module Fluent
117
117
  raise Fluent::ConfigError, "`parse` must be either of `none` or `full`"
118
118
  end
119
119
 
120
- @post_message_opts = @auto_channels_create ? {auto_channels_create: true} : {}
120
+ @post_message_opts = {}
121
+ if @auto_channels_create
122
+ raise Fluent::ConfigError, "`token` parameter is required to use `auto_channels_create`" unless @token
123
+ @post_message_opts = {auto_channels_create: true}
124
+ end
121
125
  end
122
126
 
123
127
  def format(tag, time, record)
@@ -128,7 +132,7 @@ module Fluent
128
132
  begin
129
133
  payloads = build_payloads(chunk)
130
134
  payloads.each {|payload| @slack.post_message(payload, @post_message_opts) }
131
- rescue Net::OpenTimeout, Net::ReadTimeout => e
135
+ rescue Timeout::Error => e
132
136
  log.warn "out_slack:", :error => e.to_s, :error_class => e.class.to_s
133
137
  raise e # let Fluentd retry
134
138
  rescue => e
@@ -172,6 +176,8 @@ module Fluent
172
176
  end
173
177
 
174
178
  Field = Struct.new("Field", :title, :value)
179
+ # ruby 1.9.x does not provide #to_h
180
+ Field.send(:define_method, :to_h) { {title: title, value: value} }
175
181
 
176
182
  def build_title_payloads(chunk)
177
183
  ch_fields = {}
@@ -38,7 +38,7 @@ module Fluent
38
38
  end
39
39
 
40
40
  # for test
41
- attr_reader :slack, :time_format, :localtime, :timef, :mrkdwn_in
41
+ attr_reader :slack, :time_format, :localtime, :timef, :mrkdwn_in, :post_message_opts
42
42
 
43
43
  def initialize
44
44
  super
@@ -117,7 +117,11 @@ module Fluent
117
117
  raise Fluent::ConfigError, "`parse` must be either of `none` or `full`"
118
118
  end
119
119
 
120
- @post_message_opts = @auto_channels_create ? {auto_channels_create: true} : {}
120
+ @post_message_opts = {}
121
+ if @auto_channels_create
122
+ raise Fluent::ConfigError, "`token` parameter is required to use `auto_channels_create`" unless @token
123
+ @post_message_opts = {auto_channels_create: true}
124
+ end
121
125
  end
122
126
 
123
127
  def format(tag, time, record)
@@ -128,7 +132,7 @@ module Fluent
128
132
  begin
129
133
  payloads = build_payloads(chunk)
130
134
  payloads.each {|payload| @slack.post_message(payload, @post_message_opts) }
131
- rescue Net::OpenTimeout, Net::ReadTimeout => e
135
+ rescue Timeout::Error => e
132
136
  log.warn "out_slack:", :error => e.to_s, :error_class => e.class.to_s
133
137
  raise e # let Fluentd retry
134
138
  rescue => e
@@ -172,6 +176,8 @@ module Fluent
172
176
  end
173
177
 
174
178
  Field = Struct.new("Field", :title, :value)
179
+ # ruby 1.9.x does not provide #to_h
180
+ Field.send(:define_method, :to_h) { {title: title, value: value} }
175
181
 
176
182
  def build_title_payloads(chunk)
177
183
  ch_fields = {}
@@ -51,7 +51,7 @@ module Fluent
51
51
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
52
52
  http.set_debug_output(debug_dev) if debug_dev
53
53
 
54
- req = Net::HTTP::Post.new(endpoint)
54
+ req = Net::HTTP::Post.new(endpoint.request_uri)
55
55
  req['Host'] = endpoint.host
56
56
  req['Accept'] = 'application/json; charset=utf-8'
57
57
  req['User-Agent'] = 'fluent-plugin-slack'
@@ -246,6 +246,23 @@ class SlackOutputTest < Test::Unit::TestCase
246
246
  assert_not_equal Net::HTTP, d.instance.slack.proxy_class # Net::HTTP.Proxy
247
247
  end
248
248
 
249
+ def test_auto_channels_create_configure
250
+ # default
251
+ d = create_driver(CONFIG)
252
+ assert_equal false, d.instance.auto_channels_create
253
+ assert_equal({}, d.instance.post_message_opts)
254
+
255
+ # require `token`
256
+ assert_raise(Fluent::ConfigError) do
257
+ d = create_driver(CONFIG + %[auto_channels_create true])
258
+ end
259
+
260
+ # auto_channels_create
261
+ d = create_driver(CONFIG + %[auto_channels_create true\ntoken XXX-XX-XXX])
262
+ assert_equal true, d.instance.auto_channels_create
263
+ assert_equal({auto_channels_create: true}, d.instance.post_message_opts)
264
+ end
265
+
249
266
  def test_default_incoming_webhook
250
267
  d = create_driver(%[
251
268
  channel channel
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keisuke SOGAWA
@@ -9,118 +9,118 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-02 00:00:00.000000000 Z
12
+ date: 2015-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.10.8
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.10.8
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: 10.1.1
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: 10.1.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rr
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - '>='
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.0.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.0.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: pry
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: pry-nav
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - '>='
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: test-unit
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: 3.0.2
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ~>
96
96
  - !ruby/object:Gem::Version
97
97
  version: 3.0.2
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: test-unit-rr
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ~>
103
103
  - !ruby/object:Gem::Version
104
104
  version: 1.0.3
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ~>
110
110
  - !ruby/object:Gem::Version
111
111
  version: 1.0.3
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: dotenv
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  description: fluent Slack plugin
@@ -131,8 +131,8 @@ executables: []
131
131
  extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
- - ".gitignore"
135
- - ".travis.yml"
134
+ - .gitignore
135
+ - .travis.yml
136
136
  - CHANGELOG.md
137
137
  - Gemfile
138
138
  - README.md
@@ -157,17 +157,17 @@ require_paths:
157
157
  - lib
158
158
  required_ruby_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - ">="
160
+ - - '>='
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - '>='
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0'
168
168
  requirements: []
169
169
  rubyforge_project:
170
- rubygems_version: 2.4.5
170
+ rubygems_version: 2.0.14
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: fluent Slack plugin