]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/common/filesystem.rb
1 # Convenience methods for working with the filesystem. This class
2 # only provides static methods, to be used analogously to the File
3 # class (for example, <tt>File.directory?</tt>).
7 # Return whether or not the given path begins with a dot (ASCII
10 # @param path [String] the path whose first character you want to check.
12 # @return [Boolean] whether or not *path* begins with an ASCII period.
14 def self.begins_with_dot
?(path
)
15 return (path
[0..0] == '.')
19 # Get a list of all real subdirectories of the given directory.
21 # @param dir [String] the directory whose subdirectories you want.
23 # @return [Array<String>] a list of subdirectories of *dir*, not
24 # including the pseudo-directories "." and ".." (the current/parent
27 def self.get_subdirs(dir
)
29 return subdirs
if not File
.directory
?(dir
)
33 relative_path
= File
.join(dir
, entry
)
34 if File
.directory
?(relative_path
) and not self.begins_with_dot
?(entry
)