fluent-plugin-axlsx 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 +5 -0
- data/LICENSE +22 -0
- data/README.rdoc +37 -0
- data/Rakefile +12 -0
- data/fluent-plugin-axlsx.gemspec +21 -0
- data/lib/fluent/plugin/out_axlsx.rb +80 -0
- data/test/plugin/out_axlsx.rb +36 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 MATSUMOTO Katsuyoshi
|
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.rdoc
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
= Fluent::Plugin::Axlsx
|
2
|
+
|
3
|
+
fluent-plugin-axlsx provides output plugin for fluentd
|
4
|
+
|
5
|
+
= Installation
|
6
|
+
|
7
|
+
$ git clone git://github.com/katsyoshi/fluent-plugin-axlsx.git
|
8
|
+
$ cd fluent-plugin-axlsx
|
9
|
+
$ rake build
|
10
|
+
$ rake install
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
=== Output Configureation
|
15
|
+
|
16
|
+
<match test.xlsx>
|
17
|
+
type axlsx
|
18
|
+
path /path/to/store.xlsx
|
19
|
+
</match>
|
20
|
+
|
21
|
+
= TODO
|
22
|
+
|
23
|
+
- gems
|
24
|
+
- unit test or rspec
|
25
|
+
|
26
|
+
= Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
33
|
+
|
34
|
+
= Copyright
|
35
|
+
|
36
|
+
Copyright:: Copyright (c) 2012- MATSUMOTO Katsuyoshi
|
37
|
+
License:: Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.test_files = Dir['test/plugin/*.rb']
|
7
|
+
t.ruby_opts = ['-rubygems'] if defined? Gem
|
8
|
+
t.ruby_opts << '-I.'
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => [:build]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["MATSUMOTO Katsuyoshi"]
|
6
|
+
gem.email = ["matsumoto.katsuyoshi+github@gmail.com"]
|
7
|
+
gem.description = %q{fluentd output plugin for excel}
|
8
|
+
gem.summary = %q{fluentd output plugin for excel}
|
9
|
+
gem.homepage = "https://github.com/katsyoshi/fluent-plugin-axlsx"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "fluent-plugin-axlsx"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = "0.0.1"
|
17
|
+
|
18
|
+
gem.add_dependency "fluentd"
|
19
|
+
gem.add_dependency "axlsx"
|
20
|
+
gem.add_development_dependency "rake"
|
21
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Fluent
|
2
|
+
|
3
|
+
# The AxlsxOutput class exports fluend emmitions into an OOXML
|
4
|
+
# spreadsheet document (xlsx)
|
5
|
+
class AxlsxOutput < Output
|
6
|
+
|
7
|
+
Plugin.register_output('axlsx', self)
|
8
|
+
|
9
|
+
config_param :path, :string
|
10
|
+
# config_param :worksheets, :string, :default => "main"
|
11
|
+
|
12
|
+
|
13
|
+
# PENDING @see configure TODOconfig_param :keys, :string, :default => nil
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super
|
17
|
+
require 'axlsx'
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure(conf)
|
21
|
+
super
|
22
|
+
# TODO - I like the csv keys idea in the configuration but I think it needs to be tag specific.
|
23
|
+
# e.g. dstat_keys foo, bar, biz.bang, hoge.hoge.hoge
|
24
|
+
# dot notation indicates nested keys
|
25
|
+
@time_format = workbook.styles.add_style :format_code => 'hh:mm:ss'
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
end
|
30
|
+
|
31
|
+
def shutdown
|
32
|
+
end
|
33
|
+
|
34
|
+
def format(tag, time, record)
|
35
|
+
end
|
36
|
+
|
37
|
+
def emit(tag, es, chunk)
|
38
|
+
to_xlsx(tag, es)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def to_xlsx(tag, es)
|
44
|
+
sheet_for(tag).tap do |sheet|
|
45
|
+
sheet.add_row []
|
46
|
+
es.each do |time, record|
|
47
|
+
@column_headers = column_headers | record.keys
|
48
|
+
sheet.add_row record.values.insert(0, time), :style => [@time_format]
|
49
|
+
end
|
50
|
+
# yes, I am cheeting!
|
51
|
+
sheet.rows.first.send :array_to_cells, column_headers
|
52
|
+
end
|
53
|
+
serialize
|
54
|
+
end
|
55
|
+
|
56
|
+
def package
|
57
|
+
@package ||= Axlsx::Package.new
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def column_headers
|
63
|
+
@column_headers ||= ['time']
|
64
|
+
end
|
65
|
+
|
66
|
+
def sheet_for(tag)
|
67
|
+
workbook.sheet_by_name(tag) || workbook.add_worksheet(:name => tag)
|
68
|
+
end
|
69
|
+
|
70
|
+
def serialize
|
71
|
+
@package.serialize(path)
|
72
|
+
end
|
73
|
+
|
74
|
+
def workbook
|
75
|
+
package.workbook
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'lib/fluent/plugin/out_axlsx.rb'
|
4
|
+
|
5
|
+
class AxlsxOutputTest < Test::Unit::TestCase
|
6
|
+
CONFIG = %[
|
7
|
+
path test_output_axlsx.xlsx
|
8
|
+
]
|
9
|
+
|
10
|
+
def create_driver(config=CONFIG, tag='foo')
|
11
|
+
Fluent::Test::OutputTestDriver.new(Fluent::AxlsxOutput).configure(config)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_configuration
|
15
|
+
driver = create_driver
|
16
|
+
assert_equal 'test_output_axlsx.xlsx', driver.instance.path
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def test_emit_creates_worksheet_for_tag
|
21
|
+
driver = create_driver
|
22
|
+
driver.instance.emit('foo', {Time.now => {"message1" => "testing first", "message2" => "testing first another data"}}, nil)
|
23
|
+
assert_equal('foo', driver.instance.send(:package).workbook.worksheets.first.name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_emit_creates_column_headers
|
27
|
+
driver = create_driver
|
28
|
+
driver.instance.emit('bar', {Time.now => {"message1" => "testing first", "message2" => "testing first another data"}}, nil)
|
29
|
+
assert_equal('time', driver.instance.send(:package).workbook.worksheets.first.rows[0].cells[0].value)
|
30
|
+
assert_equal('message1', driver.instance.send(:package).workbook.worksheets.first.rows[0].cells[1].value)
|
31
|
+
assert_equal('message2', driver.instance.send(:package).workbook.worksheets.first.rows[0].cells[2].value)
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-axlsx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- MATSUMOTO Katsuyoshi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
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: axlsx
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
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: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
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 output plugin for excel
|
63
|
+
email:
|
64
|
+
- matsumoto.katsuyoshi+github@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.rdoc
|
73
|
+
- Rakefile
|
74
|
+
- fluent-plugin-axlsx.gemspec
|
75
|
+
- lib/fluent/plugin/out_axlsx.rb
|
76
|
+
- test/plugin/out_axlsx.rb
|
77
|
+
homepage: https://github.com/katsyoshi/fluent-plugin-axlsx
|
78
|
+
licenses: []
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.23
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: fluentd output plugin for excel
|
101
|
+
test_files:
|
102
|
+
- test/plugin/out_axlsx.rb
|