rdf-turtle 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 499e06e63d69ec0216db2600e34260d5eda5c7a3736e8f1a42c63a91c716779c
4
- data.tar.gz: 3443fdb3e53d2b12d66f6a9534a9532dabde58b0b319ecc62ffff0a4bd87afb3
3
+ metadata.gz: a2739fecb539c03eacd39c93e7c002ee32f9b6b49f8786d2119150d1a57cd236
4
+ data.tar.gz: b72813794b2c80e8b518aaa151740f26a55017074555823fdd14dfbe181efc7f
5
5
  SHA512:
6
- metadata.gz: 1cad03d53fb973b02f541168549cc110769fde86da3b37c1a6187d7fbfffe8bee3f72bea687d14786094ad0cb6a2cd7d4f2072c9989ec4d0c62b6ad81020bccd
7
- data.tar.gz: 1e7f38e3f561a6f16304727fa89b2bbeab0b93b31e8e5a58633f533ba69e2a874e461f59bcf31d015d23382290e33b9b2ecfd007691fe6f5dc0961c98ca0d285
6
+ metadata.gz: 43ad711bd729dcabcdf0e3e07006fed39f7a31fbe074513777e1dcaec358bb373a1e77e31fd8bb5761ebf487efa0e2aa94cccc2311ffa135534fdabdf4654aa7
7
+ data.tar.gz: dc7bafb1ff5ba905b85982b6514e65da5bdf1b1e2fd1f0813ee4678f3e174cf20871087c73f7c1a2a52d65e3d07058d26be31cc8d6ea92dfd315f81e904647b9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.0.4
@@ -86,11 +86,9 @@ module RDF::Turtle
86
86
  super do
87
87
  @options = {
88
88
  anon_base: "b0",
89
- validate: false,
90
89
  whitespace: WS,
91
90
  log_depth: 0,
92
- }.merge(options)
93
- @options = {prefixes: {nil => ""}}.merge(@options) unless @options[:validate]
91
+ }.merge(@options)
94
92
  @prod_stack = []
95
93
 
96
94
  @options[:base_uri] = RDF::URI(base_uri || "")
@@ -178,7 +176,7 @@ module RDF::Turtle
178
176
  value = RDF::URI(iri)
179
177
  value = base_uri.join(value) if value.relative?
180
178
  value.validate! if validate?
181
- value.canonicalize! if canonicalize?
179
+ value.canonicalize! if canonicalize? && !value.frozen?
182
180
  value = RDF::URI.intern(value) if intern?
183
181
  value
184
182
  rescue ArgumentError => e
@@ -214,11 +212,13 @@ module RDF::Turtle
214
212
  # Expand a PNAME using string concatenation
215
213
  def pname(prefix, suffix)
216
214
  # Prefixes must be defined, except special case for empty prefix being alias for current @base
217
- if prefix(prefix)
218
- base = prefix(prefix).to_s
219
- elsif !prefix(prefix)
215
+ base = if prefix(prefix)
216
+ prefix(prefix).to_s
217
+ elsif prefix.to_s.empty? && !validate?
218
+ base_uri.to_s
219
+ else
220
220
  error("undefined prefix", production: :pname, token: prefix)
221
- base = ''
221
+ ''
222
222
  end
223
223
  suffix = suffix.to_s.sub(/^\#/, "") if base.index("#")
224
224
  log_debug("pname") {"base: '#{base}', suffix: '#{suffix}'"}
@@ -366,8 +366,8 @@ module RDF::Turtle
366
366
  seen[st.object] if @lists.has_key?(st.object)
367
367
  end
368
368
 
369
- # List elements should not be targets for top-level serialization
370
- list_elements = @lists.values.map(&:to_a).flatten.compact
369
+ # List elements which are bnodes should not be targets for top-level serialization
370
+ list_elements = @lists.values.map(&:to_a).flatten.select(&:node?).compact
371
371
 
372
372
  # Sort subjects by resources over bnodes, ref_counts and the subject URI itself
373
373
  recursable = (@subjects.keys - list_elements).
@@ -504,12 +504,15 @@ module RDF::Turtle
504
504
  list = @lists[l]
505
505
  log_debug("do_list") {list.inspect}
506
506
  subject_done(RDF.nil)
507
+ index = 0
507
508
  list.each_statement do |st|
508
509
  next unless st.predicate == RDF.first
509
510
  log_debug {" list this: #{st.subject} first: #{st.object}[#{position}]"}
511
+ @output.write(" ") if index > 0
510
512
  path(st.object, position)
511
513
  subject_done(st.subject)
512
514
  position = :object
515
+ index += 1
513
516
  end
514
517
  end
515
518
 
@@ -519,7 +522,7 @@ module RDF::Turtle
519
522
  return false if position == :object && prop_count(node) > 0
520
523
  #log_debug("collection") {"#{node.to_ntriples}, #{position}"}
521
524
 
522
- @output.write(position == :subject ? "(" : " (")
525
+ @output.write("(")
523
526
  log_depth {do_list(node, position)}
524
527
  @output.write(')')
525
528
  end
@@ -530,16 +533,20 @@ module RDF::Turtle
530
533
 
531
534
  log_debug("blankNodePropertyList") {resource.to_ntriples}
532
535
  subject_done(resource)
533
- @output.write(position == :subject ? "\n#{indent} [" : ' [')
536
+ @output.write(position == :subject ? "\n#{indent} [" : '[')
534
537
  num_props = log_depth {predicateObjectList(resource, true)}
535
- @output.write((num_props > 1 ? "\n#{indent}" : "") + (position == :object ? ']' : '] .'))
538
+ @output.write((num_props > 1 ? "\n#{indent(2)}" : "") + (position == :object ? ']' : '] .'))
536
539
  true
537
540
  end
538
541
 
539
542
  # Default singular resource representation.
540
543
  def p_term(resource, position)
541
544
  #log_debug("p_term") {"#{resource.to_ntriples}, #{position}"}
542
- l = (position == :subject ? "" : " ") + format_term(resource, options)
545
+ l = if resource == RDF.nil
546
+ "()"
547
+ else
548
+ format_term(resource, options)
549
+ end
543
550
  @output.write(l)
544
551
  end
545
552
 
@@ -562,7 +569,7 @@ module RDF::Turtle
562
569
  def predicate(resource)
563
570
  log_debug("predicate") {resource.to_ntriples}
564
571
  if resource == RDF.type
565
- @output.write(" a")
572
+ @output.write("a")
566
573
  else
567
574
  path(resource, :predicate)
568
575
  end
@@ -601,6 +608,7 @@ module RDF::Turtle
601
608
  begin
602
609
  @output.write(";\n#{indent(2)}") if i > 0
603
610
  predicate(RDF::URI.intern(prop))
611
+ @output.write(" ")
604
612
  objectList(properties[prop])
605
613
  end
606
614
  end
@@ -611,8 +619,9 @@ module RDF::Turtle
611
619
  def triples(subject)
612
620
  @output.write("\n#{indent}")
613
621
  path(subject, :subject)
614
- predicateObjectList(subject)
615
- @output.write(" .")
622
+ @output.write(" ")
623
+ num_props = predicateObjectList(subject)
624
+ @output.write("#{num_props > 0 ? ' ' : ''}.")
616
625
  true
617
626
  end
618
627
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-turtle
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-22 00:00:00.000000000 Z
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -194,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubyforge_project:
198
- rubygems_version: 2.7.6
197
+ rubygems_version: 3.0.2
199
198
  signing_key:
200
199
  specification_version: 4
201
200
  summary: Turtle reader/writer for Ruby.