require 'formula'
require 'tab'
require 'set'

module Homebrew extend self
  def leaves
    installed = Formula.installed
    deps_of_installed = Set.new

    installed.each do |f|
      deps = []

      f.deps.each do |dep|
        if dep.optional? || dep.recommended?
          tab = Tab.for_formula(f)
          deps << dep.name if tab.with?(dep.name)
        else
          deps << dep.name
        end
      end

      deps_of_installed.merge(deps)
    end

    installed.each do |f|
      puts f.name unless deps_of_installed.include? f.name
    end
  end
end

require 'formula'
require 'tab'
require 'set'

module Homebrew extend self
  def leaves
    installed = Formula.installed
    deps_of_installed = Set.new

    installed.each do |f|
      deps = []

      f.deps.each do |dep|
        if dep.optional? || dep.recommended?
          tab = Tab.for_formula(f)
          deps << dep.to_formula.name if tab.with?(dep.to_formula.name)
        else
          deps << dep.to_formula.name
        end
      end

      deps_of_installed.merge(deps)
    end

    installed.each do |f|
      puts f.name unless deps_of_installed.include? f.name
    end
  end
end

Use name of formula rather than name of dependency
Use name of formula rather than name of dependency

Closes Homebrew/homebrew#27192.

Signed-off-by: Jack Nagel <43386ce32af96f5c56f2a88e458cb94cebee3751@gmail.com>
