Method: Roby::Application#load_all_model_files_in

Defined in:
lib/roby/app.rb

#load_all_model_files_in(prefix_name, ignored_exceptions: []) ⇒ Object



1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
# File 'lib/roby/app.rb', line 1935

def load_all_model_files_in(prefix_name, ignored_exceptions: [])
    search_path = auto_load_search_path
    dirs = find_dirs(
        "models", prefix_name,
        path: search_path,
        all: true,
        order: :specific_last
    )

    dirs.each do |dir|
        all_files = Set.new
        Find.find(dir) do |path|
            # Skip the robot-specific bits that don't apply on the
            # selected robot
            if File.directory?(path)
                suffix = File.basename(File.dirname(path))
                if robots.has_robot?(suffix) && ![robot_name, robot_type].include?(suffix)
                    Find.prune
                end
            end

            if File.file?(path) && path =~ /\.rb$/
                all_files << path
            end
        end

        all_files.each do |path|
            begin
                require(path)
            rescue *ignored_exceptions => e
                ::Robot.warn "ignored file #{path}: #{e.message}"
            end
        end
    end
end