lib/pdk/config/json_with_schema.rb in pdk-2.7.1 vs lib/pdk/config/json_with_schema.rb in pdk-3.0.0
- old
+ new
@@ -6,10 +6,11 @@
# Parses a JSON document with a schema.
#
# @see PDK::Config::Namespace.parse_file
def parse_file(filename)
raise unless block_given?
+
data = load_data(filename)
data = '{}' if data.nil? || data.empty?
require 'json'
@raw_data = ::JSON.parse(data)
@@ -17,13 +18,10 @@
begin
# Ensure the parsed document is actually valid
validate_document!(@raw_data)
rescue ::JSON::Schema::ValidationError => e
- raise PDK::Config::LoadError, 'The configuration file %{filename} is not valid: %{message}' % {
- filename: filename,
- message: e.message,
- }
+ raise PDK::Config::LoadError, format('The configuration file %{filename} is not valid: %{message}', filename: filename, message: e.message)
end
schema_property_names.each do |key|
yield key, PDK::Config::JSONSchemaSetting.new(key, self, @raw_data[key])
end