module SgtnClient

Constants

DEFAULT_LOCALES
MAP_LOCALES

Public Class Methods

configure(options = {}, &block) click to toggle source
# File lib/sgtn-client/sgtn-client.rb, line 16
def configure(options = {}, &block)
SgtnClient::Config.configure(options, &block)
end
load(*args) click to toggle source
# File lib/sgtn-client/sgtn-client.rb, line 21
def load(*args)
      # load configuration file
      begin
        SgtnClient::Config.load(args[0], args[1])
        SgtnClient::ValidateUtil.validate_config()
      rescue => exception
        file = File.open('./error.log', 'a')
        file.sync = true
        log = Logger.new(file)
        log.error exception.message
      end

      # create log file
      file = './sgtnclient_d.log'
      if args[2] != nil
            file = args[2]
      end
      file = File.open(file, 'a')
      file.sync = true
      SgtnClient.logger = Logger.new(file)

      # Set log level for sandbox mode
      env = SgtnClient::Config.default_environment
      mode = SgtnClient::Config.configurations[env]["mode"]
      SgtnClient.logger.info "Current mode is: " + mode
      if mode == 'sandbox'
            SgtnClient.logger.level = Logger::DEBUG
      else 
            SgtnClient.logger.level = Logger::INFO
      end

      # initialize cache
      disable_cache = SgtnClient::Config.configurations[env]["disable_cache"]
      if disable_cache != nil
            SgtnClient::Core::Cache.initialize(disable_cache)
      else
            SgtnClient::Core::Cache.initialize()
      end
end
logger() click to toggle source
# File lib/sgtn-client/sgtn-client.rb, line 61
def logger
      SgtnClient::Config.logger
end
logger=(log) click to toggle source
# File lib/sgtn-client/sgtn-client.rb, line 65
def logger=(log)
      SgtnClient::Config.logger = log
end