mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Don't crash if classifier data is missing
This commit is contained in:
@@ -5,6 +5,10 @@ module Linguist
|
|||||||
class Classifier
|
class Classifier
|
||||||
PATH = File.expand_path('../classifier.yml', __FILE__)
|
PATH = File.expand_path('../classifier.yml', __FILE__)
|
||||||
|
|
||||||
|
def self.exist?
|
||||||
|
File.exist?(PATH)
|
||||||
|
end
|
||||||
|
|
||||||
def self.instance
|
def self.instance
|
||||||
@instance ||= YAML.load_file(PATH)
|
@instance ||= YAML.load_file(PATH)
|
||||||
end
|
end
|
||||||
@@ -61,5 +65,5 @@ module Linguist
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Eager load instance
|
# Eager load instance
|
||||||
Classifier.instance
|
Classifier.instance if Classifier.exist?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user