Module: Lsd::DirectoryLister
- Defined in:
- lib/lsd/directory_lister.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
- FILE_PRIORITY =
1
- DIRECTORY_PRIORITY =
0
Class Method Summary collapse
Class Method Details
.list(path = ".") ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lsd/directory_lister.rb', line 8 def self.list(path = ".") entries = Dir.entries(path) .reject { |entry| entry.start_with?(".") } .sort_by { |name| [File.directory?(name) ? DIRECTORY_PRIORITY : FILE_PRIORITY, name.downcase] } .map { |name| Entry.new(name) } puts TableFormatter.format(entries) rescue Errno::EACCES raise Error, "Permission denied: #{path}" end |