Class: Mebla::Configuration
- Inherits:
-
Object
- Object
- Mebla::Configuration
- Includes:
- Singleton
- Defined in:
- lib/mebla/configuration.rb
Overview
Parses the configuration file and holds important configuration attributes
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#index ⇒ Object
Returns the value of attribute index.
-
#log_dir ⇒ Object
readonly
Returns the value of attribute log_dir.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initializes a new configuration object.
-
#setup_logger ⇒ nil
Sets up the default settings of the logger.
-
#url ⇒ String
Returns the proper url for elasticsearch.
Constructor Details
#initialize ⇒ Configuration
Initializes a new configuration object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mebla/configuration.rb', line 15 def initialize @log_dir = "#{Dir.pwd}/tmp/log" parse_config # Setup defaults @index ||= "mebla" @host ||= "localhost" @port ||= 9200 make_tmp_dir @logger = ActiveSupport::BufferedLogger.new( open("#{@log_dir}/mebla.log", "a") ) @logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG setup_logger # Setup slingshot Slingshot::Configuration.url(self.url) end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
11 12 13 |
# File 'lib/mebla/configuration.rb', line 11 def host @host end |
#index ⇒ Object
Returns the value of attribute index.
11 12 13 |
# File 'lib/mebla/configuration.rb', line 11 def index @index end |
#log_dir ⇒ Object (readonly)
Returns the value of attribute log_dir.
10 11 12 |
# File 'lib/mebla/configuration.rb', line 10 def log_dir @log_dir end |
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/mebla/configuration.rb', line 11 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/mebla/configuration.rb', line 11 def port @port end |
Instance Method Details
#setup_logger ⇒ nil
Sets up the default settings of the logger
38 39 40 |
# File 'lib/mebla/configuration.rb', line 38 def setup_logger @logger.auto_flushing = true end |
#url ⇒ String
Returns the proper url for elasticsearch
44 45 46 |
# File 'lib/mebla/configuration.rb', line 44 def url "http://#{@host}:#{@port}" end |