Module: Syskit::CustomRequire

Defined in:
lib/roby/custom_require.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.resolve(path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/roby/custom_require.rb', line 8

def self.resolve(path)
    match = /^([\w|-]+)\//.match(path)
    return path unless match

    prefix = match[1]
    if (full_path = resolve_from_apps(prefix, path))
        return full_path
    end

    if (full_path = resolve_from_search_path(path))
        return full_path
    end

    path
end

.resolve_from_apps(prefix, path) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/roby/custom_require.rb', line 24

def self.resolve_from_apps(prefix, path)
    app_base_dir = Roby.app.find_registered_app_path(prefix)
    return unless app_base_dir

    full_path = File.join(File.dirname(app_base_dir), path)
    return unless File.file?(full_path) || File.file?("#{full_path}.rb")

    full_path
end

.resolve_from_search_path(path) ⇒ Object



34
35
36
37
38
39
# File 'lib/roby/custom_require.rb', line 34

def self.resolve_from_search_path(path)
    Roby.app.search_path.find do |dir|
        full_path = File.join(dir, path)
        return full_path if File.file?(full_path) || File.file?("#{full_path}.rb")
    end
end