Move Samples::DATA constant to Samples.cache method

This commit is contained in:
Brandon Keepers
2014-09-16 10:18:33 -04:00
parent 156985ed52
commit 015af19eaf
5 changed files with 16 additions and 14 deletions

View File

@@ -17,9 +17,11 @@ module Linguist
PATH = File.expand_path('../samples.json', __FILE__)
# Hash of serialized samples object
if File.exist?(PATH)
serializer = defined?(JSON) ? JSON : YAML
DATA = serializer.load(File.read(PATH))
def self.cache
@cache ||= begin
serializer = defined?(JSON) ? JSON : YAML
serializer.load(File.read(PATH))
end
end
# Public: Iterate over each sample.