45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/pdk/module/metadata.rb', line 45
def self.from_file(metadata_json_path)
unless File.file?(metadata_json_path)
raise ArgumentError, _("'%{file}' does not exist or is not a file.") % { file: metadata_json_path }
end
unless File.readable?(metadata_json_path)
raise ArgumentError, _("Unable to open '%{file}' for reading.") % { file: metadata_json_path }
end
begin
data = JSON.parse(File.read(metadata_json_path))
rescue JSON::JSONError => e
raise ArgumentError, _('Invalid JSON in metadata.json: %{msg}') % { msg: e.message }
end
new(data)
end
|