Sha256: b67701a4e63a3a2491d0540991fad7f401911079cf984a598cbf5eacbd4b2c29

Contents?: true

Size: 846 Bytes

Versions: 23

Compression:

Stored size: 846 Bytes

Contents

require 'fluent/config'

class Fluentd
  module Setting
    class Config
      attr_reader :fl_config, :file
      delegate :elements, to: :fl_config

      def initialize(config_file)
        @fl_config = Fluent::Config.parse(IO.read(config_file), config_file, nil, true)
        @file = config_file
      end

      def empty?
        elements.length.zero?
      end

      def sources
        elements.find_all do |elm|
          elm.name == "source"
        end
      end

      def matches
        elements.find_all do |elm|
          elm.name == "match"
        end
      end

      def write_to_file
        return unless Fluentd.instance
        Fluentd.instance.agent.config_write formatted
      end

      def formatted
        fl_config.to_s.gsub(/<\/?ROOT>/, "").strip_heredoc.gsub(%r|^</.*?>$|, "\\0\n")
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
fluentd-ui-1.0.1 app/models/fluentd/setting/config.rb
fluentd-ui-1.0.0 app/models/fluentd/setting/config.rb
fluentd-ui-1.0.0.beta.1 app/models/fluentd/setting/config.rb
fluentd-ui-1.0.0.alpha.3 app/models/fluentd/setting/config.rb
fluentd-ui-1.0.0.alpha.2 app/models/fluentd/setting/config.rb
fluentd-ui-1.0.0.alpha.1 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.5 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.4 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.3 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.2 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.1 app/models/fluentd/setting/config.rb
fluentd-ui-0.4.0 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.21 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.20 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.19 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.18 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.17 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.16 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.15 app/models/fluentd/setting/config.rb
fluentd-ui-0.3.14 app/models/fluentd/setting/config.rb