fluent-plugin-redmine 0.6.1 → 0.7.0

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: 1717557dfbb5ad9bba62595e3bf2d8dc092fd9fb
4
- data.tar.gz: 2a32bff9984acb4aac564396269453f8555b16d5
3
+ metadata.gz: 81811a6cf328c34cf36502e0fd6fdf9dabe81dba
4
+ data.tar.gz: 7b91b3e6f40bac9d4e87cf5bb68e6a82069e69d6
5
5
  SHA512:
6
- metadata.gz: d0d3d6d2e72d252ef8386bc7ce2e485e8a8a4607de562b3cd188a7cf986f45c81f0ed550cab940dd6e0e7aa4380544e63052f77a6bc5cb474a4fc004b20cc339
7
- data.tar.gz: bf1429ce7cdbc9fa766e323088716198e09f853223152436554a6ebcdf6eada8ff8151fd5cf47a3fd129acea0196a1f5e28d6d70bdb797222e5e0a5292c31a03
6
+ metadata.gz: a837b3521dca8933dbaa97bc279f82978a061a9686afd00160cc9bad4c1fc3350b33216c94515957e505f652c755d93b7d37a412856801a77a54f09bc88a43fb
7
+ data.tar.gz: dc7bd64a75d82b492a103c258a5b8e47c8def9276eba2a7becd15bd7e80c067012af32ca58bfaf3057099fdafaf086c93ceaceb466a738cfcd97dba60656da95
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-redmine"
7
- spec.version = "0.6.1"
7
+ spec.version = "0.7.0"
8
8
  spec.authors = ["Takuma kanari"]
9
9
  spec.email = ["chemtrails.t@gmail.com"]
10
10
  spec.summary = %q{Fluentd output plugin to create ticket in redmine}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency "fluentd", [">= 0.12", "< 2"]
20
+ spec.add_runtime_dependency "fluentd", [">= 0.14", "< 2"]
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "test-unit"
@@ -1,6 +1,9 @@
1
- module Fluent
1
+ require "json"
2
+ require "net/http"
2
3
 
3
- class RedmineOutput < BufferedOutput
4
+ module Fluent::Plugin
5
+
6
+ class RedmineOutput < Fluent::Plugin::Output
4
7
  Fluent::Plugin.register_output('redmine', self)
5
8
 
6
9
  desc "Redmine url"
@@ -45,21 +48,15 @@ module Fluent
45
48
  desc "Key name in the record for Redmine custom fields"
46
49
  config_param :custom_fields_key, :string, default: nil
47
50
 
48
- def initialize
49
- super
50
- require "json"
51
+ config_section :buffer do
52
+ config_set_default :@type, :memory
53
+ config_set_default :chunk_keys, ["tag"]
51
54
  end
52
55
 
53
56
  def configure(conf)
54
57
  super
55
58
 
56
- @use_ssl = (@url =~ /^https:/) ? true : false
57
-
58
- if @use_ssl
59
- require "net/https"
60
- else
61
- require "net/http"
62
- end
59
+ @use_ssl = @url.start_with?("https:")
63
60
 
64
61
  @subject_expander = TemplateExpander.new(@subject)
65
62
  @description_expander = TemplateExpander.new(@description)
@@ -71,12 +68,9 @@ module Fluent
71
68
  }
72
69
  end
73
70
 
74
- def format(tag, time, record)
75
- [tag, time, record].to_msgpack
76
- end
77
-
78
71
  def write(chunk)
79
- chunk.msgpack_each do |tag, time, record|
72
+ tag = chunk.metadata.tag
73
+ chunk.each do |_time, record|
80
74
  subject = @subject_expander.bind(make_record(tag, record))
81
75
  desc = @description_expander.bind(make_record(tag, record))
82
76
  begin
@@ -91,7 +85,7 @@ module Fluent
91
85
  def submit_ticket(subject, desc, record)
92
86
  request = Net::HTTP::Post.new(
93
87
  @redmine_uri.request_uri,
94
- initheader = @redmine_request_header
88
+ @redmine_request_header
95
89
  )
96
90
  request.body = JSON.generate(make_payload(subject, desc, record))
97
91
 
@@ -107,7 +101,7 @@ module Fluent
107
101
  client.start do |http|
108
102
  res = http.request(request)
109
103
  unless res.code.to_i == 201
110
- raise Exception.new("Error: #{res.code}, #{res.body}")
104
+ raise Error, "Error: #{res.code}, #{res.body}"
111
105
  end
112
106
  return res.body
113
107
  end
@@ -162,6 +156,7 @@ module Fluent
162
156
  end
163
157
  end
164
158
 
159
+ class Error < StandardError
160
+ end
165
161
  end
166
-
167
162
  end
data/test/helper.rb CHANGED
@@ -1,28 +1,12 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
1
+ require "bundler/setup"
10
2
  require 'test/unit'
11
3
 
12
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
6
  require 'fluent/test'
15
- unless ENV.has_key?('VERBOSE')
16
- nulllogger = Object.new
17
- nulllogger.instance_eval {|obj|
18
- def method_missing(method, *args)
19
- # pass
20
- end
21
- }
22
- $log = nulllogger
23
- end
24
-
7
+ require 'fluent/test/helpers'
8
+ require 'fluent/test/driver/output'
25
9
  require 'fluent/plugin/out_redmine'
26
10
 
27
- class Test::Unit::TestCase
28
- end
11
+ Test::Unit::TestCase.include(Fluent::Test::Helpers)
12
+ Test::Unit::TestCase.extend(Fluent::Test::Helpers)
@@ -121,7 +121,7 @@ class RedmineOutputTest < Test::Unit::TestCase
121
121
 
122
122
  cv = ConditionVariable.new
123
123
 
124
- watcher = Thread.new {
124
+ Thread.new {
125
125
  connected = false
126
126
  while not connected
127
127
  begin
@@ -148,8 +148,8 @@ class RedmineOutputTest < Test::Unit::TestCase
148
148
  @dummy_redmine.join
149
149
  end
150
150
 
151
- def create_driver(conf=CONFIG_OUT_KEYS,tag='test')
152
- Fluent::Test::BufferedOutputTestDriver.new(Fluent::RedmineOutput, tag).configure(conf)
151
+ def create_driver(conf=CONFIG_OUT_KEYS)
152
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::RedmineOutput).configure(conf)
153
153
  end
154
154
 
155
155
  def test_configure_http
@@ -277,16 +277,15 @@ CONFIG
277
277
  assert_false ret[:issue].key?(:custom_fields)
278
278
  end
279
279
 
280
- def test_emit
280
+ def test_feed
281
281
  d = create_driver(CONFIG_TO_FORMAT)
282
282
  record = {
283
283
  "name" => "John",
284
284
  "age" => 25,
285
285
  "message" => "this is message!"
286
286
  }
287
- t = Time.now
288
- d.run do
289
- d.emit(record, t.to_i)
287
+ d.run(default_tag: "test") do
288
+ d.feed(record)
290
289
  end
291
290
 
292
291
  assert_equal @tickets.size, 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-redmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma kanari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-03 00:00:00.000000000 Z
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.12'
19
+ version: '0.14'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.12'
29
+ version: '0.14'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'