Core libraries and tools part for pro architecture. It's a submodule - use from this perspective http://git.maniak.pro/madmaniak/pro
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
644 B

module PathsResolver
def self.resolve(kind, blacklist: [], sort: false)
@paths.map{ |paths_group|
paths = paths_group.select{ |path| path =~ /#{kind}$/ }
if blacklist.any?
paths.reject!{ |path| path =~ /(#{blacklist.join('|')})/ }
end
if sort
paths.sort_by!{ |path|
parts = path.split("/")
[ ( sort == :leafs_first ? -parts.size : parts.size ) , parts.last ]
}
else paths end
}.flatten
end
def self.load
@paths = [ Dir["services/**/*"], Dir["components/**/*"], Dir["app/**/*"] ]
end
def self.free
@paths = nil
end
end
PathsResolver.load