Guard against classify nil data

This commit is contained in:
Joshua Peek
2012-06-21 11:47:32 -05:00
parent 3d7364877d
commit 2b712dc790
2 changed files with 5 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ module Linguist
# Returns sorted Array of result pairs. Each pair contains the
# Language and a Float score.
def classify(tokens, languages = @languages.keys)
return [] if tokens.nil?
tokens = Tokenizer.new(tokens).tokens if tokens.is_a?(String)
scores = {}