rdf-raptor 1.99.0 → 3.2.0
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.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +38 -0
- data/{README → README.md} +22 -24
- data/UNLICENSE +1 -1
- data/VERSION +1 -1
- data/etc/doap.ttl +30 -25
- data/lib/rdf/raptor/cli.rb +10 -10
- data/lib/rdf/raptor/ffi/v1/iostream.rb +2 -2
- data/lib/rdf/raptor/ffi/v1/iostream_handler.rb +1 -1
- data/lib/rdf/raptor/ffi/v1/parser.rb +14 -14
- data/lib/rdf/raptor/ffi/v1/serializer.rb +6 -6
- data/lib/rdf/raptor/ffi/v1/statement.rb +1 -1
- data/lib/rdf/raptor/ffi/v1/uri.rb +1 -1
- data/lib/rdf/raptor/ffi/v1.rb +10 -10
- data/lib/rdf/raptor/ffi/v2/iostream.rb +2 -2
- data/lib/rdf/raptor/ffi/v2/iostream_handler.rb +1 -1
- data/lib/rdf/raptor/ffi/v2/namespace.rb +1 -1
- data/lib/rdf/raptor/ffi/v2/parser.rb +10 -10
- data/lib/rdf/raptor/ffi/v2/serializer.rb +11 -9
- data/lib/rdf/raptor/ffi/v2/statement.rb +1 -1
- data/lib/rdf/raptor/ffi/v2/term.rb +1 -1
- data/lib/rdf/raptor/ffi/v2/uri.rb +1 -1
- data/lib/rdf/raptor/ffi/v2.rb +12 -11
- data/lib/rdf/raptor/ffi.rb +45 -16
- data/lib/rdf/raptor/graphviz.rb +1 -10
- data/lib/rdf/raptor/ntriples.rb +6 -1
- data/lib/rdf/raptor/rdfa.rb +23 -2
- data/lib/rdf/raptor/rdfxml.rb +5 -1
- data/lib/rdf/raptor/turtle.rb +32 -1
- data/lib/rdf/raptor/version.rb +1 -1
- data/lib/rdf/raptor.rb +6 -6
- metadata +38 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5317a1ad191f7cee2d2c5d355b8a95340a9ccc97eb6b4bce85fa167bd4537e92
|
4
|
+
data.tar.gz: 2244894750cbede3dc7691c2ae936b2c3dd9f7fd3190d6cc47cab1784a35b946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aef346f8c5c2a30069f75ccdc4224d065b14a9b581693cc1caa495730acab3540fdbd62508fc3a7dec8b2bfb37cc368c0e278a3c9751981c4d5025f8ec1157fe
|
7
|
+
data.tar.gz: 6ee8542ca51db2ad90679b15afa000be9b6206eee8c31db1a3c820bd28e15be81e8365027031a4dedb6a8dadb3f63d9279c4b9e0db165d485bdea7d110171807
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
Community contributions are essential for keeping Ruby RDF great. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
4
|
+
|
5
|
+
## Development
|
6
|
+
|
7
|
+
This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage development and release activity. All submissions _must_ be on a feature branch based on the _develop_ branch to ease staging and integration.
|
8
|
+
|
9
|
+
* create or respond to an issue on the [Github Repository](https://github.com/ruby-rdf/rdf-raptor/issues)
|
10
|
+
* Fork and clone the repo:
|
11
|
+
`git clone git@github.com:your-username/rdf-raptor.git`
|
12
|
+
* Install bundle:
|
13
|
+
`bundle install`
|
14
|
+
* Create tests in RSpec and make sure you achieve at least 90% code coverage for the feature your adding or behavior being modified.
|
15
|
+
* Push to your fork and [submit a pull request][pr].
|
16
|
+
|
17
|
+
## Do's and Dont's
|
18
|
+
* Do your best to adhere to the existing coding conventions and idioms.
|
19
|
+
* Don't use hard tabs, and don't leave trailing whitespace on any line.
|
20
|
+
Before committing, run `git diff --check` to make sure of this.
|
21
|
+
* Do document every method you add using [YARD][] annotations. Read the
|
22
|
+
[tutorial][YARD-GS] or just look at the existing code for examples.
|
23
|
+
* Don't touch the `.gemspec` or `VERSION` files. If you need to change them,
|
24
|
+
do so on your private branch only.
|
25
|
+
* Do feel free to add yourself to the `CREDITS` file and the
|
26
|
+
corresponding list in the the `README`. Alphabetical order applies.
|
27
|
+
* Don't touch the `AUTHORS` file. If your contributions are significant
|
28
|
+
enough, be assured we will eventually add you in there.
|
29
|
+
* Do note that in order for us to merge any non-trivial changes (as a rule
|
30
|
+
of thumb, additions larger than about 15 lines of code), we need an
|
31
|
+
explicit [public domain dedication][PDD] on record from you,
|
32
|
+
which you will be asked to agree to on the first commit to a repo within the organization.
|
33
|
+
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
|
34
|
+
|
35
|
+
[YARD]: https://yardoc.org/
|
36
|
+
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
|
37
|
+
[PDD]: https://unlicense.org/#unlicensing-contributions
|
38
|
+
[pr]: https://github.com/ruby-rdf/rdf/compare/
|
data/{README → README.md}
RENAMED
@@ -5,11 +5,9 @@ This is an [RDF.rb][] extension that adds support for parsing/serializing [NTrip
|
|
5
5
|
[RDF/XML][], [Turtle][], [RDFa][], and [Graphviz][] data using the [Raptor RDF Parser][Raptor]
|
6
6
|
library.
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
[](http://badge.fury.io/rb/rdf-raptor)
|
12
|
-
[](http://travis-ci.org/ruby-rdf/rdf-raptor)
|
8
|
+
[](https://badge.fury.io/rb/rdf-raptor)
|
9
|
+
[](https://github.com/ruby-rdf/rdf-raptor/actions?query=workflow%3ACI)
|
10
|
+
[](https://gitter.im/ruby-rdf/rdf)
|
13
11
|
|
14
12
|
Features
|
15
13
|
--------
|
@@ -18,9 +16,9 @@ Features
|
|
18
16
|
* Parses and serializes RDF data from/into the NTriples, RDF/XML, and Turtle formats.
|
19
17
|
* Extracts RDF statements from XHTML+RDFa documents.
|
20
18
|
* Serializes RDF statements into Graphviz format.
|
21
|
-
* Provides serialization format
|
19
|
+
* Provides serialization format auto-detection for RDF/XML, Turtle and RDFa.
|
22
20
|
* Compatible with any operating system supported by Raptor and Ruby.
|
23
|
-
* Compatible with MRI
|
21
|
+
* Compatible with MRI >= 2.6, JRuby and Rubinius.
|
24
22
|
|
25
23
|
Examples
|
26
24
|
--------
|
@@ -30,7 +28,7 @@ Examples
|
|
30
28
|
### Ensuring Raptor is installed and obtaining the version number
|
31
29
|
|
32
30
|
RDF::Raptor.available? #=> true
|
33
|
-
RDF::Raptor.version #=> "2.0
|
31
|
+
RDF::Raptor.version #=> "3.2.0"
|
34
32
|
|
35
33
|
### Parsing RDF statements from an NTriples file
|
36
34
|
|
@@ -127,7 +125,7 @@ Examples
|
|
127
125
|
Documentation
|
128
126
|
-------------
|
129
127
|
|
130
|
-
<
|
128
|
+
<https://www.rubydoc.info/github/ruby-rdf/rdf-raptor/>
|
131
129
|
|
132
130
|
* {RDF::Raptor}
|
133
131
|
* {RDF::Raptor::NTriples}
|
@@ -139,14 +137,14 @@ Documentation
|
|
139
137
|
Dependencies
|
140
138
|
------------
|
141
139
|
|
142
|
-
* [RDF.rb](
|
143
|
-
* [FFI](
|
140
|
+
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
|
141
|
+
* [FFI](https://rubygems.org/gems/ffi) (~> 1.15)
|
144
142
|
* [Raptor][] (>= 2.0), the `libraptor` library or the `rapper` binary
|
145
143
|
|
146
144
|
Installation
|
147
145
|
------------
|
148
146
|
|
149
|
-
The recommended installation method is via [RubyGems](
|
147
|
+
The recommended installation method is via [RubyGems](https://rubygems.org/).
|
150
148
|
To install the latest official release of the `RDF::Raptor` gem, do:
|
151
149
|
|
152
150
|
% [sudo] gem install rdf-raptor
|
@@ -190,33 +188,33 @@ follows:
|
|
190
188
|
Mailing List
|
191
189
|
------------
|
192
190
|
|
193
|
-
* <
|
191
|
+
* <https://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
194
192
|
|
195
193
|
Authors
|
196
194
|
-------
|
197
195
|
|
198
|
-
* [Arto Bendiken](https://github.com/
|
199
|
-
* [John Fieber](https://github.com/jfieber) - <
|
196
|
+
* [Arto Bendiken](https://github.com/artob) - <https://ar.to/>
|
197
|
+
* [John Fieber](https://github.com/jfieber) - <https://github.com/jfieber>
|
200
198
|
|
201
199
|
Contributors
|
202
200
|
------------
|
203
201
|
|
204
|
-
* [Ben Lavender](https://github.com/bhuga) - <
|
205
|
-
* [David Butler](https://github.com/dwbutler) - <
|
206
|
-
* [Gregg Kellogg](https://github.com/gkellogg) - <
|
202
|
+
* [Ben Lavender](https://github.com/bhuga) - <https://bhuga.net/>
|
203
|
+
* [David Butler](https://github.com/dwbutler) - <https://github.com/dwbutler>
|
204
|
+
* [Gregg Kellogg](https://github.com/gkellogg) - <https://greggkellogg.net/>
|
207
205
|
|
208
206
|
License
|
209
207
|
-------
|
210
208
|
|
211
209
|
This is free and unencumbered public domain software. For more information,
|
212
|
-
see <
|
210
|
+
see <https://unlicense.org/> or the accompanying [UNLICENSE][] file.
|
213
211
|
|
214
212
|
[RDF.rb]: https://ruby-rdf.github.io/rdf
|
215
213
|
[NTriples]: https://en.wikipedia.org/wiki/N-Triples
|
216
|
-
[RDF/XML]:
|
214
|
+
[RDF/XML]: https://www.w3.org/TR/REC-rdf-syntax/
|
217
215
|
[Turtle]: https://en.wikipedia.org/wiki/Turtle_(syntax)
|
218
|
-
[RDFa]:
|
219
|
-
[Graphviz]:
|
220
|
-
[Raptor]:
|
221
|
-
[rapper]:
|
216
|
+
[RDFa]: https://rdfa.info/
|
217
|
+
[Graphviz]: https://www.graphviz.org/
|
218
|
+
[Raptor]: https://librdf.org/raptor/
|
219
|
+
[rapper]: https://librdf.org/raptor/rapper.html
|
222
220
|
[UNLICENSE]:https://github.com/ruby-rdf/rdf-raptor/blob/master/UNLICENSE
|
data/UNLICENSE
CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
21
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
22
|
OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
|
-
For more information, please refer to <
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.2.0
|
data/etc/doap.ttl
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
@base <
|
1
|
+
@base <https://rubygems.org/gems/rdf-raptor> .
|
2
2
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
3
3
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
4
4
|
@prefix dc: <http://purl.org/dc/terms/> .
|
@@ -7,49 +7,54 @@
|
|
7
7
|
|
8
8
|
<> a doap:Project ;
|
9
9
|
doap:name "RDF::Raptor" ;
|
10
|
-
doap:homepage <
|
11
|
-
doap:license <
|
10
|
+
doap:homepage <https://ruby-rdf.github.com/rdf-raptor> ;
|
11
|
+
doap:license <https://unlicense.org/1.0/> ;
|
12
12
|
doap:shortdesc "Raptor RDF Parser plugin for RDF.rb."@en ;
|
13
13
|
doap:description "RDF.rb plugin for parsing/serializing RDF/XML, Turtle and RDFa data using the Raptor RDF Parser library."@en ;
|
14
14
|
doap:created "2010-03-23" ;
|
15
|
-
doap:
|
16
|
-
doap:download-page
|
17
|
-
doap:bug-database <
|
18
|
-
doap:blog <
|
19
|
-
doap:developer <
|
15
|
+
doap:programming-language "Ruby" ;
|
16
|
+
doap:download-page <> ;
|
17
|
+
doap:bug-database <https://github.com/ruby-rdf/rdf-raptor/issues> ;
|
18
|
+
doap:blog <https://greggkellogg.net/> ;
|
19
|
+
doap:developer <https://ar.to/#self>,
|
20
20
|
_:jfieber,
|
21
|
-
|
22
|
-
|
23
|
-
doap:
|
24
|
-
doap:
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
_:dwbutler,
|
22
|
+
<https://greggkellogg.net/foaf#me> ;
|
23
|
+
doap:maintainer _:dwbutler, <https://greggkellogg.net/> ;
|
24
|
+
doap:documenter <https://ar.to/#self> ;
|
25
|
+
doap:helper <https://bhuga.net/#ben>,
|
26
|
+
<https://greggkellogg.net/foaf#me> ;
|
27
|
+
foaf:maker <https://ar.to/#self> ;
|
28
|
+
dc:creator <https://ar.to/#self> .
|
28
29
|
|
29
|
-
<
|
30
|
+
<https://ar.to/#self> a foaf:Person ;
|
30
31
|
foaf:name "Arto Bendiken" ;
|
31
32
|
foaf:mbox <mailto:arto.bendiken@gmail.com> ;
|
32
33
|
foaf:mbox_sha1sum "d0737cceb55eb7d740578d2db1bc0727e3ed49ce",
|
33
34
|
"a033f652c84a4d73b8c26d318c2395699dd2bdfb" ;
|
34
|
-
foaf:homepage <
|
35
|
-
rdfs:isDefinedBy <http://datagraph.org/bendiken/foaf> .
|
35
|
+
foaf:homepage <https://ar.to/> .
|
36
36
|
|
37
|
-
<
|
37
|
+
<https://bhuga.net/#ben> a foaf:Person ;
|
38
38
|
foaf:name "Ben Lavender" ;
|
39
39
|
foaf:mbox <mailto:blavender@gmail.com> ;
|
40
40
|
foaf:mbox_sha1sum "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" ;
|
41
|
-
foaf:homepage <
|
42
|
-
|
41
|
+
foaf:homepage <https://bhuga.net/> .
|
42
|
+
|
43
|
+
_:dwbutler a foaf:Person ;
|
44
|
+
foaf:name "David Butler" ;
|
45
|
+
#foaf:mbox <mailto:david.william.butler@gmail.com> ;
|
46
|
+
foaf:mbox_sha1sum "8125fe100c2ed5f6ced2a88bd09a244e1c91682b" ;
|
47
|
+
foaf:homepage <https://github.com/dwbutler> .
|
43
48
|
|
44
49
|
_:jfieber a foaf:Person ;
|
45
50
|
foaf:name "John Fieber" ;
|
46
|
-
foaf:mbox <mailto:jrf@ursamaris.org> ;
|
51
|
+
#foaf:mbox <mailto:jrf@ursamaris.org> ;
|
47
52
|
foaf:mbox_sha1sum "f7653fc1ac0e82ebb32f092389bd5fc728eaae12" ;
|
48
53
|
foaf:homepage <http://ursamaris.org/> .
|
49
54
|
|
50
|
-
<
|
55
|
+
<https://greggkellogg.net/foaf#me> a foaf:Person ;
|
51
56
|
foaf:name "Gregg Kellogg" ;
|
52
57
|
foaf:mbox <mailto:gregg@greggkellogg.net> ;
|
53
58
|
foaf:mbox_sha1sum "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" ;
|
54
|
-
foaf:homepage <
|
55
|
-
rdfs:isDefinedBy <
|
59
|
+
foaf:homepage <https://greggkellogg.net/>;
|
60
|
+
rdfs:isDefinedBy <https://greggkellogg.net/foaf> .
|
data/lib/rdf/raptor/cli.rb
CHANGED
@@ -27,30 +27,30 @@ module RDF::Raptor
|
|
27
27
|
# Initializes the CLI reader instance.
|
28
28
|
#
|
29
29
|
# @param [IO, File, RDF::URI, String] input
|
30
|
+
# @param [String, #to_s] base_uri ("file:///dev/stdin")
|
30
31
|
# @param [Hash{Symbol => Object}] options
|
31
32
|
# any additional options (see `RDF::Reader#initialize`)
|
32
|
-
# @option options [String, #to_s] :base_uri ("file:///dev/stdin")
|
33
33
|
# @yield [reader] `self`
|
34
34
|
# @yieldparam [RDF::Reader] reader
|
35
35
|
# @yieldreturn [void] ignored
|
36
|
-
def initialize(input = $stdin,
|
36
|
+
def initialize(input = $stdin, base_uri: nil, **options, &block)
|
37
37
|
raise RDF::ReaderError, "`rapper` binary not found" unless RDF::Raptor.available?
|
38
38
|
|
39
39
|
format = self.class.format.rapper_format
|
40
40
|
case input
|
41
41
|
when RDF::URI, %r(^(file|http|https|ftp)://)
|
42
42
|
@command = "#{RAPPER} -q -i #{format} -o ntriples '#{input}'"
|
43
|
-
@command << " '#{
|
43
|
+
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
|
44
44
|
@rapper = IO.popen(@command, 'rb')
|
45
45
|
|
46
46
|
when File, Tempfile
|
47
47
|
@command = "#{RAPPER} -q -i #{format} -o ntriples '#{File.expand_path(input.path)}'"
|
48
|
-
@command << " '#{
|
48
|
+
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
|
49
49
|
@rapper = IO.popen(@command, 'rb')
|
50
50
|
|
51
51
|
else # IO, String
|
52
52
|
@command = "#{RAPPER} -q -i #{format} -o ntriples file:///dev/stdin"
|
53
|
-
@command << " '#{
|
53
|
+
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
|
54
54
|
@rapper = IO.popen(@command, 'rb+')
|
55
55
|
pid = fork do
|
56
56
|
# process to feed `rapper`
|
@@ -113,7 +113,7 @@ module RDF::Raptor
|
|
113
113
|
#
|
114
114
|
# @private
|
115
115
|
# @see RDF::NTriples::Reader#read_node
|
116
|
-
# @see https://github.com/
|
116
|
+
# @see https://github.com/ruby-rdf/rdf-raptor/issues/#issue/9
|
117
117
|
def read_node
|
118
118
|
if node_id = match(NODEID)
|
119
119
|
@nodes ||= {}
|
@@ -135,20 +135,20 @@ module RDF::Raptor
|
|
135
135
|
# @yield [writer] `self`
|
136
136
|
# @yieldparam [RDF::Writer] writer
|
137
137
|
# @yieldreturn [void]
|
138
|
-
def initialize(output = $stdout,
|
138
|
+
def initialize(output = $stdout, base_uri: nil, **options, &block)
|
139
139
|
raise RDF::WriterError, "`rapper` binary not found" unless RDF::Raptor.available?
|
140
140
|
|
141
141
|
format = self.class.format.rapper_format
|
142
142
|
case output
|
143
143
|
when File, IO, StringIO, Tempfile
|
144
144
|
@command = "#{RAPPER} -q -i turtle -o #{format} file:///dev/stdin"
|
145
|
-
@command << " '#{
|
145
|
+
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
|
146
146
|
@rapper = IO.popen(@command, 'rb+')
|
147
147
|
else
|
148
148
|
raise ArgumentError, "unsupported output type: #{output.inspect}"
|
149
149
|
end
|
150
|
-
@writer = RDF::NTriples::Writer.new(@rapper, options)
|
151
|
-
super(output, options, &block)
|
150
|
+
@writer = RDF::NTriples::Writer.new(@rapper, **options)
|
151
|
+
super(output, base_uri: base_uri, **options, &block)
|
152
152
|
end
|
153
153
|
|
154
154
|
protected
|
@@ -3,7 +3,7 @@ module RDF::Raptor::FFI::V1
|
|
3
3
|
# This class provides an I/O stream that can write to filenames, `FILE*`,
|
4
4
|
# strings and user-defined output via callbacks.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-iostream.html
|
7
7
|
class IOStream < ::FFI::ManagedStruct
|
8
8
|
include RDF::Raptor::FFI
|
9
9
|
layout :user_data, :pointer # the actual layout is private
|
@@ -18,7 +18,7 @@ module RDF::Raptor::FFI::V1
|
|
18
18
|
# @overload initialize(file)
|
19
19
|
# @param [File, Tempfile] file
|
20
20
|
#
|
21
|
-
def initialize(ptr_or_obj, options
|
21
|
+
def initialize(ptr_or_obj, **options)
|
22
22
|
ptr = case ptr_or_obj
|
23
23
|
when FFI::Pointer
|
24
24
|
ptr_or_obj
|
@@ -3,7 +3,7 @@ module RDF::Raptor::FFI::V1
|
|
3
3
|
# This class provides the functionality of turning syntaxes into RDF
|
4
4
|
# triples - RDF parsing.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-parser.html
|
7
7
|
class Parser < ::FFI::ManagedStruct
|
8
8
|
include RDF::Raptor::FFI
|
9
9
|
layout :world, :pointer # the actual layout is private
|
@@ -75,16 +75,16 @@ module RDF::Raptor::FFI::V1
|
|
75
75
|
# @yieldparam [FFI::Pointer] statement
|
76
76
|
# @yieldreturn [void] ignored
|
77
77
|
# @return [void]
|
78
|
-
def parse(input, options
|
78
|
+
def parse(input, **options, &block)
|
79
79
|
case input
|
80
80
|
when RDF::URI, %r(^(file|https|http|ftp)://)
|
81
|
-
parse_url(input, options, &block)
|
81
|
+
parse_url(input, **options, &block)
|
82
82
|
when File, Tempfile
|
83
|
-
parse_file(input, options, &block)
|
83
|
+
parse_file(input, **options, &block)
|
84
84
|
when IO, StringIO
|
85
|
-
parse_stream(input, options, &block)
|
85
|
+
parse_stream(input, **options, &block)
|
86
86
|
when String
|
87
|
-
parse_buffer(input, options, &block)
|
87
|
+
parse_buffer(input, **options, &block)
|
88
88
|
else
|
89
89
|
raise ArgumentError, "don't know how to parse #{input.inspect}"
|
90
90
|
end
|
@@ -101,11 +101,11 @@ module RDF::Raptor::FFI::V1
|
|
101
101
|
# @yieldparam [FFI::Pointer] statement
|
102
102
|
# @yieldreturn [void] ignored
|
103
103
|
# @return [void]
|
104
|
-
def parse_url(url,
|
104
|
+
def parse_url(url, base_uri: nil, **options, &block)
|
105
105
|
self.statement_handler = block if block_given?
|
106
106
|
|
107
107
|
data_url = V1::URI.new((url.respond_to?(:to_uri) ? url.to_uri : url).to_s)
|
108
|
-
base_uri =
|
108
|
+
base_uri = base_uri.to_s.empty? ? nil : V1::URI.new(base_uri.to_s)
|
109
109
|
|
110
110
|
result = V1.raptor_parse_uri(self, data_url, base_uri)
|
111
111
|
# TODO: error handling if result.nonzero?
|
@@ -123,11 +123,11 @@ module RDF::Raptor::FFI::V1
|
|
123
123
|
# @yieldparam [FFI::Pointer] statement
|
124
124
|
# @yieldreturn [void] ignored
|
125
125
|
# @return [void]
|
126
|
-
def parse_file(file,
|
126
|
+
def parse_file(file, base_uri: nil, **options, &block)
|
127
127
|
self.statement_handler = block if block_given?
|
128
128
|
|
129
129
|
data_url = V1::URI.new("file://#{File.expand_path(file.path)}")
|
130
|
-
base_uri =
|
130
|
+
base_uri = base_uri.to_s.empty? ? nil : V1::URI.new(base_uri.to_s)
|
131
131
|
|
132
132
|
result = V1.raptor_parse_file(self, data_url, base_uri)
|
133
133
|
# TODO: error handling if result.nonzero?
|
@@ -144,11 +144,11 @@ module RDF::Raptor::FFI::V1
|
|
144
144
|
# @yieldparam [FFI::Pointer] statement
|
145
145
|
# @yieldreturn [void] ignored
|
146
146
|
# @return [void]
|
147
|
-
def parse_stream(stream,
|
147
|
+
def parse_stream(stream, base_uri: nil, **options, &block)
|
148
148
|
self.statement_handler = block if block_given?
|
149
149
|
|
150
150
|
begin
|
151
|
-
parse_start!((
|
151
|
+
parse_start!((base_uri || BASE_URI).to_s)
|
152
152
|
loop do
|
153
153
|
parse_chunk(stream.sysread(BUFFER_SIZE))
|
154
154
|
end
|
@@ -168,10 +168,10 @@ module RDF::Raptor::FFI::V1
|
|
168
168
|
# @yieldparam [FFI::Pointer] statement
|
169
169
|
# @yieldreturn [void] ignored
|
170
170
|
# @return [void]
|
171
|
-
def parse_buffer(buffer,
|
171
|
+
def parse_buffer(buffer, base_uri: nil, **options, &block)
|
172
172
|
self.statement_handler = block if block_given?
|
173
173
|
|
174
|
-
parse_start!((
|
174
|
+
parse_start!((base_uri || BASE_URI).to_s)
|
175
175
|
parse_chunk(buffer.to_str)
|
176
176
|
parse_end!
|
177
177
|
end
|
@@ -3,7 +3,7 @@ module RDF::Raptor::FFI::V1
|
|
3
3
|
# This class provides the functionality of turning RDF triples into
|
4
4
|
# syntaxes - RDF serializing.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-serializer.html
|
7
7
|
class Serializer < ::FFI::ManagedStruct
|
8
8
|
include RDF::Raptor::FFI
|
9
9
|
layout :world, :pointer # the actual layout is private
|
@@ -57,9 +57,9 @@ module RDF::Raptor::FFI::V1
|
|
57
57
|
# @option options [String, #to_s] :base_uri (nil)
|
58
58
|
# the base URI to use when resolving relative URIs
|
59
59
|
# @return [void]
|
60
|
-
def start_to(output, options
|
60
|
+
def start_to(output, **options)
|
61
61
|
if output.respond_to?(:write)
|
62
|
-
start_to_stream(output, options)
|
62
|
+
start_to_stream(output, **options)
|
63
63
|
else
|
64
64
|
raise ArgumentError, "don't know how to serialize to #{output.inspect}"
|
65
65
|
end
|
@@ -70,9 +70,9 @@ module RDF::Raptor::FFI::V1
|
|
70
70
|
# @param [Hash{Symbol => Object}] options
|
71
71
|
# any additional options for serializing (see {#start_to})
|
72
72
|
# @return [void]
|
73
|
-
def start_to_stream(stream, options
|
73
|
+
def start_to_stream(stream, **options)
|
74
74
|
iostream = V1::IOStream.new(V1::IOStreamHandler.new(stream), free_iostream: false)
|
75
|
-
start_to_iostream(iostream, options)
|
75
|
+
start_to_iostream(iostream, **options)
|
76
76
|
end
|
77
77
|
|
78
78
|
##
|
@@ -80,7 +80,7 @@ module RDF::Raptor::FFI::V1
|
|
80
80
|
# @param [Hash{Symbol => Object}] options
|
81
81
|
# any additional options for serializing (see {#start_to})
|
82
82
|
# @return [void]
|
83
|
-
def start_to_iostream(iostream, options
|
83
|
+
def start_to_iostream(iostream, **options)
|
84
84
|
@iostream = iostream # prevents premature GC
|
85
85
|
@base_uri = options[:base_uri].to_s.empty? ? nil : V1::URI.new(options[:base_uri].to_s)
|
86
86
|
if V1.raptor_serialize_start_to_iostream(self, @base_uri, @iostream).nonzero?
|
@@ -4,7 +4,7 @@ module RDF::Raptor::FFI::V1
|
|
4
4
|
# passing URI references. The default internal implementation uses `char*`
|
5
5
|
# strings for URIs, manipulating them and constructing them.
|
6
6
|
#
|
7
|
-
# @see
|
7
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-uri.html
|
8
8
|
class URI < ::FFI::ManagedStruct
|
9
9
|
include RDF::Raptor::FFI
|
10
10
|
include RDF::Resource
|
data/lib/rdf/raptor/ffi/v1.rb
CHANGED
@@ -2,7 +2,7 @@ module RDF::Raptor::FFI
|
|
2
2
|
##
|
3
3
|
# A foreign-function interface (FFI) to `libraptor` 1.4.x.
|
4
4
|
#
|
5
|
-
# @see
|
5
|
+
# @see https://librdf.org/raptor/libraptor.html
|
6
6
|
module V1
|
7
7
|
autoload :IOStream, 'rdf/raptor/ffi/v1/iostream'
|
8
8
|
autoload :IOStreamHandler, 'rdf/raptor/ffi/v1/iostream_handler'
|
@@ -22,27 +22,27 @@ module RDF::Raptor::FFI
|
|
22
22
|
RAPTOR_IDENTIFIER_TYPE_ANONYMOUS = 2
|
23
23
|
RAPTOR_IDENTIFIER_TYPE_LITERAL = 5
|
24
24
|
|
25
|
-
# @see
|
25
|
+
# @see https://librdf.org/raptor/api-1.4/tutorial-initialising-finishing.html
|
26
26
|
attach_function :raptor_init, [], :void
|
27
27
|
attach_function :raptor_finish, [], :void
|
28
28
|
attach_function :raptor_alloc_memory, [:size_t], :pointer
|
29
29
|
attach_function :raptor_calloc_memory, [:size_t, :size_t], :pointer
|
30
30
|
attach_function :raptor_free_memory, [:pointer], :void
|
31
31
|
|
32
|
-
# @see
|
32
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-locator.html
|
33
33
|
typedef :pointer, :raptor_locator
|
34
34
|
attach_function :raptor_locator_line, [:raptor_locator], :int
|
35
35
|
attach_function :raptor_locator_column, [:raptor_locator], :int
|
36
36
|
attach_function :raptor_locator_byte, [:raptor_locator], :int
|
37
37
|
|
38
|
-
# @see
|
38
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-general.html
|
39
39
|
attach_variable :raptor_version_major, :int
|
40
40
|
attach_variable :raptor_version_minor, :int
|
41
41
|
attach_variable :raptor_version_release, :int
|
42
42
|
attach_variable :raptor_version_decimal, :int
|
43
43
|
callback :raptor_message_handler, [:pointer, :raptor_locator, :string], :void
|
44
44
|
|
45
|
-
# @see
|
45
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-uri.html
|
46
46
|
typedef :pointer, :raptor_uri
|
47
47
|
attach_function :raptor_new_uri, [:string], :raptor_uri
|
48
48
|
attach_function :raptor_uri_copy, [:raptor_uri], :raptor_uri
|
@@ -52,7 +52,7 @@ module RDF::Raptor::FFI
|
|
52
52
|
attach_function :raptor_uri_print, [:raptor_uri, :pointer], :void
|
53
53
|
attach_function :raptor_free_uri, [:raptor_uri], :void
|
54
54
|
|
55
|
-
# @see
|
55
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-triples.html
|
56
56
|
typedef :int, :raptor_identifier_type
|
57
57
|
typedef :pointer, :raptor_identifier
|
58
58
|
typedef :pointer, :raptor_statement
|
@@ -61,7 +61,7 @@ module RDF::Raptor::FFI
|
|
61
61
|
attach_function :raptor_print_statement_as_ntriples, [:pointer, :pointer], :void
|
62
62
|
attach_function :raptor_statement_part_as_string, [:pointer, :raptor_identifier_type, :raptor_uri, :pointer], :string
|
63
63
|
|
64
|
-
# @see
|
64
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-parser.html
|
65
65
|
callback :raptor_statement_handler, [:pointer, :raptor_statement], :void
|
66
66
|
typedef :pointer, :raptor_parser
|
67
67
|
typedef :string, :mime_type
|
@@ -81,7 +81,7 @@ module RDF::Raptor::FFI
|
|
81
81
|
attach_function :raptor_get_need_base_uri, [:raptor_parser], :int
|
82
82
|
attach_function :raptor_free_parser, [:raptor_parser], :void
|
83
83
|
|
84
|
-
# @see
|
84
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-iostream.html
|
85
85
|
typedef :pointer, :raptor_iostream
|
86
86
|
attach_function :raptor_new_iostream_from_handler2, [:pointer, :pointer], :raptor_iostream
|
87
87
|
attach_function :raptor_free_iostream, [:raptor_iostream], :void
|
@@ -93,10 +93,10 @@ module RDF::Raptor::FFI
|
|
93
93
|
callback :raptor_iostream_read_bytes_func, [:pointer, :pointer, :size_t, :size_t], :int
|
94
94
|
callback :raptor_iostream_read_eof_func, [:pointer], :int
|
95
95
|
|
96
|
-
# @see
|
96
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-xml-namespace.html
|
97
97
|
typedef :pointer, :raptor_namespace
|
98
98
|
|
99
|
-
# @see
|
99
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-serializer.html
|
100
100
|
typedef :pointer, :raptor_serializer
|
101
101
|
attach_function :raptor_new_serializer, [:string], :raptor_serializer
|
102
102
|
attach_function :raptor_free_serializer, [:raptor_serializer], :void
|
@@ -3,7 +3,7 @@ module RDF::Raptor::FFI::V2
|
|
3
3
|
# This class provides an I/O stream that can write to filenames, `FILE*`,
|
4
4
|
# strings and user-defined output via callbacks.
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://librdf.org/raptor/api-1.4/raptor-section-iostream.html
|
7
7
|
class IOStream < ::FFI::ManagedStruct
|
8
8
|
include RDF::Raptor::FFI
|
9
9
|
layout :world, :pointer,
|
@@ -23,7 +23,7 @@ module RDF::Raptor::FFI::V2
|
|
23
23
|
# @overload initialize(file)
|
24
24
|
# @param [File, Tempfile] file
|
25
25
|
#
|
26
|
-
def initialize(ptr_or_obj, options
|
26
|
+
def initialize(ptr_or_obj, **options)
|
27
27
|
ptr = case ptr_or_obj
|
28
28
|
when FFI::Pointer
|
29
29
|
ptr_or_obj
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RDF::Raptor::FFI::V2
|
2
2
|
##
|
3
|
-
# @see
|
3
|
+
# @see https://librdf.org/raptor/api/raptor2-section-xml-namespace.html
|
4
4
|
class Namespace < ::FFI::Struct
|
5
5
|
include RDF::Raptor::FFI
|
6
6
|
# @see https://github.com/dajobe/raptor/blob/f4b2597d4279dcb283bf5c32e5435696fd28a8ec/src/raptor_internal.h#L428
|