rdf-turtle 3.2.0 → 3.3.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 +20 -18
- data/VERSION +1 -1
- data/lib/rdf/turtle/format.rb +1 -0
- data/lib/rdf/turtle/freebase_reader.rb +3 -2
- data/lib/rdf/turtle/reader.rb +13 -9
- data/lib/rdf/turtle/terminals.rb +1 -1
- data/lib/rdf/turtle/writer.rb +10 -8
- data/lib/rdf/turtle.rb +1 -1
- metadata +24 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e3cededb73cd8863f7a82386dc5ae0667edee714910a148df381402c8daf664
|
4
|
+
data.tar.gz: 7952f03d779df79e0f02fd5c9281118afeb661fc810ada681e98e4b604941528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d24d8479b3055dff29ac2c958532817d32860e419dd1d9e978ef63bfca8c8c08cf2da93b08353dc488b5489d20d83b2c33959277d3d8b2fd2c4a3d768bcd4bb
|
7
|
+
data.tar.gz: 3a3f31bb8ca9e14228596de15a3108d9a30903f9ef947d6fa5338bd038684b44cdc8fee7aa3b4d3ce6f473bda11b8b0501bd6eab76585585863f3a98db25f2ba
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[Turtle][] reader/writer for [RDF.rb][RDF.rb] .
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/rdf-turtle.
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/rdf-turtle.svg)](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
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)
|
@@ -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 >=
|
20
|
+
* Compatible with Ruby >= 3.0.
|
21
21
|
* Optional streaming writer, to serialize large graphs
|
22
|
-
* Provisional support for [
|
22
|
+
* Provisional support for [RDF 1.2][].
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
Instantiate a reader from a local file:
|
@@ -36,15 +36,17 @@ Write a graph to a file:
|
|
36
36
|
writer << graph
|
37
37
|
end
|
38
38
|
|
39
|
-
##
|
39
|
+
## RDF 1.2
|
40
40
|
|
41
|
-
Both reader and writer include provisional support for [
|
41
|
+
Both reader and writer include provisional support for [RDF 1.2][] quoted triples.
|
42
|
+
|
43
|
+
Both reader and writer include provisional support for [RDF 1.2][] directional language-tagged strings, which are literals of type `rdf:dirLangString` having both a `language` and `direction`.
|
42
44
|
|
43
45
|
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
46
|
|
45
47
|
**Note: This feature is subject to change or elimination as the standards process progresses.**
|
46
48
|
|
47
|
-
### Serializing a Graph containing
|
49
|
+
### Serializing a Graph containing quoted triples
|
48
50
|
|
49
51
|
require 'rdf/turtle'
|
50
52
|
statement = RDF::Statement(RDF::URI('bob'), RDF::Vocab::FOAF.age, RDF::Literal(23))
|
@@ -52,7 +54,7 @@ Internally, an `RDF::Statement` is treated as another resource, along with `RDF:
|
|
52
54
|
graph.dump(:ttl, validate: false, standard_prefixes: true)
|
53
55
|
# => '<<<bob> foaf:age 23>> <ex:certainty> 9.0e-1 .'
|
54
56
|
|
55
|
-
### Reading a Graph containing
|
57
|
+
### Reading a Graph containing quoted triples
|
56
58
|
|
57
59
|
By default, the Turtle reader will reject a document containing a subject resource.
|
58
60
|
|
@@ -140,9 +142,9 @@ This version uses a hand-written parser using the Lexer from the [EBNF][] gem in
|
|
140
142
|
|
141
143
|
## Dependencies
|
142
144
|
|
143
|
-
* [Ruby](https://ruby-lang.org/) (>=
|
144
|
-
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.
|
145
|
-
* [EBNF][] (~>
|
145
|
+
* [Ruby](https://ruby-lang.org/) (>= 3.0)
|
146
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.3)
|
147
|
+
* [EBNF][] (~> 2.4)
|
146
148
|
|
147
149
|
## Installation
|
148
150
|
|
@@ -185,12 +187,12 @@ A copy of the [Turtle EBNF][] and derived parser files are included in the repos
|
|
185
187
|
[YARD]: https://yardoc.org/
|
186
188
|
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
187
189
|
[PDD]: https://unlicense.org/#unlicensing-contributions
|
188
|
-
[RDF.rb]: https://
|
190
|
+
[RDF.rb]: https://ruby-rdf.github.io/rdf
|
189
191
|
[EBNF]: https://rubygems.org/gems/ebnf
|
190
|
-
[
|
191
|
-
[
|
192
|
-
[
|
193
|
-
[RDF
|
194
|
-
[Turtle doc]: https://
|
195
|
-
[Turtle EBNF]: https://
|
196
|
-
[Freebase Dumps]: https://developers.google.com/freebase/data
|
192
|
+
[N-Triples]: https://www.w3.org/TR/rdf12-n-triples
|
193
|
+
[Turtle]: https://www.w3.org/TR/rdf12-turtle
|
194
|
+
[RDF 1.1]: https://www.w3.org/TR/rdf11-concepts/
|
195
|
+
[RDF 1.2]: https://www.w3.org/TR/rdf12-concepts/
|
196
|
+
[Turtle doc]: https://ruby-rdf.github.io/rdf-turtle/master/file/README.md
|
197
|
+
[Turtle EBNF]: https://w3c.github.io/rdf-turtle/spec/turtle-bnf.html
|
198
|
+
[Freebase Dumps]: https://developers.google.com/freebase/data
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.0
|
data/lib/rdf/turtle/format.rb
CHANGED
@@ -79,8 +79,9 @@ module RDF::Turtle
|
|
79
79
|
if literal_str = match(LITERAL_PLAIN)
|
80
80
|
literal_str = self.class.unescape(literal_str)
|
81
81
|
literal = case
|
82
|
-
when
|
83
|
-
|
82
|
+
when lang_dir = match(RDF::Turtle::Reader::LANG_DIR)
|
83
|
+
language, direction = lang_dir.split('--')
|
84
|
+
RDF::Literal.new(literal_str, language: language, direction: direction)
|
84
85
|
when datatype = match(/^(\^\^)/)
|
85
86
|
RDF::Literal.new(literal_str, datatype: read_pname(intern: true) || read_uriref || fail_object)
|
86
87
|
else
|
data/lib/rdf/turtle/reader.rb
CHANGED
@@ -36,11 +36,11 @@ module RDF::Turtle
|
|
36
36
|
|
37
37
|
terminal(:PREFIX, PREFIX)
|
38
38
|
terminal(:BASE, BASE)
|
39
|
-
terminal(:
|
39
|
+
terminal(:LANG_DIR, LANG_DIR)
|
40
40
|
|
41
41
|
##
|
42
42
|
# Reader options
|
43
|
-
# @see https://
|
43
|
+
# @see https://ruby-rdf.github.io/rdf/RDF/Reader#options-class_method
|
44
44
|
def self.options
|
45
45
|
super + [
|
46
46
|
RDF::CLI::Option.new(
|
@@ -394,7 +394,7 @@ module RDF::Turtle
|
|
394
394
|
end
|
395
395
|
end
|
396
396
|
|
397
|
-
# Read
|
397
|
+
# Read a quoted triple
|
398
398
|
# @return [RDF::Statement]
|
399
399
|
def read_quotedTriple
|
400
400
|
return unless @options[:rdfstar]
|
@@ -408,7 +408,7 @@ module RDF::Turtle
|
|
408
408
|
error("Failed to end of embedded triple", production: :quotedTriple, token: @lexer.first)
|
409
409
|
end
|
410
410
|
@lexer.shift
|
411
|
-
statement = RDF::Statement(subject, predicate, object)
|
411
|
+
statement = RDF::Statement(subject, predicate, object, quoted: true)
|
412
412
|
statement
|
413
413
|
end
|
414
414
|
end
|
@@ -442,7 +442,7 @@ module RDF::Turtle
|
|
442
442
|
@lexer.shift
|
443
443
|
|
444
444
|
# Statement becomes subject for predicateObjectList
|
445
|
-
statement = RDF::Statement(subject, predicate, object)
|
445
|
+
statement = RDF::Statement(subject, predicate, object, quoted: true)
|
446
446
|
read_predicateObjectList(statement) ||
|
447
447
|
error("Expected predicateObjectList", production: :annotation, token: @lexer.first)
|
448
448
|
error("annotation", "Expected closing '|}'") unless @lexer.first === '|}'
|
@@ -470,8 +470,10 @@ module RDF::Turtle
|
|
470
470
|
value = @lexer.shift.value[1..-2]
|
471
471
|
error("read_literal", "Unexpected end of file") unless token = @lexer.first
|
472
472
|
case token.type || token.value
|
473
|
-
when :
|
474
|
-
|
473
|
+
when :LANG_DIR
|
474
|
+
lang_dir = @lexer.shift.value[1..-1]
|
475
|
+
language, direction = lang_dir.split('--')
|
476
|
+
literal(value, language: language, direction: direction)
|
475
477
|
when '^^'
|
476
478
|
@lexer.shift
|
477
479
|
literal(value, datatype: read_iri)
|
@@ -484,8 +486,10 @@ module RDF::Turtle
|
|
484
486
|
value = @lexer.shift.value[3..-4]
|
485
487
|
error("read_literal", "Unexpected end of file") unless token = @lexer.first
|
486
488
|
case token.type || token.value
|
487
|
-
when :
|
488
|
-
|
489
|
+
when :LANG_DIR
|
490
|
+
lang_dir = @lexer.shift.value[1..-1]
|
491
|
+
language, direction = lang_dir.split('--')
|
492
|
+
literal(value, language: language, direction: direction)
|
489
493
|
when '^^'
|
490
494
|
@lexer.shift
|
491
495
|
literal(value, datatype: read_iri)
|
data/lib/rdf/turtle/terminals.rb
CHANGED
@@ -48,7 +48,7 @@ module RDF::Turtle
|
|
48
48
|
# 141s
|
49
49
|
BLANK_NODE_LABEL = /_:(?:[0-9]|#{PN_CHARS_U})(?:(?:#{PN_CHARS}|\.)*#{PN_CHARS})?/u.freeze
|
50
50
|
# 144s
|
51
|
-
|
51
|
+
LANG_DIR = /@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*(?:--[a-zA-Z]+)?)/u.freeze
|
52
52
|
# 19
|
53
53
|
INTEGER = /[+-]?[0-9]+/u.freeze
|
54
54
|
# 20
|
data/lib/rdf/turtle/writer.rb
CHANGED
@@ -65,7 +65,7 @@ module RDF::Turtle
|
|
65
65
|
|
66
66
|
##
|
67
67
|
# Writer options
|
68
|
-
# @see https://
|
68
|
+
# @see https://ruby-rdf.github.io/rdf/RDF/Writer#options-class_method
|
69
69
|
def self.options
|
70
70
|
super + [
|
71
71
|
RDF::CLI::Option.new(
|
@@ -87,7 +87,7 @@ module RDF::Turtle
|
|
87
87
|
symbol: :literal_shorthand,
|
88
88
|
datatype: FalseClass,
|
89
89
|
on: ["--no-literal-shorthand"],
|
90
|
-
description: "Do not
|
90
|
+
description: "Do not attempt to use Literal shorthands fo numbers and boolean values.") {false},
|
91
91
|
]
|
92
92
|
end
|
93
93
|
|
@@ -201,7 +201,7 @@ module RDF::Turtle
|
|
201
201
|
super
|
202
202
|
end
|
203
203
|
|
204
|
-
# Return a
|
204
|
+
# Return a PName for the URI, or nil. Adds namespace of PName to defined prefixes
|
205
205
|
# @param [RDF::Resource] resource
|
206
206
|
# @return [String, nil] value to use to identify URI
|
207
207
|
def get_pname(resource)
|
@@ -215,7 +215,7 @@ module RDF::Turtle
|
|
215
215
|
end
|
216
216
|
|
217
217
|
pname = case
|
218
|
-
when @uri_to_pname.
|
218
|
+
when @uri_to_pname.key?(uri)
|
219
219
|
return @uri_to_pname[uri]
|
220
220
|
when u = @uri_to_prefix.keys.sort_by {|uu| uu.length}.reverse.detect {|uu| uri.index(uu.to_s) == 0}
|
221
221
|
# Use a defined prefix
|
@@ -223,14 +223,15 @@ module RDF::Turtle
|
|
223
223
|
unless u.to_s.empty?
|
224
224
|
prefix(prefix, u) unless u.to_s.empty?
|
225
225
|
log_debug("get_pname") {"add prefix #{prefix.inspect} => #{u}"}
|
226
|
-
|
226
|
+
# Escape suffix, as necessary
|
227
|
+
RDF::URI(uri).pname(prefixes: {prefix => u})
|
227
228
|
end
|
228
229
|
when @options[:standard_prefixes] && vocab = RDF::Vocabulary.each.to_a.detect {|v| uri.index(v.to_uri.to_s) == 0}
|
229
230
|
prefix = vocab.__name__.to_s.split('::').last.downcase
|
230
231
|
@uri_to_prefix[vocab.to_uri.to_s] = prefix
|
231
232
|
prefix(prefix, vocab.to_uri) # Define for output
|
232
233
|
log_debug("get_pname") {"add standard prefix #{prefix.inspect} => #{vocab.to_uri}"}
|
233
|
-
uri.
|
234
|
+
RDF::URI(uri).pname(prefixes: {prefix => vocab.to_uri})
|
234
235
|
else
|
235
236
|
nil
|
236
237
|
end
|
@@ -295,8 +296,9 @@ module RDF::Turtle
|
|
295
296
|
in_form ? literal.value : literal.canonicalize.to_s.sub('E', 'e').to_s
|
296
297
|
else
|
297
298
|
text = quoted(literal.value)
|
298
|
-
text << "@#{literal.language}" if literal.
|
299
|
-
text << "
|
299
|
+
text << "@#{literal.language}" if literal.language?
|
300
|
+
text << "--#{literal.direction}" if literal.direction?
|
301
|
+
text << "^^#{format_uri(literal.datatype)}" if literal.datatype?
|
300
302
|
text
|
301
303
|
end
|
302
304
|
else
|
data/lib/rdf/turtle.rb
CHANGED
@@ -15,7 +15,7 @@ module RDF
|
|
15
15
|
# end
|
16
16
|
# end
|
17
17
|
#
|
18
|
-
# @see https://
|
18
|
+
# @see https://ruby-rdf.github.io/rdf/master/frames
|
19
19
|
# @see https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-turtle/index.html
|
20
20
|
#
|
21
21
|
# @author [Gregg Kellogg](https://greggkellogg.net/)
|
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.3.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: 2023-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ebnf
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '2.
|
40
|
+
version: '2.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: erubis
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.12'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.12'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-its
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,56 +100,56 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
103
|
+
version: '3.3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '3.
|
110
|
+
version: '3.3'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: json-ld
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
117
|
+
version: '3.3'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.3'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rdf-spec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '3.
|
131
|
+
version: '3.3'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '3.
|
138
|
+
version: '3.3'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rdf-vocab
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '3.
|
145
|
+
version: '3.3'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '3.
|
152
|
+
version: '3.3'
|
153
153
|
description: RDF::Turtle is an Turtle reader/writer for the RDF.rb library suite.
|
154
154
|
email: public-rdf-ruby@w3.org
|
155
155
|
executables: []
|
@@ -172,7 +172,12 @@ files:
|
|
172
172
|
homepage: https://github.com/ruby-rdf/rdf-turtle
|
173
173
|
licenses:
|
174
174
|
- Unlicense
|
175
|
-
metadata:
|
175
|
+
metadata:
|
176
|
+
documentation_uri: https://ruby-rdf.github.io/rdf-turtle
|
177
|
+
bug_tracker_uri: https://github.com/ruby-rdf/rdf-turtle/issues
|
178
|
+
homepage_uri: https://github.com/ruby-rdf/rdf-turtle
|
179
|
+
mailing_list_uri: https://lists.w3.org/Archives/Public/public-rdf-ruby/
|
180
|
+
source_code_uri: https://github.com/ruby-rdf/rdf-turtle
|
176
181
|
post_install_message:
|
177
182
|
rdoc_options: []
|
178
183
|
require_paths:
|
@@ -181,14 +186,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
186
|
requirements:
|
182
187
|
- - ">="
|
183
188
|
- !ruby/object:Gem::Version
|
184
|
-
version: '
|
189
|
+
version: '3.0'
|
185
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
191
|
requirements:
|
187
192
|
- - ">="
|
188
193
|
- !ruby/object:Gem::Version
|
189
194
|
version: '0'
|
190
195
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.4.19
|
192
197
|
signing_key:
|
193
198
|
specification_version: 4
|
194
199
|
summary: Turtle reader/writer for Ruby.
|