mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-08 12:28:47 +00:00
Extract empty blob strategy
This commit is contained in:
@@ -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
|
||||
|
||||
10
lib/linguist/strategy/empty_blob.rb
Normal file
10
lib/linguist/strategy/empty_blob.rb
Normal file
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user