logstash-output-xls 0.1.0

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: c89222ad3d52151ce10eacfa2197b57cfba60aa4
4
+ data.tar.gz: a35fddd5d3056c9f55bee6656ba663aad6f6d476
5
+ SHA512:
6
+ metadata.gz: ac7e9ae94f2ac458f6a65b6fe02ac1ddec28c21ae884081223ce9eea5994a212a64af59891f6c083404f63b883091ae3b6f254e1957a13074ba10706fd971272
7
+ data.tar.gz: aa4e73339ebdd2c2cfe70d63cb39ba50b7287ca0e1060dde88601836d1b7ce6f03939601529d29695c1530b96651994f8e702aa729a690108a564a552a198df3
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ .ruby-version
3
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,96 @@
1
+ require "logstash/outputs/base"
2
+ require "logstash/namespace"
3
+ require "spreadsheet"
4
+
5
+ # A null output. This is useful for testing logstash inputs and filters for
6
+ # performance.
7
+ class LogStash::Outputs::Xls < LogStash::Outputs::Base
8
+ config_name "xls"
9
+
10
+ default :codec, "xls"
11
+
12
+ # The format to use when writing events to the file. This value
13
+ # supports any string and can include %{name} and other dynamic
14
+ # strings.
15
+ #
16
+ # If this setting is omitted, the full json representation of the
17
+ # event will be written as a single line.
18
+ config :message_format, :validate => :string
19
+
20
+ # The path to the file to write. Event fields can be used here,
21
+ # like "/var/log/logstash/%{host}/%{application}"
22
+ # One may also utilize the path option for date-based log
23
+ # rotation via the joda time format. This will use the event
24
+ # timestamp.
25
+ # E.g.: path => "./test-%{+YYYY-MM-dd}.txt" to create
26
+ # ./test-2013-05-29.txt
27
+ config :path, :validate => :string
28
+
29
+ public
30
+ def register
31
+ @files = {}
32
+
33
+ @codec.on_event do |event|
34
+ if @path
35
+ path = event.sprintf(@path)
36
+ else
37
+ path = event["path"]
38
+ end
39
+
40
+ workbook = open(path)
41
+
42
+ if event.is_a? LogStash::Event and @message_format
43
+ output = event.sprintf(@message_format)
44
+ else
45
+ output = event["message"]
46
+ end
47
+
48
+ cells = output.split(/;/)
49
+
50
+ wsname = event["wsname"]
51
+
52
+ if(workbook.worksheet(wsname).nil?)
53
+ sheet = workbook.create_worksheet :name => wsname
54
+ else
55
+ sheet = workbook.worksheet wsname
56
+ end
57
+
58
+ row_index = sheet.row_count == 0 ? 0 : sheet.last_row_index + 1
59
+ cells.each do |cell|
60
+ sheet.row(row_index).push cell
61
+ end
62
+ end
63
+ end # def register
64
+
65
+ public
66
+ def receive(event)
67
+ @codec.encode(event)
68
+
69
+ if event.include? "tags" and event["tags"].include?("eof")
70
+ flush event['path']
71
+ end
72
+ end # def event
73
+
74
+ private
75
+ def open(path)
76
+ return @files[path] if @files.include?(path) and not @files[path].nil?
77
+ @logger.info("Opening file", :path => path)
78
+
79
+ dir = File.dirname(path)
80
+ if !Dir.exists?(dir)
81
+ @logger.info("Creating directory", :directory => dir)
82
+ FileUtils.mkdir_p(dir)
83
+ end
84
+
85
+ @files[path] = Spreadsheet::Workbook.new
86
+ end
87
+
88
+ public
89
+ def flush(path)
90
+ @files.each do |path, workbook|
91
+ if(File.basename(path) == File.basename(path))
92
+ workbook.write path
93
+ end
94
+ end
95
+ end
96
+ end # class LogStash::Outputs::Xls
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-output-xls'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Output to xls"
7
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Signify"]
9
+ s.email = 'dietmar@signifydata.com'
10
+ s.homepage = "http://www.signifydata.com"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_runtime_dependency "spreadsheet", ["~> 0.9.7"]
26
+
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
29
+
@@ -0,0 +1,5 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require 'logstash/outputs/xls'
3
+
4
+ describe LogStash::Outputs::Xls do
5
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-xls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Signify
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '>='
17
+ - !ruby/object:Gem::Version
18
+ version: 1.4.0
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 0.9.7
39
+ name: spreadsheet
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.9.7
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: logstash-devutils
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
62
+ email: dietmar@signifydata.com
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - .gitignore
68
+ - Gemfile
69
+ - LICENSE
70
+ - Rakefile
71
+ - lib/logstash/outputs/xls.rb
72
+ - logstash-output-xls.gemspec
73
+ - spec/outputs/xls_spec.rb
74
+ homepage: http://www.signifydata.com
75
+ licenses:
76
+ - Apache License (2.0)
77
+ metadata:
78
+ logstash_plugin: 'true'
79
+ logstash_group: output
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.1.9
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Output to xls
100
+ test_files:
101
+ - spec/outputs/xls_spec.rb