Class: Ordit::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/ordit/files.rb

Class Method Summary collapse

Class Method Details

.allObject



5
6
7
# File 'lib/ordit/files.rb', line 5

def self.all
  run
end

.runObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ordit/files.rb', line 9

def self.run
  Ordit.configuration.controller_paths.flat_map do |path_pattern|
    base_dir = path_pattern.split("/*").first
    
    Dir.glob(path_pattern).select do |file|
      # Only filter by controller pattern if we're finding all files
      file.match?(%r{[^/]*_?controller\.(js|ts)$})
    end.map do |file|
      Pathname.new(file).relative_path_from(Pathname.new(base_dir)).to_s
    end
  end.uniq
end