rdf-raptor 0.0.0.pre → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +24 -1
- data/VERSION +1 -1
- data/lib/rdf/raptor/format.rb +20 -0
- data/lib/rdf/raptor/rdfxml.rb +30 -0
- data/lib/rdf/raptor/reader.rb +30 -0
- data/lib/rdf/raptor/turtle.rb +30 -0
- data/lib/rdf/raptor/version.rb +2 -2
- data/lib/rdf/raptor/writer.rb +7 -0
- data/lib/rdf/raptor.rb +6 -1
- metadata +14 -12
data/README
CHANGED
@@ -7,15 +7,38 @@ library.
|
|
7
7
|
|
8
8
|
* <http://github.com/bendiken/rdf-raptor>
|
9
9
|
|
10
|
+
Examples
|
11
|
+
--------
|
12
|
+
|
13
|
+
require 'rdf/raptor'
|
14
|
+
|
15
|
+
### Parsing an RDF/XML file
|
16
|
+
|
17
|
+
RDF::Reader.open('http://datagraph.org/jhacker/foaf.rdf') do |reader|
|
18
|
+
reader.each_statement do |statement|
|
19
|
+
puts statement.inspect
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
### Parsing a Turtle file
|
24
|
+
|
25
|
+
RDF::Reader.open('http://datagraph.org/jhacker/foaf.ttl') do |reader|
|
26
|
+
reader.each_statement do |statement|
|
27
|
+
puts statement.inspect
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
10
31
|
Documentation
|
11
32
|
-------------
|
12
33
|
|
13
34
|
* {RDF::Raptor}
|
35
|
+
* {RDF::Raptor::RDFXML}
|
36
|
+
* {RDF::Raptor::Turtle}
|
14
37
|
|
15
38
|
Dependencies
|
16
39
|
------------
|
17
40
|
|
18
|
-
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.1.
|
41
|
+
* [RDF.rb](http://rubygems.org/gems/rdf) (>= 0.1.3)
|
19
42
|
* [Raptor](http://librdf.org/raptor/) (>= 1.4.21)
|
20
43
|
|
21
44
|
Installation
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RDF::Raptor
|
2
|
+
##
|
3
|
+
# Format base class.
|
4
|
+
class Format < RDF::Format
|
5
|
+
##
|
6
|
+
# @overload rapper_format
|
7
|
+
#
|
8
|
+
# @overload rapper_format(format)
|
9
|
+
# @param [Symbol] format
|
10
|
+
#
|
11
|
+
# @return [void]
|
12
|
+
def self.rapper_format(format = nil)
|
13
|
+
unless format
|
14
|
+
@rapper_format
|
15
|
+
else
|
16
|
+
@rapper_format = format
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RDF::Raptor
|
2
|
+
##
|
3
|
+
# RDF/XML support.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/REC-rdf-syntax/
|
6
|
+
module RDFXML
|
7
|
+
##
|
8
|
+
# RDF/XML format specification.
|
9
|
+
class Format < RDF::Raptor::Format
|
10
|
+
content_type 'application/rdf+xml', :extension => :rdf
|
11
|
+
content_encoding 'utf-8'
|
12
|
+
rapper_format :rdfxml
|
13
|
+
|
14
|
+
reader { RDF::Raptor::RDFXML::Reader }
|
15
|
+
writer { RDF::Raptor::RDFXML::Writer }
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# RDF/XML parser.
|
20
|
+
class Reader < RDF::Raptor::Reader
|
21
|
+
format RDF::Raptor::RDFXML::Format
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# RDF/XML serializer.
|
26
|
+
class Writer < RDF::Raptor::Writer
|
27
|
+
format RDF::Raptor::RDFXML::Format
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RDF::Raptor
|
2
|
+
##
|
3
|
+
# Reader base class.
|
4
|
+
class Reader < RDF::Reader
|
5
|
+
##
|
6
|
+
def initialize(input = $stdin, options = {}, &block)
|
7
|
+
format = self.class.format.rapper_format
|
8
|
+
case input
|
9
|
+
when RDF::URI, %r(^(file|http|https|ftp)://)
|
10
|
+
@command = "rapper -q -i #{format} -o ntriples #{input}"
|
11
|
+
@rapper = IO.popen(@command, 'rb')
|
12
|
+
when File
|
13
|
+
@command = "rapper -q -i #{format} -o ntriples #{File.expand_path(input.path)}"
|
14
|
+
@rapper = IO.popen(@command, 'rb')
|
15
|
+
else # IO, String
|
16
|
+
@command = "rapper -q -i #{format} -o ntriples file:///dev/stdin"
|
17
|
+
@rapper = IO.popen(@command, 'rb+')
|
18
|
+
@rapper.write(input.respond_to?(:read) ? input.read : input.to_s)
|
19
|
+
@rapper.close_write
|
20
|
+
end
|
21
|
+
@reader = RDF::NTriples::Reader.new(@rapper, options, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# @return [Array]
|
26
|
+
def read_triple
|
27
|
+
@reader.read_triple
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RDF::Raptor
|
2
|
+
##
|
3
|
+
# Turtle support.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TeamSubmission/turtle/
|
6
|
+
module Turtle
|
7
|
+
##
|
8
|
+
# Turtle format specification.
|
9
|
+
class Format < RDF::Raptor::Format
|
10
|
+
content_type 'text/turtle', :extension => :ttl
|
11
|
+
content_encoding 'utf-8'
|
12
|
+
rapper_format :turtle
|
13
|
+
|
14
|
+
reader { RDF::Raptor::Turtle::Reader }
|
15
|
+
writer { RDF::Raptor::Turtle::Writer }
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Turtle parser.
|
20
|
+
class Reader < RDF::Raptor::Reader
|
21
|
+
format RDF::Raptor::Turtle::Format
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Turtle serializer.
|
26
|
+
class Writer < RDF::Raptor::Writer
|
27
|
+
format RDF::Raptor::Turtle::Format
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/rdf/raptor/version.rb
CHANGED
data/lib/rdf/raptor.rb
CHANGED
@@ -12,6 +12,11 @@ module RDF
|
|
12
12
|
#
|
13
13
|
# @author [Arto Bendiken](http://ar.to/)
|
14
14
|
module Raptor
|
15
|
-
|
15
|
+
require 'rdf/raptor/version'
|
16
|
+
require 'rdf/raptor/format'
|
17
|
+
require 'rdf/raptor/reader'
|
18
|
+
require 'rdf/raptor/writer'
|
19
|
+
require 'rdf/raptor/rdfxml'
|
20
|
+
require 'rdf/raptor/turtle'
|
16
21
|
end # module Raptor
|
17
22
|
end # module RDF
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-raptor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.0.0.pre
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Arto Bendiken
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-04-01 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -70,8 +69,8 @@ dependencies:
|
|
70
69
|
segments:
|
71
70
|
- 0
|
72
71
|
- 1
|
73
|
-
-
|
74
|
-
version: 0.1.
|
72
|
+
- 3
|
73
|
+
version: 0.1.3
|
75
74
|
type: :runtime
|
76
75
|
version_requirements: *id004
|
77
76
|
description: RDF.rb plugin for parsing/serializing RDF/XML and Turtle data using the Raptor RDF Parser library.
|
@@ -87,7 +86,12 @@ files:
|
|
87
86
|
- README
|
88
87
|
- UNLICENSE
|
89
88
|
- VERSION
|
89
|
+
- lib/rdf/raptor/format.rb
|
90
|
+
- lib/rdf/raptor/rdfxml.rb
|
91
|
+
- lib/rdf/raptor/reader.rb
|
92
|
+
- lib/rdf/raptor/turtle.rb
|
90
93
|
- lib/rdf/raptor/version.rb
|
94
|
+
- lib/rdf/raptor/writer.rb
|
91
95
|
- lib/rdf/raptor.rb
|
92
96
|
has_rdoc: false
|
93
97
|
homepage: http://rdf.rubyforge.org/
|
@@ -109,13 +113,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
113
|
version: 1.8.2
|
110
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
115
|
requirements:
|
112
|
-
- - "
|
116
|
+
- - ">="
|
113
117
|
- !ruby/object:Gem::Version
|
114
118
|
segments:
|
115
|
-
-
|
116
|
-
|
117
|
-
- 1
|
118
|
-
version: 1.3.1
|
119
|
+
- 0
|
120
|
+
version: "0"
|
119
121
|
requirements:
|
120
122
|
- Raptor (>= 1.4.21)
|
121
123
|
rubyforge_project: rdf
|