class Middleman::CoreExtensions::Data::DataObject

def data_for_path(path)

def data_for_path(path)
  response = nil
  
  @@local_sources ||= {}
  @@callback_sources ||= {}
  
  if @@local_sources.has_key?(path.to_s)
    response = @@local_sources[path.to_s]
  elsif @@callback_sources.has_key?(path.to_s)
    response = @@callback_sources[path.to_s].call()
  else
    file_path = File.join(@app.root, @app.data_dir, "#{path}.yml")
    if File.exists? file_path
      response = YAML.load_file(file_path) 
    else
      file_path = File.join(@app.root, @app.data_dir, "#{path}.yaml")
      if File.exists? file_path
        response = YAML.load_file(file_path)
      else
        file_path = File.join(@app.root, @app.data_dir, "#{path}.json")
        response = ActiveSupport::JSON.decode(File.read(file_path)) if File.exists? file_path
      end
    end
  end
  
  response
end