diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 58881125..17b7ddad 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -93,13 +93,13 @@ module Linguist end require 'linguist/strategy/filename' + require 'linguist/strategy/empty_blob' require 'linguist/strategy/shebang' require 'linguist/strategy/classifier' + STRATEGIES = [ Linguist::Strategy::Filename, - # Don't bother with binary contents or an empty file - lambda {|blob, langauges| [] if blob.data.nil? || blob.data == "" }, - # Check if there's a shebang line and use that as authoritative + Linguist::Strategy::EmptyBlob, Linguist::Strategy::Shebang, Linguist::Heuristics, Linguist::Strategy::Classifier diff --git a/lib/linguist/strategy/empty_blob.rb b/lib/linguist/strategy/empty_blob.rb new file mode 100644 index 00000000..cc30477d --- /dev/null +++ b/lib/linguist/strategy/empty_blob.rb @@ -0,0 +1,10 @@ +module Linguist + module Strategy + class EmptyBlob + def self.call(blob, langauges) + # Don't bother with binary contents or an empty file + [] if blob.data.nil? || blob.data == "" + end + end + end +end diff --git a/lib/linguist/strategy/shebang.rb b/lib/linguist/strategy/shebang.rb index 244e4c85..dd5bc38b 100644 --- a/lib/linguist/strategy/shebang.rb +++ b/lib/linguist/strategy/shebang.rb @@ -1,5 +1,6 @@ module Linguist module Strategy + # Check if there's a shebang line and use that as authoritative class Shebang def self.call(blob, _) Language.find_by_shebang(blob.data)