Class: Kafkat::Config
- Inherits:
-
Object
- Object
- Kafkat::Config
- Defined in:
- lib/kafkat/config.rb
Defined Under Namespace
Classes: NotFoundError, ParseError
Constant Summary collapse
- CONFIG_PATHS =
[ '~/.kafkatcfg', '/etc/kafkatcfg' ]
Instance Attribute Summary collapse
-
#kafka_path ⇒ Object
readonly
Returns the value of attribute kafka_path.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#zk_path ⇒ Object
readonly
Returns the value of attribute zk_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(json) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(json) ⇒ Config
Returns a new instance of Config.
39 40 41 42 43 |
# File 'lib/kafkat/config.rb', line 39 def initialize(json) @kafka_path = json['kafka_path'] @log_path = json['log_path'] @zk_path = json['zk_path'] end |
Instance Attribute Details
#kafka_path ⇒ Object (readonly)
Returns the value of attribute kafka_path.
11 12 13 |
# File 'lib/kafkat/config.rb', line 11 def kafka_path @kafka_path end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
12 13 14 |
# File 'lib/kafkat/config.rb', line 12 def log_path @log_path end |
#zk_path ⇒ Object (readonly)
Returns the value of attribute zk_path.
13 14 15 |
# File 'lib/kafkat/config.rb', line 13 def zk_path @zk_path end |
Class Method Details
.load! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kafkat/config.rb', line 15 def self.load! string = nil e = nil CONFIG_PATHS.each do |rel_path| begin path = File.(rel_path) string = File.read(path) break rescue => e end end raise e if e && string.nil? json = JSON.parse(string) self.new(json) rescue Errno::ENOENT raise NotFoundError rescue JSON::JSONError raise ParseError end |