Class: Middleman::CoreExtensions::Data::FileLoader::JsonFileLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-core/core_extensions/data/file_loader.rb

Overview

Load json files

Instance Method Summary collapse

Instance Method Details

#load(file) ⇒ Object

Parameters:

  • file (Pathname)


34
35
36
37
38
39
# File 'lib/middleman-core/core_extensions/data/file_loader.rb', line 34

def load(file)
  JSON.parse(file.read)
rescue => e
  $stderr.puts %(Loading data file "#{file}" failed due to an error: #{e.message})
  {}
end

#match?(file) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/middleman-core/core_extensions/data/file_loader.rb', line 29

def match?(file)
  '.json' == File.extname(file)
end