| Class | FileList |
| In: |
lib/facet/filelist.rb
|
| Parent: | Array |
A FileList is essentially an array with a few helper methods defined to make file manipulation a bit easier. It works in a fashion similar to Dir.glob.
require 'trix/filelist'
fl = FileList.new
fl.include('./**/*')
fl.exclude('./*~')
| VERSION | = | '1.0.0' |
| DEFAULT_IGNORE_PATTERNS | = | [ /(^|[\/\\])CVS([\/\\]|$)/, /\.bak$/, /~$/, /(^|[\/\\])core$/ |
Create a file list from the globbable patterns given. If you wish to perform multiple includes or excludes at object build time, use the "yield self" pattern.
Example:
file_list = FileList.new['lib/**/*.rb', 'test/test*.rb']
pkg_files = FileList.new['lib/**/*'] do |fl|
fl.exclude(/\bCVS\b/)
end
Set the ignore patterns back to the default value. The default patterns will ignore files
Note that file names beginning with "." are automatically ignored by Ruby’s glob patterns and are not specifically listed in the ignore patterns.
Register a list of file name patterns that should be excluded from the list. Patterns may be regular expressions, glob patterns or regular strings.
Note that glob patterns are expanded against the file system. If a file is explicitly added to a file list, but does not exist in the file system, then an glob pattern in the exclude list will not exclude the file.
Examples:
FileList['a.c', 'b.c'].exclude("a.c") => ['b.c']
FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c']
If "a.c" is a file, then …
FileList['a.c', 'b.c'].exclude("a.*") => ['b.c']
If "a.c" is not a file, then …
FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c']
Return a new FileList with the results of running gsub against each element of the original list.
Example:
FileList['lib/test/file', 'x/y'].gsub(/\//, "\\")
=> ['lib\\test\\file', 'x\\y']
Add file names defined by glob patterns to the file list. If an array is given, add each element of the array.
Example:
file_list.include("*.java", "*.cfg")
file_list.include %w( math.c lib.h *.o )
Return a new FileList with the results of running sub against each element of the oringal list.
Example:
FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o']