Differentiate between identically named repositories

This commit is contained in:
Adam Sanderson 2011-01-01 14:07:07 -07:00
parent 320133c4a5
commit b16af67f73
2 changed files with 14 additions and 3 deletions

View File

@ -18,9 +18,20 @@ module Qwandry
packages.concat(repo.scan(pattern))
end
differentiate packages
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)

View File

@ -1,8 +1,8 @@
module Qwandry
class Package
attr_reader :name
attr_reader :paths
attr_reader :repository
attr_accessor :name
attr_accessor :paths
attr_reader :repository
def initialize(name, paths, repository)
@name = name