fluent-plugin-google-sheets 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +41 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fluent-plugin-google-sheets.gemspec +26 -0
- data/lib/fluent/plugin/out_google_sheets.rb +48 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 688f1cdc00554c3aa687502b679381e5f2e8237c
|
4
|
+
data.tar.gz: 24e23c085c4e78f13cb64a92b4f018f20d5d0e22
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa1c47142c4388646fb31ce002be9184c6946ab2ceb6dfe902fed41927f6dd7253dfe68c2841c6ae8589c45cb4fcc7482d93a5a339f8b155c250740d35616c9a
|
7
|
+
data.tar.gz: 338da024298632daeadfee3f58b6c686abdca9469ee912972f85c0d4f92efb557b0314ade569f5149d483bd7d4cf27b8454b720939f2d29ac6be5460f6e8b97c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# fluent-plugin-google-sheets
|
2
|
+
|
3
|
+
Fluentd output plugin to store data on Google Sheets.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluent-plugin-google-sheets'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fluent-plugin-google-sheets
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
<match example>
|
25
|
+
@type google_sheets
|
26
|
+
|
27
|
+
credential_file_path path_to_your_service_account_credential
|
28
|
+
spreadsheet_id your_spreadsheet_id
|
29
|
+
</match>
|
30
|
+
```
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fluent-plugin-google-sheets.
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluent/plugin/google/sheets"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: 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 |spec|
|
6
|
+
spec.name = "fluent-plugin-google-sheets"
|
7
|
+
spec.version = '0.1.0'
|
8
|
+
spec.authors = ["Fumiaki MATSUSHIMA"]
|
9
|
+
spec.email = ["mtsmfm@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Fluentd output plugin to store data on Google Sheets.}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/esminc/fluent-plugin-google-sheets"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd"
|
21
|
+
spec.add_dependency "google_drive"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'google_drive'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Fluent
|
5
|
+
class GoogleSheetsOutput < BufferedOutput
|
6
|
+
Fluent::Plugin.register_output('google_sheets', self)
|
7
|
+
|
8
|
+
config_param :credential_file_path, :string
|
9
|
+
config_param :spreadsheet_id, :string
|
10
|
+
config_param :keys, default: [] do |val|
|
11
|
+
val.split(',')
|
12
|
+
end
|
13
|
+
|
14
|
+
def format(tag, time, record)
|
15
|
+
[tag, Time.at(time).strftime('%F %T'), record].to_json + "\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
def write(chunk)
|
19
|
+
data = chunk.read.each_line.map {|line| JSON.parse(line) }.group_by {|tag, *| tag }
|
20
|
+
|
21
|
+
data.each do |tag, xs|
|
22
|
+
ws = worksheet(tag)
|
23
|
+
ws.insert_rows(ws.num_rows + 1, xs.map {|_, time, record| [time] + record.values })
|
24
|
+
ws.save
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def headers
|
31
|
+
%w(timestamp) + @keys
|
32
|
+
end
|
33
|
+
|
34
|
+
def worksheet(tag)
|
35
|
+
spreadsheet.worksheet_by_title(tag) || spreadsheet.add_worksheet(tag).tap do |ws|
|
36
|
+
ws.insert_rows(1, [headers])
|
37
|
+
ws.save
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def spreadsheet
|
42
|
+
@spreadsheet ||= begin
|
43
|
+
session = GoogleDrive::Session.from_service_account_key(@credential_file_path)
|
44
|
+
session.spreadsheet_by_key(@spreadsheet_id)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-google-sheets
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fumiaki MATSUSHIMA
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: google_drive
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
description: Fluentd output plugin to store data on Google Sheets.
|
84
|
+
email:
|
85
|
+
- mtsmfm@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/console
|
96
|
+
- bin/setup
|
97
|
+
- fluent-plugin-google-sheets.gemspec
|
98
|
+
- lib/fluent/plugin/out_google_sheets.rb
|
99
|
+
homepage: https://github.com/esminc/fluent-plugin-google-sheets
|
100
|
+
licenses: []
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.5.1
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Fluentd output plugin to store data on Google Sheets.
|
122
|
+
test_files: []
|