fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehasemodule PathsInitializer
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa DEFAULT_PATHS = {git_repositories: 'repositories',
f55fc9b4d9bf2d78c5c7fac976c948d618c24e5dEugen Kuksa git_daemon: 'git_daemon',
6bbb71b52f053c148669e5b128e236781150da1fEugen Kuksa git_ssh: 'git_ssh',
b193b60354ad3bef7d3783b3bf676a5641362358Eugen Kuksa commits: 'commits'}
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehase class << self
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa def expand(path)
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa Dir.chdir(Rails.root) { Pathname.new(path).expand_path }
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa end
2f0eba71c311b096362f3603d17addad30213c4dEugen Kuksa
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa def cleanup_release(path)
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa path.sub(%r(/releases/\d+/), "/current/")
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa end
f3dde587c4b53acccfb18816316bb0dc5bb4da68Eugen Kuksa
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))
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa end
016150e0d029b39900111b1b20fcc89614754608Eugen Kuksa
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 end
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa
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 Reddehase end
369d8bc42b0aa41d482fbd14df38ed945ad66af3Julian Kornberger end
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehaseend
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehase
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehaseif defined?(Ontohub::Application)
fe5c95e87c0b8ac2ec38d701ba402020e0ecf88aTim Reddehase Ontohub::Application.configure do |app|
dc71c45bda7a6ff016d1b1fe78bc68b9236ad1e9Eugen Kuksa PathsInitializer.empty_initialization(app.config)
43b3e7c742a93b0a02f38afc10e81b5eb0b33bc6Julian Kornberger end
369d8bc42b0aa41d482fbd14df38ed945ad66af3Julian Kornbergerend