Sha256: 4b264d451eb19c9834ddd282d21593f3ef187a50742e79632240c296a778d156
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 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 # # @raise Fluent::ConfigParseError if conf has syntax errors # @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.1 | lib/fluent/format/format.rb |