<commit_before>dir = Pathname(__FILE__).dirname.expand_path

require dir / 'core_ext' / 'object'
require dir / 'user'
require dir / 'resume'
require dir / 'message'
require dir / 'helpers'


class Sinatra::Reloader < Rack::Reloader
  def safe_load(file, mtime, stderr=$stderr)
    if file == __FILE__
      ::JibJob::App.reset!
    end
    super
  end
end

module JibJob
  class App < Sinatra::Base
    @@_app_config = YAML.load_file(File.expand_path("#{File.dirname(__FILE__)}/../../config.yml")).freeze
    
    # Default config
    set :app_file, __FILE__
    set :root, File.dirname(__FILE__) + "/../.."
    set :views, Proc.new { File.join(File.dirname(__FILE__), "views") }
    enable :methodoverride, :logging
    set :cookie_domain, Proc.new { @@_app_config[environment][:cookie_domain] }
    set :cookie_secret, Proc.new { @@_app_config[environment][:cookie_secret] }
    set :noreply_email, Proc.new { @@_app_config[environment][:email][:noreply] }
    set :recaptcha_pubkey, Proc.new { @@_app_config[environment][:recaptcha][:public_key] }
    set :recaptcha_privkey, Proc.new { @@_app_config[environment][:recaptcha][:private_key] }
    
    db_config = @@_app_config[environment][:db]
    DataMapper.setup(:default, db_config)
    
    # Production config
    configure :production do      
      error do
        "Application Error: Something went wrong"
      end
    end
    
    # Development config
    configure :development do
      require 'ruby-debug'
      
      enable :show_exceptions, :static, :dump_errors
      set :public, Proc.new { File.join(root, "static") }
      use Sinatra::Reloader, 0
      use Rack::Lint    
    end
    
    # Test config
    configure :test do
      # There is no Rack::Flash in testing, so do not test flash
      # in controllers and views yet
      def flash
        {}
      end
    end
    
    # Helpers
    helpers JibJob::Helpers

    # Racks
    configure :development, :production do
      use Rack::Session::Cookie, :key => "jibjob.session",
                                 :domain => self.cookie_domain,
                                 :path => "/",
                                 :expire_after => 3600 * 8,
                                 :secret => self.cookie_secret
      use Rack::Flash
    end

    # Before filter
    before do
    end
    
    # 404 Handler
    not_found do
      haml :"404"
    end
    
    # Stylesheet<commit_msg>Set session expiry to 24 hours<commit_after>dir = Pathname(__FILE__).dirname.expand_path

require dir / 'core_ext' / 'object'
require dir / 'user'
require dir / 'resume'
require dir / 'message'
require dir / 'helpers'


class Sinatra::Reloader < Rack::Reloader
  def safe_load(file, mtime, stderr=$stderr)
    if file == __FILE__
      ::JibJob::App.reset!
    end
    super
  end
end

module JibJob
  class App < Sinatra::Base
    @@_app_config = YAML.load_file(File.expand_path("#{File.dirname(__FILE__)}/../../config.yml")).freeze
    
    # Default config
    set :app_file, __FILE__
    set :root, File.dirname(__FILE__) + "/../.."
    set :views, Proc.new { File.join(File.dirname(__FILE__), "views") }
    enable :methodoverride, :logging
    set :cookie_domain, Proc.new { @@_app_config[environment][:cookie_domain] }
    set :cookie_secret, Proc.new { @@_app_config[environment][:cookie_secret] }
    set :noreply_email, Proc.new { @@_app_config[environment][:email][:noreply] }
    set :recaptcha_pubkey, Proc.new { @@_app_config[environment][:recaptcha][:public_key] }
    set :recaptcha_privkey, Proc.new { @@_app_config[environment][:recaptcha][:private_key] }
    
    db_config = @@_app_config[environment][:db]
    DataMapper.setup(:default, db_config)
    
    # Production config
    configure :production do      
      error do
        "Application Error: Something went wrong"
      end
    end
    
    # Development config
    configure :development do
      require 'ruby-debug'
      
      enable :show_exceptions, :static, :dump_errors
      set :public, Proc.new { File.join(root, "static") }
      use Sinatra::Reloader, 0
      use Rack::Lint    
    end
    
    # Test config
    configure :test do
      # There is no Rack::Flash in testing, so do not test flash
      # in controllers and views yet
      def flash
        {}
      end
    end
    
    # Helpers
    helpers JibJob::Helpers

    # Racks
    configure :development, :production do
      use Rack::Session::Cookie, :key => "jibjob.session",
                                 :domain => self.cookie_domain,
                                 :path => "/",
                                 :expire_after => 3600 * 24,
                                 :secret => self.cookie_secret
      use Rack::Flash
    end

    # Before filter
    before do
    end
    
    # 404 Handler
    not_found do
      haml :"404"
    end
    
    # Stylesheet
{'fraction_non_alphanumeric': 0.1145919208573784, 'fraction_numerical': 0.005564715581203627, 'mean_word_length': 2.346896551724138, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1601412', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1498, 'n_words': 358}