fluent-plugin-imagefile 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/fluent-plugin-imagefile.gemspec +26 -0
- data/lib/fluent/plugin/out_imagefile.rb +45 -0
- data/spec/lib/fluent/plugin/imagefile.jpg +0 -0
- data/spec/lib/fluent/plugin/out_imagefile_spec.rb +68 -0
- data/spec/spec_helper.rb +25 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 80bd3ae30af071184ae5d2f2e04acaca839b8f6e
|
4
|
+
data.tar.gz: f978d330298e86fd3b5d2967a8c9e0ff7863c8fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae3343f1369e2b41887ac59d9d7c3d704e0591f57398836b1489debc9da3633686ae7d691ee76cb104514887d2ae6c499e4bf59406ba1061494a30eccf0e833c
|
7
|
+
data.tar.gz: 0e5443af2e39ca725bcd088cce79c72010fc00ef30c397a80013625b65ac5c5d7a595f1d0156eb08a9630023b4048f3883cb9b69b5ad7f0925260cfbd4b4e839
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# fluent-plugin-imagefile
|
2
|
+
|
3
|
+
## Output
|
4
|
+
|
5
|
+
Output plugin to save image file from massages attribute value
|
6
|
+
|
7
|
+
### Configure Example
|
8
|
+
|
9
|
+
````
|
10
|
+
type iamgefile
|
11
|
+
save_dir SAVE_DIR
|
12
|
+
filename_key filename_field
|
13
|
+
extension jpg
|
14
|
+
image_key image_field
|
15
|
+
base64encoded false
|
16
|
+
````
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
1. Fork it
|
21
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
22
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
23
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
24
|
+
5. Create new Pull Request
|
25
|
+
|
26
|
+
## releases
|
27
|
+
|
28
|
+
- 2014/01/25 0.0.1 Release gem
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -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-imagefile"
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["bash0C7"]
|
9
|
+
spec.email = ["koshiba+github@4038nullpointer.com"]
|
10
|
+
spec.description = "Output plugin to save image file from massages attribute value"
|
11
|
+
spec.summary = "Output plugin to save image file from massages attribute value"
|
12
|
+
spec.homepage = "https://github.com/bash0C7/fluent-plugin-imagefile"
|
13
|
+
spec.license = "Ruby's"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "fluentd"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rr"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class Fluent::ImageFileOutput < Fluent::Output
|
5
|
+
Fluent::Plugin.register_output('imagefile', self)
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
config_param :save_dir, :string
|
12
|
+
config_param :filename_key, :string
|
13
|
+
config_param :extension, :string
|
14
|
+
config_param :image_key, :string
|
15
|
+
config_param :base64encoded, :bool
|
16
|
+
|
17
|
+
def configure(conf)
|
18
|
+
super
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
super
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def shutdown
|
28
|
+
super
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def emit(tag, es, chain)
|
33
|
+
es.each {|time,record|
|
34
|
+
file_fullpath = File.join(@save_dir, "#{record[@filename_key]}.#{@extension}")
|
35
|
+
|
36
|
+
media = record[@image_key]
|
37
|
+
media = Base64.decode64(media) if @base64encoded
|
38
|
+
|
39
|
+
File.open(file_fullpath, 'wb') {|file| file.write(media)}
|
40
|
+
}
|
41
|
+
|
42
|
+
chain.next
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe do
|
4
|
+
let(:driver) {Fluent::Test::OutputTestDriver.new(Fluent::ImageFileOutput, 'test.metrics').configure(config)}
|
5
|
+
let(:save_imagefiles_dir) {File.join(File.dirname(__FILE__), 'saveimages')}
|
6
|
+
|
7
|
+
let(:instance) {driver.instance}
|
8
|
+
let(:record) {{ 'filename_field' => save_filename, 'image_field' => image_file}}
|
9
|
+
let(:time) {0}
|
10
|
+
let(:emit) {
|
11
|
+
d = driver
|
12
|
+
d.emit(record, Time.at(time))
|
13
|
+
d.run
|
14
|
+
}
|
15
|
+
|
16
|
+
before do
|
17
|
+
FileUtils.rm_rf(save_imagefiles_dir)
|
18
|
+
Dir.mkdir(save_imagefiles_dir)
|
19
|
+
end
|
20
|
+
|
21
|
+
after do
|
22
|
+
FileUtils.rm_rf(save_imagefiles_dir)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'emit' do
|
26
|
+
context 'base64encoded_false' do
|
27
|
+
let(:image_file) {File.open(File.join(File.dirname(__FILE__), 'imagefile.jpg'), 'rb').read}
|
28
|
+
let(:save_filename) {'savefile1'}
|
29
|
+
|
30
|
+
let(:config) {
|
31
|
+
%[
|
32
|
+
save_dir #{save_imagefiles_dir}
|
33
|
+
filename_key filename_field
|
34
|
+
extension jpg
|
35
|
+
image_key image_field
|
36
|
+
base64encoded false
|
37
|
+
]
|
38
|
+
}
|
39
|
+
|
40
|
+
it do
|
41
|
+
emit
|
42
|
+
File.exists?(File.join(save_imagefiles_dir, 'savefile1.jpg')).should be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'base64encoded_true' do
|
47
|
+
let(:image_file) {Base64.encode64(File.open(File.join(File.dirname(__FILE__), 'imagefile.jpg'), 'rb').read)}
|
48
|
+
let(:save_filename) {'savefile2'}
|
49
|
+
|
50
|
+
let(:config) {
|
51
|
+
%[
|
52
|
+
save_dir #{save_imagefiles_dir}
|
53
|
+
filename_key filename_field
|
54
|
+
extension jpg
|
55
|
+
image_key image_field
|
56
|
+
base64encoded true
|
57
|
+
]
|
58
|
+
}
|
59
|
+
|
60
|
+
it do
|
61
|
+
emit
|
62
|
+
File.exists?(File.join(save_imagefiles_dir, 'savefile2.jpg')).should be_true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
|
18
|
+
require 'fluent/load'
|
19
|
+
require 'fluent/test'
|
20
|
+
|
21
|
+
require 'fluent/plugin/out_imagefile'
|
22
|
+
|
23
|
+
require 'pry'
|
24
|
+
require 'rr'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-imagefile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- bash0C7
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-25 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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Output plugin to save image file from massages attribute value
|
98
|
+
email:
|
99
|
+
- koshiba+github@4038nullpointer.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- fluent-plugin-imagefile.gemspec
|
110
|
+
- lib/fluent/plugin/out_imagefile.rb
|
111
|
+
- spec/lib/fluent/plugin/imagefile.jpg
|
112
|
+
- spec/lib/fluent/plugin/out_imagefile_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
homepage: https://github.com/bash0C7/fluent-plugin-imagefile
|
115
|
+
licenses:
|
116
|
+
- Ruby's
|
117
|
+
metadata: {}
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 2.0.5
|
135
|
+
signing_key:
|
136
|
+
specification_version: 4
|
137
|
+
summary: Output plugin to save image file from massages attribute value
|
138
|
+
test_files:
|
139
|
+
- spec/lib/fluent/plugin/imagefile.jpg
|
140
|
+
- spec/lib/fluent/plugin/out_imagefile_spec.rb
|
141
|
+
- spec/spec_helper.rb
|