rdf-turtle 3.1.3 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -10
- data/VERSION +1 -1
- data/lib/rdf/turtle/reader.rb +16 -16
- data/lib/rdf/turtle/writer.rb +17 -4
- metadata +16 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b5531c582f4d0cd8d8fda744147e74501bf4efc0c721b1b3cf05a1d2cc60b3
|
4
|
+
data.tar.gz: 61e7f1e122300b7e822d81d9429dfee943a7ef7cfb12bb031f9ff133edd6a263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faad4f256da8872159efeb82c150b30566770ad8fe1fdf504aa2b993b2b8e070192365ecfa5cea8c3f99d0087e3da4b21f0794b17883f17e0a8d6eaac6b82f26
|
7
|
+
data.tar.gz: f3c231a0ba031d14ff8273ec17a134144387626fe0594c6cb7d6b039d3aaac88d673344e8cf5cbb9019c3e3caba62929fa21ed0beb84c79f2896ea03bdd7028f
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/rdf-turtle.png)](https://badge.fury.io/rb/rdf-turtle)
|
6
6
|
[![Build Status](https://github.com/ruby-rdf/rdf-turtle/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf-turtle/actions?query=workflow%3ACI)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-turtle/badge.svg)](https://coveralls.io/github/ruby-rdf/rdf-turtle)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-turtle/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf-turtle?branch=develop)
|
8
8
|
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)
|
9
9
|
|
10
10
|
## Description
|
@@ -17,9 +17,9 @@ Install with `gem install rdf-turtle`
|
|
17
17
|
|
18
18
|
* 100% free and unencumbered [public domain](https://unlicense.org/) software.
|
19
19
|
* Implements a complete parser for [Turtle][].
|
20
|
-
* Compatible with Ruby >= 2.
|
20
|
+
* Compatible with Ruby >= 2.6.
|
21
21
|
* Optional streaming writer, to serialize large graphs
|
22
|
-
* Provisional support for [Turtle
|
22
|
+
* Provisional support for [Turtle-star][RDF-star].
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
Instantiate a reader from a local file:
|
@@ -36,9 +36,9 @@ Write a graph to a file:
|
|
36
36
|
writer << graph
|
37
37
|
end
|
38
38
|
|
39
|
-
## Turtle
|
39
|
+
## Turtle-star (RDF-star)
|
40
40
|
|
41
|
-
Both reader and writer include provisional support for [Turtle
|
41
|
+
Both reader and writer include provisional support for [Turtle-star][RDF-star].
|
42
42
|
|
43
43
|
Internally, an `RDF::Statement` is treated as another resource, along with `RDF::URI` and `RDF::Node`, which allows an `RDF::Statement` to have a `#subject` or `#object` which is also an `RDF::Statement`.
|
44
44
|
|
@@ -88,7 +88,7 @@ where the subject is the the triple ending with that annotation.
|
|
88
88
|
end
|
89
89
|
# => RDF::ReaderError
|
90
90
|
|
91
|
-
Note that this requires the `rdfstar` option to be
|
91
|
+
Note that this requires the `rdfstar` option to be set.
|
92
92
|
|
93
93
|
## Documentation
|
94
94
|
Full documentation available on [Rubydoc.info][Turtle doc]
|
@@ -140,9 +140,9 @@ This version uses a hand-written parser using the Lexer from the [EBNF][] gem in
|
|
140
140
|
|
141
141
|
## Dependencies
|
142
142
|
|
143
|
-
* [Ruby](https://ruby-lang.org/) (>= 2.
|
144
|
-
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.
|
145
|
-
* [EBNF][] (~> 1.
|
143
|
+
* [Ruby](https://ruby-lang.org/) (>= 2.6)
|
144
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
|
145
|
+
* [EBNF][] (~> 1.2)
|
146
146
|
|
147
147
|
## Installation
|
148
148
|
|
@@ -190,7 +190,7 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
|
|
190
190
|
[Backports]: https://rubygems.org/gems/backports
|
191
191
|
[N-Triples]: https://www.w3.org/TR/rdf-testcases/#ntriples
|
192
192
|
[Turtle]: https://www.w3.org/TR/2012/WD-turtle-20120710/
|
193
|
-
[RDF
|
193
|
+
[RDF-star]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
|
194
194
|
[Turtle doc]: https://rubydoc.info/github/ruby-rdf/rdf-turtle/master/file/README.md
|
195
195
|
[Turtle EBNF]: https://dvcs.w3.org/hg/rdf/file/default/rdf-turtle/turtle.bnf
|
196
196
|
[Freebase Dumps]: https://developers.google.com/freebase/data
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/lib/rdf/turtle/reader.rb
CHANGED
@@ -373,7 +373,7 @@ module RDF::Turtle
|
|
373
373
|
read_iri ||
|
374
374
|
read_BlankNode ||
|
375
375
|
read_collection ||
|
376
|
-
|
376
|
+
read_quotedTriple ||
|
377
377
|
error( "Expected subject", production: :subject, token: @lexer.first)
|
378
378
|
end
|
379
379
|
end
|
@@ -386,7 +386,7 @@ module RDF::Turtle
|
|
386
386
|
read_collection ||
|
387
387
|
read_blankNodePropertyList ||
|
388
388
|
read_literal ||
|
389
|
-
|
389
|
+
read_quotedTriple
|
390
390
|
|
391
391
|
add_statement(:object, RDF::Statement(subject, predicate, object)) if subject && predicate
|
392
392
|
object
|
@@ -394,18 +394,18 @@ module RDF::Turtle
|
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
397
|
-
# Read an RDF
|
397
|
+
# Read an RDF-star reified statement
|
398
398
|
# @return [RDF::Statement]
|
399
|
-
def
|
399
|
+
def read_quotedTriple
|
400
400
|
return unless @options[:rdfstar]
|
401
401
|
if @lexer.first.value == '<<'
|
402
|
-
prod(:
|
402
|
+
prod(:quotedTriple) do
|
403
403
|
@lexer.shift # eat <<
|
404
|
-
subject =
|
405
|
-
predicate = read_verb || error("Failed to parse predicate", production: :
|
406
|
-
object =
|
404
|
+
subject = read_qtSubject || error("Failed to parse subject", production: :quotedTriple, token: @lexer.first)
|
405
|
+
predicate = read_verb || error("Failed to parse predicate", production: :quotedTriple, token: @lexer.first)
|
406
|
+
object = read_qtObject || error("Failed to parse object", production: :quotedTriple, token: @lexer.first)
|
407
407
|
unless @lexer.first.value == '>>'
|
408
|
-
error("Failed to end of embedded triple", production: :
|
408
|
+
error("Failed to end of embedded triple", production: :quotedTriple, token: @lexer.first)
|
409
409
|
end
|
410
410
|
@lexer.shift
|
411
411
|
statement = RDF::Statement(subject, predicate, object)
|
@@ -415,22 +415,22 @@ module RDF::Turtle
|
|
415
415
|
end
|
416
416
|
|
417
417
|
# @return [RDF::Resource]
|
418
|
-
def
|
419
|
-
prod(:
|
418
|
+
def read_qtSubject
|
419
|
+
prod(:qtSubject) do
|
420
420
|
read_iri ||
|
421
421
|
read_BlankNode ||
|
422
|
-
|
423
|
-
error( "Expected embedded subject", production: :
|
422
|
+
read_quotedTriple ||
|
423
|
+
error( "Expected embedded subject", production: :qtSubject, token: @lexer.first)
|
424
424
|
end
|
425
425
|
end
|
426
426
|
|
427
427
|
# @return [RDF::Term]
|
428
|
-
def
|
429
|
-
prod(:
|
428
|
+
def read_qtObject(subject = nil, predicate = nil)
|
429
|
+
prod(:qtObject) do
|
430
430
|
read_iri ||
|
431
431
|
read_BlankNode ||
|
432
432
|
read_literal ||
|
433
|
-
|
433
|
+
read_quotedTriple
|
434
434
|
end
|
435
435
|
end
|
436
436
|
|
data/lib/rdf/turtle/writer.rb
CHANGED
@@ -276,10 +276,23 @@ module RDF::Turtle
|
|
276
276
|
case literal
|
277
277
|
when RDF::Literal
|
278
278
|
case @options[:literal_shorthand] && literal.valid? ? literal.datatype : false
|
279
|
-
when RDF::XSD.boolean
|
280
|
-
literal.canonicalize.to_s
|
279
|
+
when RDF::XSD.boolean
|
280
|
+
%w(true false).include?(literal.value) ? literal.value : literal.canonicalize.to_s
|
281
|
+
when RDF::XSD.integer
|
282
|
+
literal.value.match?(/^[\+\-]?\d+$/) && !canonicalize? ? literal.value : literal.canonicalize.to_s
|
283
|
+
when RDF::XSD.decimal
|
284
|
+
literal.value.match?(/^[\+\-]?\d+\.\d+?$/) && !canonicalize? ?
|
285
|
+
literal.value :
|
286
|
+
literal.canonicalize.to_s
|
281
287
|
when RDF::XSD.double
|
282
|
-
|
288
|
+
in_form = case literal.value
|
289
|
+
when /[\+\-]?\d+\.\d*E[\+\-]?\d+$/i then true
|
290
|
+
when /[\+\-]?\.\d+E[\+\-]?\d+$/i then true
|
291
|
+
when /[\+\-]?\d+E[\+\-]?\d+$/i then true
|
292
|
+
else false
|
293
|
+
end && !canonicalize?
|
294
|
+
|
295
|
+
in_form ? literal.value : literal.canonicalize.to_s.sub('E', 'e').to_s
|
283
296
|
else
|
284
297
|
text = quoted(literal.value)
|
285
298
|
text << "@#{literal.language}" if literal.has_language?
|
@@ -319,7 +332,7 @@ module RDF::Turtle
|
|
319
332
|
# @param [RDF::Statement] statement
|
320
333
|
# @param [Hash{Symbol => Object}] options
|
321
334
|
# @return [String]
|
322
|
-
def
|
335
|
+
def format_quotedTriple(statement, **options)
|
323
336
|
log_debug("rdfstar") {"#{statement.to_ntriples}"}
|
324
337
|
"<<%s %s %s>>" % statement.to_a.map { |value| format_term(value, **options) }
|
325
338
|
end
|
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.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -16,34 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 3.1.8
|
19
|
+
version: '3.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.1.8
|
26
|
+
version: '3.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: ebnf
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '2.
|
33
|
+
version: '2.3'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '2.
|
40
|
+
version: '2.3'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: erubis
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,56 +100,56 @@ dependencies:
|
|
106
100
|
requirements:
|
107
101
|
- - "~>"
|
108
102
|
- !ruby/object:Gem::Version
|
109
|
-
version: '3.
|
103
|
+
version: '3.2'
|
110
104
|
type: :development
|
111
105
|
prerelease: false
|
112
106
|
version_requirements: !ruby/object:Gem::Requirement
|
113
107
|
requirements:
|
114
108
|
- - "~>"
|
115
109
|
- !ruby/object:Gem::Version
|
116
|
-
version: '3.
|
110
|
+
version: '3.2'
|
117
111
|
- !ruby/object:Gem::Dependency
|
118
112
|
name: json-ld
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: '3.
|
117
|
+
version: '3.2'
|
124
118
|
type: :development
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: '3.
|
124
|
+
version: '3.2'
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: rdf-spec
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - "~>"
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: '3.
|
131
|
+
version: '3.2'
|
138
132
|
type: :development
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
136
|
- - "~>"
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: '3.
|
138
|
+
version: '3.2'
|
145
139
|
- !ruby/object:Gem::Dependency
|
146
140
|
name: rdf-vocab
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
148
142
|
requirements:
|
149
143
|
- - "~>"
|
150
144
|
- !ruby/object:Gem::Version
|
151
|
-
version: '3.
|
145
|
+
version: '3.2'
|
152
146
|
type: :development
|
153
147
|
prerelease: false
|
154
148
|
version_requirements: !ruby/object:Gem::Requirement
|
155
149
|
requirements:
|
156
150
|
- - "~>"
|
157
151
|
- !ruby/object:Gem::Version
|
158
|
-
version: '3.
|
152
|
+
version: '3.2'
|
159
153
|
description: RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite.
|
160
154
|
email: public-rdf-ruby@w3.org
|
161
155
|
executables: []
|
@@ -187,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
181
|
requirements:
|
188
182
|
- - ">="
|
189
183
|
- !ruby/object:Gem::Version
|
190
|
-
version: '2.
|
184
|
+
version: '2.6'
|
191
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
186
|
requirements:
|
193
187
|
- - ">="
|
194
188
|
- !ruby/object:Gem::Version
|
195
189
|
version: '0'
|
196
190
|
requirements: []
|
197
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.3.3
|
198
192
|
signing_key:
|
199
193
|
specification_version: 4
|
200
194
|
summary: Turtle reader/writer for Ruby.
|