Class: Homebrew::Cmd::PrettyListing Private

Inherits:
Object
  • Object
show all
Defined in:
cmd/list.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PrettyListing

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns a new instance of PrettyListing.



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'cmd/list.rb', line 215

def initialize(path)
  Pathname.new(path).children.sort_by { |p| p.to_s.downcase }.each do |pn|
    case pn.basename.to_s
    when "bin", "sbin"
      pn.find { |pnn| puts pnn unless pnn.directory? }
    when "lib"
      print_dir pn do |pnn|
        # dylibs have multiple symlinks and we don't care about them
        (pnn.extname == ".dylib" || pnn.extname == ".pc") && !pnn.symlink?
      end
    when ".brew"
      next # Ignore .brew
    else
      if pn.directory?
        if pn.symlink?
          puts "#{pn} -> #{pn.readlink}"
        else
          print_dir pn
        end
      elsif Metafiles.list?(pn.basename.to_s)
        puts pn
      end
    end
  end
end