adp-fluentd-plugin-gzip 0.0.3 → 0.0.7

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
  SHA256:
3
- metadata.gz: 800634a8c124fd7d4d97bdacf40b285fee79e406b1a68ac3c527646b25f3174f
4
- data.tar.gz: 165843eeac9cb9ad9bad2c8780ad67bef122b27ec3885e0a42e3392df75fda8e
3
+ metadata.gz: 035f43e830370693918be6653314292a027450a6eabf9fe3f7608cad2905b11f
4
+ data.tar.gz: d5583cff60b1220af5e04765531ed862bc5adee071d729520e040093609cf30b
5
5
  SHA512:
6
- metadata.gz: fcefbbfe461627052e0b19009cf778056f8b0c7f576ce9ba4c27b12dfdc027c462525b746705a5054cd67bc4c8fbba2a013dee3aa6c237775ab7fe3e42def3fd
7
- data.tar.gz: 46103c3f72fb63ae8652573b938c86dd5d91867550d22538a0672899662a7c4ec8f7eba7fc9072e53f39a87f902298cbaf9c24eeda30c1368c08085e36a57d4e
6
+ metadata.gz: c3913479f31d8b1c01afc99a7fb0dca966c730df3c1b08ec3fd6bacfe62f76ab5734a669c3f36992c4ae8998d07a40a87e2677cfd09be91485bcb402e59c18be
7
+ data.tar.gz: 9a787aace6432f99fada0ab66aad1899242d7eb5249ea9c6fc9ed0b16029bc583642d2bf87c79a8c4c990183e27bbe3a4f0c1ea5e529baca3d1a8eec6fe7ef8c
@@ -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.3"
5
+ spec.version = "0.0.7"
6
6
  spec.authors = ["Aleksander Dudek"]
7
7
  spec.email = ["aleksander.dudek@ringieraxelspringer.pl"]
8
8
 
@@ -1,25 +1,31 @@
1
1
  require 'fluent/plugin/parser'
2
2
  require 'zlib'
3
+ require 'logger'
3
4
 
4
- module Fluent::Plugin
5
- class GzipParser < Parser
6
- Fluent::Plugin.register_parser('gzip', self)
5
+ module Fluent
6
+ module Plugin
7
+ class GzipParser < Parser
8
+ Plugin.register_parser('gzip', self)
9
+ logger = Logger.new(STDOUT)
10
+ logger.level = Logger::INFO
7
11
 
8
- def configure(conf)
9
- super
10
- end
12
+ def configure(conf)
13
+ super
14
+ end
11
15
 
12
- def parse(text)
13
- log.info("Text: #{text}")
14
- log.info("After compression: #{compress(text)}")
15
- end
16
+ def parse(text)
17
+ @logger.info("Text: #{text}")
18
+ @logger.info("After compression: #{compress(text)}")
19
+ text
20
+ end
16
21
 
17
- def compress(string, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
18
- output = Stream.new
19
- gz = Zlib::GzipWriter.new(output, level, strategy)
20
- gz.write(string)
21
- gz.close
22
- output.string
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
28
+ end
23
29
  end
24
30
  end
25
31
  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.3
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksander Dudek