adp-fluentd-plugin-gzip 0.0.4 → 0.0.8
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 +4 -4
- data/adp-fluentd-plugin-gzip.gemspec +1 -1
- data/lib/fluent/plugin/parser_gzip.rb +17 -20
- data/test/adp/fluentd/plugin/gzip_test.rb +31 -7
- data/test/test_helper.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf6f56869f6a6ebbc68cab5a337df0afb3bb993a634c61e5039638f00db5001a
|
4
|
+
data.tar.gz: b730b9f344628ad6c535b90f0ad2e60cba48db57507942500cf96701547accf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d119cc5275b301a0b0d2e595c22f7450fcfa64d0fba01872fc77075b81e611fc6b7f6aee9bcd3ac8003df5069f26e76de0ddaea6252a8e16e60b91dba48e4319
|
7
|
+
data.tar.gz: e631cb982dbb5b9ff699261ae07fe7f1fd65780ddef9cc9226a3080021a5a31c8425021476d5cae213f0c44845a948fa877b3b792d388cda788725560c917d53
|
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "adp-fluentd-plugin-gzip"
|
5
|
-
spec.version = "0.0.
|
5
|
+
spec.version = "0.0.8"
|
6
6
|
spec.authors = ["Aleksander Dudek"]
|
7
7
|
spec.email = ["aleksander.dudek@ringieraxelspringer.pl"]
|
8
8
|
|
@@ -2,29 +2,26 @@ require 'fluent/plugin/parser'
|
|
2
2
|
require 'zlib'
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module Fluent
|
6
|
+
module Plugin
|
7
|
+
class GzipParser < Parser
|
8
|
+
Plugin.register_parser('gzip', self)
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def configure(conf)
|
11
|
+
super
|
12
|
+
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def parse(text)
|
17
|
-
logger.info("Text: #{text}")
|
18
|
-
logger.info("After compression: #{compress(text)}")
|
19
|
-
text
|
20
|
-
end
|
14
|
+
def parse(text)
|
15
|
+
compress(text)
|
16
|
+
end
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
18
|
+
def compress(string, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
|
19
|
+
output = Stream.new
|
20
|
+
gz = Zlib::GzipWriter.new(output, level, strategy)
|
21
|
+
gz.write(string)
|
22
|
+
gz.close
|
23
|
+
output.string
|
24
|
+
end
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
@@ -1,11 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser_gzip'
|
2
4
|
|
3
|
-
class
|
4
|
-
def
|
5
|
-
refute_nil ::Adp::Fluentd::Plugin::Gzip::VERSION
|
5
|
+
class ParserYourOwnTest < Test::Unit::TestCase
|
6
|
+
def setup
|
6
7
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
CONFIG = %[
|
9
|
+
pattern apache
|
10
|
+
]
|
11
|
+
def create_driver(conf = CONF)
|
12
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::GzipParser).configure(conf)
|
13
|
+
end
|
14
|
+
sub_test_case 'configured with invalid configurations' do
|
15
|
+
test 'empty' do
|
16
|
+
assert_raise(Fluent::ConfigError) do
|
17
|
+
create_driver('')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
sub_test_case 'plugin will parse text' do
|
22
|
+
test 'record has a field' do
|
23
|
+
d = create_driver(CONFIG)
|
24
|
+
text = '192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777'
|
25
|
+
expected_time = event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z')
|
26
|
+
expected_record = {
|
27
|
+
'method' => 'GET',
|
28
|
+
}
|
29
|
+
d.instance.parse(text) do |time, record|
|
30
|
+
assert_equal(expected_time, time)
|
31
|
+
assert_equal(expected_record, record)
|
32
|
+
end
|
33
|
+
end
|
10
34
|
end
|
11
35
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
require "minitest/autorun"
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test'
|
3
|
+
require "fluent/plugin/parser_gzip"
|