From 3d7c9ab1ed695f86fb731ddc9268eb5b202c7fe5 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 27 May 2011 12:11:48 -0500 Subject: [PATCH] Raise an error if paths isn't an array or hash --- lib/linguist/repository.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 536f825c..787e8312 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -20,13 +20,16 @@ module Linguist # # Returns a Repository def initialize(paths) - if paths.is_a?(Array) + case paths + when Array @paths = paths.inject({}) do |h, blob| h[blob.name] = blob h end - else + when Hash @paths = paths + else + raise ArgumentError, "#{paths.class} is not an Array or Hash" end @computed_stats = false