# encoding: utf-8 module LocalPac @config_semaphore = Mutex.new @logger_semaphore = Mutex.new @routing_semaphore = Mutex.new class << self attr_reader :config_semaphore attr_reader :logger_semaphore attr_reader :routing_semaphore attr_accessor :debug_mode def config config_semaphore.synchronize do @config ||= LocalPac::Config.new end end def config=(config) @config = config end def ui_logger(local_logger = LocalPac::UiLogger.new) logger_semaphore.synchronize do @ui_logger ||= local_logger end end def error_id SecureRandom.hex end def routing routing_semaphore.synchronize do @routing ||= Rack::Builder.new do require_relative ::File.expand_path('../../../app/controllers/application_controller.rb', __FILE__) Dir.glob(::File.expand_path('../../../app/controllers/*.rb', __FILE__)).each { |f| require_relative f } map '/' do run LocalPac::App::FileServeController end map '/v1/pac/' do run LocalPac::App::FileServeController end map '/v1/lookup/' do run LocalPac::App::LookupController end map LocalPac::App::ApplicationController.assets_prefix do run LocalPac::App::ApplicationController.assets end end end end end end