Class: HAProxy::Parser
- Inherits:
-
Object
- Object
- HAProxy::Parser
- Defined in:
- lib/haproxy/parser.rb
Overview
Responsible for reading an HAProxy config file and building an HAProxy::Config instance.
Constant Summary collapse
- Error =
Raised when an error occurs during parsing.
Class.new(StandardError)
- SERVER_ATTRIBUTE_NAMES_1_3 =
haproxy 1.3
%w{ addr backup check cookie disabled fall id inter fastinter downinter maxconn maxqueue minconn port redir rise slowstart source track weight }
- SERVER_ATTRIBUTE_NAMES_1_4 =
Added in haproxy 1.4
%w{error-limit observe on-error}
- SERVER_ATTRIBUTE_NAMES =
SERVER_ATTRIBUTE_NAMES_1_3 + SERVER_ATTRIBUTE_NAMES_1_4
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#parse_result ⇒ Object
Returns the value of attribute parse_result.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse(config_text) ⇒ Object
- #parse_file(filename) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Parser
Returns a new instance of Parser.
18 19 20 21 22 23 24 |
# File 'lib/haproxy/parser.rb', line 18 def initialize( = nil) ||= {} = { :verbose => false }.merge() self. = self.verbose = [:verbose] end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
16 17 18 |
# File 'lib/haproxy/parser.rb', line 16 def @options end |
#parse_result ⇒ Object
Returns the value of attribute parse_result.
16 17 18 |
# File 'lib/haproxy/parser.rb', line 16 def parse_result @parse_result end |
#verbose ⇒ Object
Returns the value of attribute verbose.
16 17 18 |
# File 'lib/haproxy/parser.rb', line 16 def verbose @verbose end |
Instance Method Details
#parse(config_text) ⇒ Object
31 32 33 34 35 |
# File 'lib/haproxy/parser.rb', line 31 def parse(config_text) result = parse_config_text(config_text) self.parse_result = result build_config(result) end |
#parse_file(filename) ⇒ Object
26 27 28 29 |
# File 'lib/haproxy/parser.rb', line 26 def parse_file(filename) config_text = File.read(filename) self.parse(config_text) end |