tidying up.

This commit is contained in:
Adam Sanderson 2011-01-01 14:10:30 -07:00
parent b16af67f73
commit ec37f3b59f
1 changed files with 15 additions and 11 deletions

View File

@ -22,16 +22,6 @@ module Qwandry
packages
end
def differentiate(packages)
named_groups = Hash.new{|h,k| h[k] = []}
packages.each{|p| named_groups[p.name] << p }
named_groups.each do |name, packages|
if packages.length > 1
packages.each{|p| p.name = "#{p.name} (#{p.paths.first})"}
end
end
end
# Launches a Package or path represented by a String. Unless `editor` will
# check against the environment by default.
def launch(package, editor=nil)
@ -50,5 +40,19 @@ module Qwandry
system(*(editor_and_options + paths))
end
private
# If there are multiple packages named the same, append their path to the name.
# This could later be handled in other ways, for instance by merging the paths.
def differentiate(packages)
named_groups = Hash.new{|h,k| h[k] = []}
packages.each{|p| named_groups[p.name] << p }
named_groups.each do |name, packages|
if packages.length > 1
packages.each{|p| p.name = "#{p.name} (#{p.paths.first})"}
end
end
end
end
end