diff --git a/lib/pdk/validate/metadata/metadata_syntax_validator.rb b/lib/pdk/validate/metadata/metadata_syntax_validator.rb index 44801a563..54f09ad36 100644 --- a/lib/pdk/validate/metadata/metadata_syntax_validator.rb +++ b/lib/pdk/validate/metadata/metadata_syntax_validator.rb @@ -22,15 +22,6 @@ def invoke(report) JSON.parser = JSON::Ext::Parser if defined?(JSON::Ext::Parser) end - def before_validation - # The pure ruby JSON parser gives much nicer parse error messages than - # the C extension at the cost of slightly slower parsing. We require it - # here and restore the C extension at the end of the method (if it was - # being used). - require 'json/pure' - JSON.parser = JSON::Pure::Parser - end - def validate_target(report, target) unless PDK::Util::Filesystem.readable?(target) report.add_event( @@ -56,9 +47,7 @@ def validate_target(report, target) rescue JSON::ParserError => e # Because the message contains a raw segment of the file, we use # String#dump here to unescape any escape characters like newlines. - # We then strip out the surrounding quotes and the exclaimation - # point that json_pure likes to put in exception messages. - sane_message = e.message.dump[/\A"(.+?)!?"\Z/, 1] + sane_message = e.message.dump report.add_event( file: target, diff --git a/pdk.gemspec b/pdk.gemspec index af33328ac..4374ec258 100644 --- a/pdk.gemspec +++ b/pdk.gemspec @@ -47,7 +47,6 @@ Gem::Specification.new do |spec| # Other deps spec.add_runtime_dependency 'deep_merge', '~> 1.2.2' spec.add_runtime_dependency 'diff-lcs', '>= 1.5.0' - spec.add_runtime_dependency 'json', '< 2.8.0' spec.add_runtime_dependency 'pathspec', '~> 1.1' spec.add_runtime_dependency 'puppet_forge', '~> 5.0' diff --git a/spec/support/file_based_namespaces.rb b/spec/support/file_based_namespaces.rb index f530ffb91..73961a2cf 100644 --- a/spec/support/file_based_namespaces.rb +++ b/spec/support/file_based_namespaces.rb @@ -197,7 +197,7 @@ context 'when there is no data stored' do it 'serializes to an empty JSON object' do - expect(serialized_data).to match(/^\{\n+\}$/) + expect(serialized_data).to match(/^\{\}$/) end end diff --git a/spec/unit/pdk/validate/metadata/metadata_syntax_validator_spec.rb b/spec/unit/pdk/validate/metadata/metadata_syntax_validator_spec.rb index f5065c267..ce1d7dee7 100644 --- a/spec/unit/pdk/validate/metadata/metadata_syntax_validator_spec.rb +++ b/spec/unit/pdk/validate/metadata/metadata_syntax_validator_spec.rb @@ -78,7 +78,7 @@ source: 'metadata-syntax', state: :failure, severity: 'error', - message: a_string_matching(/\Aexpected ':' in object/) + message: a_string_matching(/unexpected token at/) }) expect(return_value).to eq(1) end