class Middleman::CoreExtensions::Data::DataStore

def touch_file(file)

Returns:
  • (void) -

Parameters:
  • file (String) -- The file to be re-parsed
def touch_file(file)
  root = Pathname(@app.root)
  full_path = root + file
  extension = File.extname(file)
  basename  = File.basename(file, extension)
  data_path = full_path.relative_path_from(root + @app.config[:data_dir])
  if %w(.yaml .yml).include?(extension)
    data = YAML.load_file(full_path)
  elsif extension == '.json'
    data = ActiveSupport::JSON.decode(full_path.read)
  else
    return
  end
  data_branch = @local_data
  path = data_path.to_s.split(File::SEPARATOR)[0..-2]
  path.each do |dir|
    data_branch[dir] ||= ::Middleman::Util.recursively_enhance({})
    data_branch = data_branch[dir]
  end
  data_branch[basename] = ::Middleman::Util.recursively_enhance(data)
end