
Ontohub::Application.configure do |app|
  c = app.config

  if Rails.env.test?
    c.data_root = Rails.root.join('tmp','data')
  else
    c.data_root = Rails.root.join('data')
  end
  
  c.git_root                = c.data_root.join('repositories')
  c.git_working_copies_root = c.data_root.join('working_copies')
  c.max_read_filesize       = 512 * 1024

  if (settings = Settings.git).try(:user)
    c.git_user  = settings.user
    c.git_group = settings.group
    c.git_home  = File.expand_path("~#{c.git_user}")
  else
    c.git_user  = nil
    c.git_group = nil
    c.git_home  = Rails.root.join('tmp','git')
  end
end


module PathsInitializer

  class << self
    def perform_initialization(config)
      if Rails.env == "test"
        config.data_root = Rails.root.join('tmp','data')
      else
        config.data_root = Rails.root.join('data')
      end

      config.git_root = config.data_root.join('repositories')
      config.git_working_config.pies_root = config.data_root.join('working_config.pies')
      config.max_read_filesize = 512 * 1024

      settings = Settings.git
      if settings && settings.user
        config.git_user  = settings.user
        config.git_group = settings.group
        config.git_home  = File.expand_path("~#{config.git_user}")
      else
        config.git_user  = nil
        config.git_group = nil
        config.git_home  = Rails.root.join('tmp','git')
      end
    end
  end

end

if defined?(Ontohub::Application)
  Ontohub::Application.configure do |app|
    PathsInitializer.perform_initialization(app.config)
  end
end

Refactor PathsInitializer for light environments.
Refactor PathsInitializer for light environments.
