Skip to content

Commit

Permalink
In CLI Reuse prefixes established when reading when serializing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 23, 2021
1 parent ed7439d commit 0fb0185
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rdf/cli.rb
Expand Up @@ -256,8 +256,7 @@ def to_hash
lambda: ->(argv, opts) do
writer_class = RDF::Writer.for(opts[:output_format]) || RDF::NTriples::Writer
out = opts[:output]
opts = opts.merge(prefixes: {})
writer_opts = opts.merge(standard_prefixes: true)
writer_opts = {prefixes: {}, standard_prefixes: true}.merge(opts)
writer_class.new(out, **writer_opts) do |writer|
writer << repository
end
Expand Down Expand Up @@ -536,6 +535,8 @@ def self.exec(args, output: $stdout, option_parser: nil, messages: {}, **options
count = 0
self.parse(args, **options) do |reader|
reader.each_statement {|st| @repository << st}
# Remember prefixes from reading
options[:prefixes] ||= reader.prefixes
end
secs = Time.new - start
options[:logger].info "Parsed #{repository.count} statements with #{@readers.join(', ')} in #{secs} seconds @ #{count/secs} statements/second."
Expand Down

0 comments on commit 0fb0185

Please sign in to comment.