Sha256: 39967ad594cb1b29f51da3b91c0a0db07e59b8e26e1867ed6eb6ca39d7a4c73a
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Fluent class Format class Format # Initialize # # @param [IO|String] config_dev def initialize(config_dev) @config_dev = config_dev end # Format config # # @return [String] the formatted config def run config = read_config(@config_dev) indent_config(config) end private # partial copy from lib/fluent/config.rb def read_config(dev) if dev.respond_to?(:read) # IO object parse_config(dev, '-', '-') else File.open(dev) {|io| parse_config(io, File.basename(dev), File.dirname(dev)) } end 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.2.0 | lib/fluent/format/format.rb |