fluent-plugin-tail-asis 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/fluent-plugin-tail-asis.gemspec +24 -0
- data/lib/fluent/plugin/in_tail_asis.rb +30 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_in_tail_asis.rb +106 -0
- metadata +110 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TERAOKA Yoshinori
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Fluent::Plugin::TailAsis
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fluent-plugin-tail-asis'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-tail-asis
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "fluent-plugin-tail-asis"
|
7
|
+
gem.version = "0.0.1"
|
8
|
+
gem.authors = ["TERAOKA Yoshinori"]
|
9
|
+
gem.email = ["jyobijyoba@gmail.com"]
|
10
|
+
gem.description = %q{fluentd input plugin, whole line read into single key}
|
11
|
+
gem.summary = %q{fluentd input plugin, whole line read into single key}
|
12
|
+
gem.homepage = ""
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.rubyforge_project = "fluent-plugin-tailasis"
|
20
|
+
|
21
|
+
gem.add_development_dependency "rake"
|
22
|
+
gem.add_development_dependency "fluentd"
|
23
|
+
gem.add_runtime_dependency "fluentd"
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fluent
|
2
|
+
|
3
|
+
class AsisTailInput < TailInput
|
4
|
+
Plugin.register_input('tail_asis', self)
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
|
9
|
+
@parser = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure_parser(conf)
|
13
|
+
@parser = AsisParser.new
|
14
|
+
@parser.configure(conf)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class AsisParser
|
19
|
+
include Configurable
|
20
|
+
|
21
|
+
config_param :asis_key, :string, :default => 'message'
|
22
|
+
|
23
|
+
def parse(text)
|
24
|
+
record = {}
|
25
|
+
record[@asis_key] = text
|
26
|
+
return Engine.now, record
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
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
|
+
|
25
|
+
require 'fluent/plugin/in_tail'
|
26
|
+
require 'fluent/plugin/in_tail_asis'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class AsisTailInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
FileUtils.rm_rf(TMP_DIR)
|
7
|
+
FileUtils.mkdir_p(TMP_DIR)
|
8
|
+
end
|
9
|
+
|
10
|
+
TMP_DIR = File.dirname(__FILE__) + "/../tmp"
|
11
|
+
|
12
|
+
CONFIG = %[
|
13
|
+
path #{TMP_DIR}/tailasis.txt
|
14
|
+
tag t1
|
15
|
+
rotate_wait 2s
|
16
|
+
pos_file #{TMP_DIR}/tailasis.pos
|
17
|
+
asis_key message
|
18
|
+
]
|
19
|
+
|
20
|
+
def create_driver(conf=CONFIG)
|
21
|
+
Fluent::Test::InputTestDriver.new(Fluent::AsisTailInput).configure(conf)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_configure
|
25
|
+
d = create_driver
|
26
|
+
assert_equal ["#{TMP_DIR}/tailasis.txt"], d.instance.paths
|
27
|
+
assert_equal "t1", d.instance.tag
|
28
|
+
assert_equal 2, d.instance.rotate_wait
|
29
|
+
assert_equal "#{TMP_DIR}/tailasis.pos", d.instance.pos_file
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_emit
|
33
|
+
File.open("#{TMP_DIR}/tailasis.txt", "w") {|f|
|
34
|
+
f.puts "test1"
|
35
|
+
f.puts "test2"
|
36
|
+
}
|
37
|
+
|
38
|
+
d = create_driver
|
39
|
+
|
40
|
+
d.run do
|
41
|
+
sleep 1
|
42
|
+
|
43
|
+
File.open("#{TMP_DIR}/tailasis.txt", "a") {|f|
|
44
|
+
f.puts "test3"
|
45
|
+
f.puts "test4"
|
46
|
+
}
|
47
|
+
sleep 1
|
48
|
+
end
|
49
|
+
|
50
|
+
emits = d.emits
|
51
|
+
assert_equal(true, emits.length > 0)
|
52
|
+
assert_equal({"message"=>"test3"}, emits[0][2])
|
53
|
+
assert_equal({"message"=>"test4"}, emits[1][2])
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_lf
|
57
|
+
File.open("#{TMP_DIR}/tailasis.txt", "w") {|f| }
|
58
|
+
|
59
|
+
d = create_driver
|
60
|
+
|
61
|
+
d.run do
|
62
|
+
File.open("#{TMP_DIR}/tailasis.txt", "a") {|f|
|
63
|
+
f.print "test3"
|
64
|
+
}
|
65
|
+
sleep 1
|
66
|
+
|
67
|
+
File.open("#{TMP_DIR}/tailasis.txt", "a") {|f|
|
68
|
+
f.puts "test4"
|
69
|
+
}
|
70
|
+
sleep 1
|
71
|
+
end
|
72
|
+
|
73
|
+
emits = d.emits
|
74
|
+
assert_equal(true, emits.length > 0)
|
75
|
+
assert_equal({"message"=>"test3test4"}, emits[0][2])
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_whitespace
|
79
|
+
File.open("#{TMP_DIR}/tailasis.txt", "w") {|f| }
|
80
|
+
|
81
|
+
d = create_driver
|
82
|
+
|
83
|
+
d.run do
|
84
|
+
sleep 1
|
85
|
+
|
86
|
+
File.open("#{TMP_DIR}/tailasis.txt", "a") {|f|
|
87
|
+
f.puts " " # 4 spaces
|
88
|
+
f.puts " 4 spaces"
|
89
|
+
f.puts "4 spaces "
|
90
|
+
f.puts " " # tab
|
91
|
+
f.puts " tab"
|
92
|
+
f.puts "tab "
|
93
|
+
}
|
94
|
+
sleep 1
|
95
|
+
end
|
96
|
+
|
97
|
+
emits = d.emits
|
98
|
+
assert_equal(true, emits.length > 0)
|
99
|
+
assert_equal({"message"=>" "}, emits[0][2])
|
100
|
+
assert_equal({"message"=>" 4 spaces"}, emits[1][2])
|
101
|
+
assert_equal({"message"=>"4 spaces "}, emits[2][2])
|
102
|
+
assert_equal({"message"=>" "}, emits[3][2])
|
103
|
+
assert_equal({"message"=>" tab"}, emits[4][2])
|
104
|
+
assert_equal({"message"=>"tab "}, emits[5][2])
|
105
|
+
end
|
106
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-tail-asis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- TERAOKA Yoshinori
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fluentd
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fluentd
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: fluentd input plugin, whole line read into single key
|
63
|
+
email:
|
64
|
+
- jyobijyoba@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- fluent-plugin-tail-asis.gemspec
|
75
|
+
- lib/fluent/plugin/in_tail_asis.rb
|
76
|
+
- test/helper.rb
|
77
|
+
- test/plugin/test_in_tail_asis.rb
|
78
|
+
homepage: ''
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
hash: -4502054065033792938
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: -4502054065033792938
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project: fluent-plugin-tailasis
|
104
|
+
rubygems_version: 1.8.24
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: fluentd input plugin, whole line read into single key
|
108
|
+
test_files:
|
109
|
+
- test/helper.rb
|
110
|
+
- test/plugin/test_in_tail_asis.rb
|