Method: PDK::Util::VendoredFile#read

Defined in:
lib/pdk/util/vendored_file.rb

#readObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pdk/util/vendored_file.rb', line 33

def read
  return File.read(package_vendored_path) if PDK::Util.package_install?
  return File.read(gem_vendored_path) if File.file?(gem_vendored_path)

  content = download_file

  # TODO: should only write if it's valid JSON
  # TODO: need a way to invalidate if out of date
  FileUtils.mkdir_p(File.dirname(gem_vendored_path))
  write_file(gem_vendored_path, content)
  content
end