rdf-n3 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rdf/n3/writer.rb +29 -12
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afdac73ba35b42f05afd81b7bda64d6ae2f8ca733d605dc9ba73baa83466f8b0
4
- data.tar.gz: 0ed15e323151966a1244d0e0ad7082ff058e733ec0350200828b4560f0c00e59
3
+ metadata.gz: e1e295c958340c4c0dd8f47583cf716f65d3d2164acdddda485281cb2038c09a
4
+ data.tar.gz: eb2280ffe26460e5eb01e3c99cf330a47a2aa565711679f4c7ddbb4fffcc0546
5
5
  SHA512:
6
- metadata.gz: 1f1bc864db4ccc46228207c6421a2a6961eeab25558f1ca976bf7662fd324e78e87a72b080d5f777c52818a9a9bcc3d38a38eae201e17272da71171f0ade8e58
7
- data.tar.gz: 3f574efe368b1f7564298b95d7a6b7490d3859cf698bac24f139b00d746ffba828ec323a5cafff6bc7a233e9b22b0b8c9c3f2bb86c126af8bde970027a87a320
6
+ metadata.gz: 75ca555fe8e9369e7450fd1631f484ddba0af4ba2d370bfb5710310a1c74636cc78d6f8b64358d5dfd0825707be64b489537d2a6759b91d203e00715bb7b7078
7
+ data.tar.gz: 2179ab00eec3d52700a4d03cfc07d63ec54e6ec84b17fe922f280181d95bac402c627bed85abfe1789e35d15e2d707b5fcb871e379fd61199fa07c99d4a1f420
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.0.1
@@ -273,8 +273,6 @@ module RDF::N3
273
273
  protected
274
274
  # Output @base and @prefix definitions
275
275
  def start_document
276
- @started = true
277
-
278
276
  @output.write("#{indent}@base <#{base_uri}> .\n") unless base_uri.to_s.empty?
279
277
 
280
278
  log_debug {"start_document: #{prefixes.inspect}"}
@@ -317,14 +315,24 @@ module RDF::N3
317
315
 
318
316
  # Add distinguished classes
319
317
  top_classes.each do |class_uri|
320
- graph.query(predicate: RDF.type, object: class_uri).map {|st| st.subject}.sort.uniq.each do |subject|
321
- log_debug {"order_subjects: #{subject.inspect}"}
318
+ graph.query(predicate: RDF.type, object: class_uri).
319
+ map {|st| st.subject}.
320
+ sort.
321
+ uniq.
322
+ each do |subject|
323
+ log_debug("order_subjects") {subject.to_ntriples}
322
324
  subjects << subject
323
325
  seen[subject] = true
324
326
  end
325
327
  end
326
328
  log_debug {"subjects2: #{subjects.inspect}"}
327
-
329
+
330
+ # Mark as seen lists that are part of another list
331
+ @lists.values.map(&:statements).
332
+ flatten.each do |st|
333
+ seen[st.object] if @lists.has_key?(st.object)
334
+ end
335
+
328
336
  # Sort subjects by resources over bnodes, ref_counts and the subject URI itself
329
337
  recursable = @subjects.keys.
330
338
  select {|s| !seen.include?(s)}.
@@ -358,7 +366,17 @@ module RDF::N3
358
366
  references = ref_count(statement.object) + 1
359
367
  @references[statement.object] = references
360
368
  @subjects[statement.subject] = true
361
-
369
+
370
+ # Collect lists
371
+ if statement.predicate == RDF.first
372
+ @lists[statement.subject] = RDF::List.new(subject: statement.subject, graph: graph)
373
+ end
374
+
375
+ if statement.object == RDF.nil || statement.subject == RDF.nil
376
+ # Add an entry for the list tail
377
+ @lists[RDF.nil] ||= RDF::List[]
378
+ end
379
+
362
380
  # Pre-fetch qnames, to fill prefixes
363
381
  get_qname(statement.subject)
364
382
  get_qname(statement.predicate)
@@ -385,12 +403,10 @@ module RDF::N3
385
403
  def reset
386
404
  @depth = 0
387
405
  @lists = {}
388
- @namespaces = {}
406
+
389
407
  @references = {}
390
408
  @serialized = {}
391
409
  @subjects = {}
392
- @shortNames = {}
393
- @started = false
394
410
  end
395
411
 
396
412
  ##
@@ -412,11 +428,11 @@ module RDF::N3
412
428
  # Checks if l is a valid RDF list, i.e. no nodes have other properties.
413
429
  def is_valid_list(l)
414
430
  #log_debug {"is_valid_list: #{l.inspect}"}
415
- return (l.node? && RDF::List.new(subject: l, graph: @graph).valid?) || l == RDF.nil
431
+ return @lists[l] && @lists[l].valid?
416
432
  end
417
433
 
418
434
  def do_list(l)
419
- list = RDF::List.new(subject: l, graph: @graph)
435
+ list = @lists[l]
420
436
  log_debug {"do_list: #{list.inspect}"}
421
437
  position = :subject
422
438
  list.each_statement do |st|
@@ -502,7 +518,8 @@ module RDF::N3
502
518
  properties[st.predicate.to_s] << st.object
503
519
  end
504
520
 
505
- prop_list = sort_properties(properties) - [RDF.first.to_s, RDF.rest.to_s]
521
+ prop_list = sort_properties(properties)
522
+ prop_list -= [RDF.first.to_s, RDF.rest.to_s] if subject.node?
506
523
  log_debug {"predicate_list: #{prop_list.inspect}"}
507
524
  return if prop_list.empty?
508
525
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-n3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-14 00:00:00.000000000 Z
12
+ date: 2018-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.7.3
178
+ rubygems_version: 2.7.6
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Notation3 reader/writer for RDF.rb.