Method: Roby::Application#find_base_path_for
- Defined in:
- lib/roby/app.rb
#find_base_path_for(path) ⇒ nil, String
Returns the path in search_path that contains the given file or path
2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 |
# File 'lib/roby/app.rb', line 2914 def find_base_path_for(path) if @find_base_path_rx_paths != search_path @find_base_path_rx = search_path .map { |app_dir| [Pathname.new(app_dir), app_dir, %r{(^|/)#{app_dir}(/|$)}] } .sort_by { |_, app_dir, _| app_dir.size } .reverse @find_base_path_rx_paths = search_path.dup end longest_prefix_path, = @find_base_path_rx.find do |app_path, app_dir, rx| (path =~ rx) || ((path[0] != "/") && File.file?(File.join(app_dir, path))) end longest_prefix_path end |