From ec37f3b59f5846ce7634c9cbfc8b435fd4698825 Mon Sep 17 00:00:00 2001 From: Adam Sanderson Date: Sat, 1 Jan 2011 14:10:30 -0700 Subject: [PATCH] tidying up. --- lib/qwandry/launcher.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/qwandry/launcher.rb b/lib/qwandry/launcher.rb index 86768ac..1956ecc 100644 --- a/lib/qwandry/launcher.rb +++ b/lib/qwandry/launcher.rb @@ -21,16 +21,6 @@ module Qwandry 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. @@ -49,6 +39,20 @@ module Qwandry # Launch the editor with its options and any paths that we have been passed 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