From d6dd27d9fad340044636c0d02550571e4cc81b4f Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Tue, 15 Jul 2025 13:41:46 -0700 Subject: [PATCH] Don't use canonicalize option to trigger writing VERSION, just use the absence of a version option. Otherwise, canonicalize will modify literals and IRIs to their canonical form. --- lib/rdf/ntriples/writer.rb | 2 +- spec/nquads_spec.rb | 4 ++-- spec/ntriples_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rdf/ntriples/writer.rb b/lib/rdf/ntriples/writer.rb index 3f098ba6..12d8cff1 100644 --- a/lib/rdf/ntriples/writer.rb +++ b/lib/rdf/ntriples/writer.rb @@ -217,7 +217,7 @@ def initialize(output = $stdout, validate: true, **options, &block) # @return [self] # @abstract def write_prologue - puts %(VERSION #{version.inspect}) if version && !canonicalize? + puts %(VERSION #{version.inspect}) if version @logged_errors_at_prolog = log_statistics[:error].to_i super end diff --git a/spec/nquads_spec.rb b/spec/nquads_spec.rb index 988de0cc..04f89c18 100644 --- a/spec/nquads_spec.rb +++ b/spec/nquads_spec.rb @@ -322,9 +322,9 @@ end.to write(%(VERSION "1.2")) end - it "does not write version with :version and :canonicalize options" do + it " not write version with unless specified" do expect do - described_class.new($stdout, version: "1.2", canonicalize: true) do |w| + described_class.new($stdout, version: nil) do |w| w.insert(graph) end end.not_to write(%(VERSION "1.2")) diff --git a/spec/ntriples_spec.rb b/spec/ntriples_spec.rb index 3a9294ea..85617e0d 100644 --- a/spec/ntriples_spec.rb +++ b/spec/ntriples_spec.rb @@ -931,9 +931,9 @@ end.to write(%(VERSION "1.2")) end - it "does not write version with :version and :canonicalize options" do + it "does not write version with unless specified" do expect do - writer.new($stdout, version: "1.2", canonicalize: true) do |w| + writer.new($stdout, version: nil) do |w| w.insert(graph) end end.not_to write(%(VERSION "1.2"))