Class: Fluentd::Agent::Configuration
- Inherits:
-
Object
- Object
- Fluentd::Agent::Configuration
- Includes:
- Enumerable
- Defined in:
- app/models/fluentd/agent/configuration.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #config ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(config_file) ⇒ Configuration
constructor
A new instance of Configuration.
- #matches ⇒ Object
- #sources ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config_file) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 |
# File 'app/models/fluentd/agent/configuration.rb', line 10 def initialize(config_file) @file = config_file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
8 9 10 |
# File 'app/models/fluentd/agent/configuration.rb', line 8 def file @file end |
Instance Method Details
#config ⇒ Object
14 15 16 |
# File 'app/models/fluentd/agent/configuration.rb', line 14 def config @config ||= ::Fluent::Config::V1Parser.parse(File.read(file), File.basename(file), File.dirname(file)) end |
#each(&block) ⇒ Object
22 23 24 |
# File 'app/models/fluentd/agent/configuration.rb', line 22 def each(&block) config.each_element(&block) end |
#matches ⇒ Object
30 31 32 |
# File 'app/models/fluentd/agent/configuration.rb', line 30 def matches find_all{|e| e.name == "match"} end |
#sources ⇒ Object
26 27 28 |
# File 'app/models/fluentd/agent/configuration.rb', line 26 def sources find_all{|e| e.name == "source"} end |
#to_s ⇒ Object
18 19 20 |
# File 'app/models/fluentd/agent/configuration.rb', line 18 def to_s config.to_s.gsub(/\A<ROOT>\n/, "").gsub(/<\/ROOT>\n\z/, "").gsub(/^ {2}/, "") end |