Class: Fluent::S3Input::LZOExtractor

Inherits:
Extractor
  • Object
show all
Defined in:
lib/fluent/plugin/s3_extractor_lzo.rb

Instance Attribute Summary

Attributes inherited from Extractor

#log

Instance Method Summary collapse

Methods inherited from Extractor

#initialize

Constructor Details

This class inherits a constructor from Fluent::S3Input::Extractor

Instance Method Details

#configure(conf) ⇒ Object



9
10
11
12
# File 'lib/fluent/plugin/s3_extractor_lzo.rb', line 9

def configure(conf)
  super
  check_command('lzop', 'LZO')
end

#content_typeObject



18
19
20
# File 'lib/fluent/plugin/s3_extractor_lzo.rb', line 18

def content_type
  'application/x-lzop'.freeze
end

#extObject



14
15
16
# File 'lib/fluent/plugin/s3_extractor_lzo.rb', line 14

def ext
  'lzo'.freeze
end

#extract(io) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fluent/plugin/s3_extractor_lzo.rb', line 22

def extract(io)
  path = if io.respond_to?(path)
           io.path
         else
           temp = Tempfile.new("lzop-temp")
           temp.write(io.read)
           temp.close
           temp.path
         end

  stdout, succeeded = Open3.capture2("lzop #{@command_parameter} #{path}")
  if succeeded
    stdout
  else
    raise "Failed to extract #{path} with lzop command."
  end
end