016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa DEFAULT_PATHS = {git_repositories: 'repositories',
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa def expand(path)
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa Dir.chdir(Rails.root) { Pathname.new(path).expand_path }
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa def cleanup_release(path)
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa path.sub(%r(/releases/\d+/), "/current/")
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa def prepare(path, fallback = nil)
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa path = File.join(Settings.paths.data, fallback) if fallback && path.nil?
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa cleanup_release(expand(path))
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa # Only defines methods to prevent NoMethodErrors
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa # To be called before settings validation.
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa def empty_initialization(config)
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa config.data_root = nil
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa config.git_root = nil
787127631abcd463c471486a393ec0981d3ab9b7Eugen Kuksa config.git_daemon_path = nil
6bbb71b52f053c148669e5b128e236781150da1fEugen Kuksa config.git_ssh_path = nil
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa config.commits_path = nil
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa # Actually performs initialization
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa # To be called after settings validation
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehase def perform_initialization(config)
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa config.data_root = prepare(Settings.paths.data)
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa config.git_root = prepare(Settings.paths.git_repositories, DEFAULT_PATHS[:git_repositories])
787127631abcd463c471486a393ec0981d3ab9b7Eugen Kuksa config.git_daemon_path = prepare(Settings.paths.git_daemon, DEFAULT_PATHS[:git_daemon])
6bbb71b52f053c148669e5b128e236781150da1fEugen Kuksa config.git_ssh_path = prepare(Settings.paths.git_ssh, DEFAULT_PATHS[:git_ssh])
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa config.commits_path = prepare(Settings.paths.commits, DEFAULT_PATHS[:commits])
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehaseif defined?(Ontohub::Application)
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehase Ontohub::Application.configure do |app|
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa PathsInitializer.empty_initialization(app.config)