Class: Del::Configuration
- Inherits:
-
Object
- Object
- Del::Configuration
- Defined in:
- lib/del/configuration.rb
Overview
This is used to contain all configuration.
Constant Summary collapse
- SOCKET_FILE =
'/tmp/del.sock'
Instance Attribute Summary collapse
- #default_rooms ⇒ Object
- #host ⇒ Object
- #jid ⇒ Object
- #logger ⇒ Object
- #muc_domain ⇒ Object
- #name ⇒ Object
- #password ⇒ Object
-
#router ⇒ Object
Returns the value of attribute router.
- #socket_file ⇒ Object
-
#users ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
-
#initialize(settings = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #load(file) ⇒ Object
Constructor Details
#initialize(settings = {}) ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 |
# File 'lib/del/configuration.rb', line 18 def initialize(settings = {}) @settings = settings @router = DefaultRouter.new @users = Repository.new(mapper: User) end |
Instance Attribute Details
#default_rooms ⇒ Object
57 58 59 |
# File 'lib/del/configuration.rb', line 57 def default_rooms @default_rooms ||= settings.fetch(:rooms, []) end |
#host ⇒ Object
28 29 30 |
# File 'lib/del/configuration.rb', line 28 def host @host ||= settings.fetch(:host, 'chat.hipchat.com') end |
#jid ⇒ Object
24 25 26 |
# File 'lib/del/configuration.rb', line 24 def jid @jid ||= settings.fetch(:jid) end |
#logger ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/del/configuration.rb', line 44 def logger @logger ||= begin x = Logger.new(STDOUT) x.level = settings.fetch(:log_level, Logger::INFO).to_i x end end |
#muc_domain ⇒ Object
32 33 34 |
# File 'lib/del/configuration.rb', line 32 def muc_domain @muc_domain ||= settings.fetch(:muc_domain, 'conf.hipchat.com') end |
#name ⇒ Object
36 37 38 |
# File 'lib/del/configuration.rb', line 36 def name @name ||= settings.fetch(:full_name) end |
#password ⇒ Object
40 41 42 |
# File 'lib/del/configuration.rb', line 40 def password @password ||= settings.fetch(:password) end |
#router ⇒ Object
Returns the value of attribute router.
7 8 9 |
# File 'lib/del/configuration.rb', line 7 def router @router end |
#socket_file ⇒ Object
53 54 55 |
# File 'lib/del/configuration.rb', line 53 def socket_file @socket_file ||= settings.fetch(:socket_file, SOCKET_FILE) end |
#users ⇒ Object
Returns the value of attribute users.
8 9 10 |
# File 'lib/del/configuration.rb', line 8 def users @users end |
Instance Method Details
#load(file) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/del/configuration.rb', line 61 def load(file) return if file.nil? return Kernel.load(file) if File.exist?(file) download(file) end |