Sha256: c52769dc5e03b2c6e3d75451662854d489dff49f5760f2b6768e6941093a8f08

Contents?: true

Size: 972 Bytes

Versions: 3

Compression:

Stored size: 972 Bytes

Contents

require 'yaml'

# Read the .yml file containing the configuration values
class Settings
  
  attr_reader :solr_url, :solrj_jar_dir, :log_level, :log_file
  
  def initialize(settings_group)
    yml = YAML.load_file('lib/config/settings.yml')[settings_group]
    @solr_url = yml["solr_url"]
    @solrj_jar_dir = yml["solrj_jar_dir"]
    @log_level = yml["log_level"]
    @log_file = yml["log_file"]
  end
  
  # @return the attributes of this class as a Hash
  def as_hash
    {:solr_url => @solr_url,
      :solrj_jar_dir => @solrj_jar_dir,
      :log_level => get_log_level, 
      :log_file => @log_file
       }
  end
  
  def get_log_level
    case (@log_level)
      when "debug"
        logger_level = Logger::DEBUG
      when "warn"
        logger_level = Logger::WARN
      when "error"
        logger_level = Logger::ERROR
      when "fatal"
        logger_level = Logger::FATAL
      else
        logger_level = Logger::INFO
    end
    logger_level
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solrj_wrapper-1.1.0 lib/solrj_wrapper/settings.rb
solrj_wrapper-1.0.2 lib/solrj_wrapper/settings.rb
solrj_wrapper-1.0.1 lib/solrj_wrapper/settings.rb