Method: Roby::Application#find_files_in_dirs
- Defined in:
- lib/roby/app.rb
#find_files_in_dirs(*path, options) ⇒ Array<String>
Enumerates the files that are present in subdirectories of paths in #search_path. The subdirectories are resolved using File.join(*path) If one of the elements of the path is the string ‘ROBOT’, it gets replaced by the robot name and type.
Given a search dir of [app1, app2]
app1/models/tasks/goto.rb
app1/models/tasks/v3/goto.rb
app2/models/tasks/asguard/goto.rb
2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 |
# File 'lib/roby/app.rb', line 2637 def find_files_in_dirs(*dir_path) return [] if search_path.empty? Application.debug { "find_files_in_dirs(#{dir_path.map(&:inspect).join(', ')})" } if dir_path.last.kind_of?(Hash) = dir_path.pop end = Kernel.( || {}, :all, :order, :path, prioritize_root_paths: false, pattern: Regexp.new("") ) dir_search = dir_path.dup dir_search << { all: true, order: [:order], path: [:path], prioritize_root_paths: [:prioritize_root_paths] } search_path = find_dirs(*dir_search) result = [] search_path.each do |dirname| Application.debug { " dir: #{dirname}" } Dir.new(dirname).each do |file_name| file_path = File.join(dirname, file_name) Application.debug { " file: #{file_path}" } if File.file?(file_path) && [:pattern] === file_name Application.debug " added" result << file_path end end break unless [:all] end result end |