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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dbcc94bf83b9b8e4a3d25b900fd593467b696a65b96287add90b17e77d69f70
4
- data.tar.gz: 77dbc39e996acac186c81d24904b4b01773ab3f09df49c51e5a0f6a773aafc3e
3
+ metadata.gz: bf6f56869f6a6ebbc68cab5a337df0afb3bb993a634c61e5039638f00db5001a
4
+ data.tar.gz: b730b9f344628ad6c535b90f0ad2e60cba48db57507942500cf96701547accf7
5
5
  SHA512:
6
- metadata.gz: e1d555f90a2237f985f8639aded8eadda601366df45bc767047333d6e05b86a531f2073cf6f0b65cc0294992778f1c993740a57a2650d25670b63da1f6e24e6d
7
- data.tar.gz: e788e6c2cdf99994da22206fa2e263a432c478d895361ec6f9e7c110f69b91140dab5498a943641fa8ed7a4532ece37f6749d72746dde11bd2184bea52180504
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.4"
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
- logger = Logger.new(STDOUT)
6
- logger.level = Logger::INFO
5
+ module Fluent
6
+ module Plugin
7
+ class GzipParser < Parser
8
+ Plugin.register_parser('gzip', self)
7
9
 
8
- module Fluent::Plugin
9
- class GzipParser < Parser
10
- Fluent::Plugin.register_parser('gzip', self)
10
+ def configure(conf)
11
+ super
12
+ end
11
13
 
12
- def configure(conf)
13
- super
14
- end
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
- def compress(string, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
23
- output = Stream.new
24
- gz = Zlib::GzipWriter.new(output, level, strategy)
25
- gz.write(string)
26
- gz.close
27
- output.string
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 "test_helper"
1
+ require 'test/unit'
2
+ require 'fluent/test/driver/parser'
3
+ require 'fluent/plugin/parser_gzip'
2
4
 
3
- class Adp::Fluentd::Plugin::GzipTest < Minitest::Test
4
- def test_that_it_has_a_version_number
5
- refute_nil ::Adp::Fluentd::Plugin::Gzip::VERSION
5
+ class ParserYourOwnTest < Test::Unit::TestCase
6
+ def setup
6
7
  end
7
-
8
- def test_it_does_something_useful
9
- assert false
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
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
- require "adp/fluentd/plugin/gzip"
3
-
4
- require "minitest/autorun"
1
+ require 'test/unit'
2
+ require 'fluent/test'
3
+ require "fluent/plugin/parser_gzip"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adp-fluentd-plugin-gzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksander Dudek