fluent-plugin-to_js 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a0bef3040140db7c847bb165f1321c4b58a92196
4
+ data.tar.gz: a695b9692e33203cc4fea24b215eb6f09c8c2289
5
+ SHA512:
6
+ metadata.gz: 8f0ef0dfafe7a6071e9907f22ad4f7554834ee0f8f7eea4acd8030200a245184a76186d94996f1fc3a37f10f629f5f33fa65a3bec0927925eeeb0683a9d767d2
7
+ data.tar.gz: dfcfc97bec28d4707bc5f7199a8ec8cf8d7bad1aa8b332c26b54a7a5b651f8b60cb994845e618fbaf8d8b3b3a7f11895aa356371b370bd6c9d0504f526a9ee5c
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ # Created by https://www.gitignore.io
2
+
3
+ ### Ruby ###
4
+ *.gem
5
+ *.rbc
6
+ *.lock
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+
21
+ ## Documentation cache and generated files:
22
+ /.yardoc/
23
+ /_yardoc/
24
+ /doc/
25
+ /rdoc/
26
+
27
+ ## Environment normalisation:
28
+ /.bundle/
29
+ /vendor/bundle
30
+ /lib/bundler/man/
31
+
32
+ # for a library or gem, you might want to ignore these files since the code is
33
+ # intended to run in multiple environments; otherwise, check them in:
34
+ # Gemfile.lock
35
+ # .ruby-version
36
+ # .ruby-gemset
37
+
38
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
39
+ .rvmrc
40
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-to_s.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ryoji Ishii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # fluent-plugin-to_js [![Gem Version](https://badge.fury.io/rb/fluent-plugin-to_s.svg)](http://badge.fury.io/rb/fluent-plugin-to_s)
2
+
3
+ Plugin that adds whole record to (default) to_s field
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ gem install fluent-plugin-to_js
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```xml
14
+ <match test.**>
15
+ type to_s
16
+ tag_prefix string
17
+ field_name to_string
18
+ </match>
19
+ ```
20
+
21
+ ### following inputs are coming:
22
+
23
+ ```
24
+ test.hoge {"data":"wef"}
25
+ ```
26
+
27
+ ### then output becomes as belows
28
+
29
+ ```
30
+ string.test.hoge {"data":"wef", "to_string":"{\"data\":\"wef\"}"}
31
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ # require 'fluent/plugin/add/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-to_js"
8
+ spec.version = "0.0.1"
9
+ spec.authors = ["dixen"]
10
+ spec.email = ["dixentw@gmail.com"]
11
+ spec.description = %q{Plugin that adds whole record to to_s field, json format}
12
+ spec.summary = %q{Plugin that adds whole record to to_s field, json format}
13
+ spec.homepage = "https://github.com/dixentw/fluent-plugin-to_s"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "fluentd"
24
+ end
@@ -0,0 +1,14 @@
1
+ class Fluent::ToSFilter < Fluent::Filter
2
+ Fluent::Plugin.register_filter('to_jstr', self)
3
+
4
+ config_param :field_name, :string, :default => 'to_s'
5
+
6
+ def configure(conf)
7
+ super
8
+ end
9
+
10
+ def filter(tag, time, record)
11
+ record[@field_name] = record.to_json
12
+ return record
13
+ end
14
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
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/out_to_s'
26
+
27
+ class Test::Unit::TestCase
28
+ end
@@ -0,0 +1,37 @@
1
+ require 'helper'
2
+
3
+ class ToSOutputTest < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+ end
7
+
8
+ CONFIG = %[
9
+ tag_prefix pre_hoge
10
+ field_name fname_fuga
11
+ ]
12
+
13
+ def create_driver(conf=CONFIG, tag='test')
14
+ Fluent::Test::OutputTestDriver.new(Fluent::ToSOutput, tag).configure(conf)
15
+ end
16
+
17
+ def test_configure
18
+ d = create_driver
19
+ assert_equal 'pre_hoge', d.instance.config["tag_prefix"]
20
+ assert_equal 'fname_fuga', d.instance.config["field_name"]
21
+ end
22
+
23
+ def test_tos
24
+ d = create_driver
25
+ time = Time.parse("2011-01-02 13:14:15 UTC").to_i
26
+
27
+ d.run do
28
+ d.emit({"a" => 1})
29
+ end
30
+
31
+ assert_equal [
32
+ {"a" => 1, d.instance.config["field_name"] => {"a" => 1}.to_s}
33
+ ], d.records
34
+
35
+ d.run
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-to_js
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - dixen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Plugin that adds whole record to to_s field, json format
56
+ email:
57
+ - dixentw@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - fluent-plugin-to_s.gemspec
68
+ - lib/fluent/plugin/parse_to_j.rb
69
+ - test/helper.rb
70
+ - test/plugin/test_out_to_s.rb
71
+ homepage: https://github.com/dixentw/fluent-plugin-to_s
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.14
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Plugin that adds whole record to to_s field, json format
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/plugin/test_out_to_s.rb