Sha256: 91becf02abf1564ad75a140abb982d3f85709341a39d795275bba5e6ec4b4a91
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'fluent/load' module Fluent class Format class << self def format_config(dev) config = if dev.respond_to?(:read) # IO object parse_config(dev, '-', '-') else read_config(dev) end indent_config(config) end private # partial copy from lib/fluent/config.rb def read_config(path) File.open(path) {|io| parse_config(io, File.basename(path), File.dirname(path)) } end # partial copy from lib/fluent/config.rb def parse_config(io, fname, basepath=Dir.pwd) if fname =~ /\.rb$/ Fluent::Config::DSL::Parser.parse(io, File.join(basepath, fname)) else Fluent::Config.parse(io, fname, basepath) end end # hmm, ugly workaround def indent_config(conf) lines = conf.to_s.split("\n")[1..-2] # remove <ROOT> and </ROOT> lines = lines.map {|line| line[2..-1] } # remove heading 2 white spaces lines.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-format-0.1.1 | lib/fluent/format.rb |