All pastes #2073377 Raw Edit

Miscellany

public text v1 · immutable
#2073377 ·published 2011-06-01 20:00 UTC
rendered paste body
def filter(pkgs, name)
	filtered_pkgs = ""
	pkgs.strip!
# need to change next line, want to eleminate spaces and tabs after a colon
	pkgs.gsub(": ", ":")
	pkgs.split(/[, ]+/).map do |package|
		arr = package.split(':')
		if (arr.length == 1 or (arr.length == 2 and arr[0] == name))
			filtered_pkgs = filtered_pkgs + " " + arr[arr.length-1]
		end

	end
	filtered_pkgs
end

puts filter("a deb:b rpm:c d", "deb")
puts filter("a deb:b rpm:c d", "rpm")