rdf 0.3.4.1 → 0.3.5
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.
- data/VERSION +1 -1
- data/etc/doap.nt +3 -22
- data/lib/rdf/format.rb +16 -10
- data/lib/rdf/mixin/enumerable.rb +21 -4
- data/lib/rdf/mixin/queryable.rb +3 -2
- data/lib/rdf/mixin/type_check.rb +1 -1
- data/lib/rdf/mixin/writable.rb +5 -0
- data/lib/rdf/model/graph.rb +10 -0
- data/lib/rdf/model/literal/date.rb +2 -2
- data/lib/rdf/model/literal/datetime.rb +2 -2
- data/lib/rdf/model/literal/time.rb +13 -1
- data/lib/rdf/model/value.rb +1 -1
- data/lib/rdf/nquads.rb +7 -6
- data/lib/rdf/ntriples.rb +1 -1
- data/lib/rdf/ntriples/format.rb +23 -3
- data/lib/rdf/reader.rb +1 -0
- data/lib/rdf/repository.rb +1 -11
- data/lib/rdf/util/cache.rb +6 -4
- data/lib/rdf/util/file.rb +6 -2
- data/lib/rdf/version.rb +2 -5
- data/lib/rdf/writer.rb +1 -0
- metadata +52 -90
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.5
|
data/etc/doap.nt
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
<http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
|
2
|
-
<http://ar.to/#self> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bendiken/foaf> .
|
|
3
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/homepage> <http://ar.to/> .
|
|
4
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <http://rubygems.org/gems/rdf> .
|
|
5
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto.bendiken@gmail.com> .
|
|
6
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "a033f652c84a4d73b8c26d318c2395699dd2bdfb" .
|
|
7
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "d0737cceb55eb7d740578d2db1bc0727e3ed49ce" .
|
|
8
|
-
<http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
|
|
9
|
-
<http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
|
10
|
-
<http://bhuga.net/#ben> <http://www.w3.org/2000/01/rdf-schema#isDefinedBy> <http://datagraph.org/bhuga/foaf> .
|
|
11
|
-
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/homepage> <http://bhuga.net/> .
|
|
12
|
-
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
|
|
13
|
-
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "dbf45f4ffbd27b67aa84f02a6a31c144727d10af" .
|
|
14
|
-
<http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
|
|
15
|
-
<http://greggkellogg.net/foaf.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
|
|
16
|
-
<http://greggkellogg.net/foaf.rdf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .
|
|
17
|
-
<http://greggkellogg.net/foaf.rdf#me> <http://xmlns.com/foaf/0.1/mbox> <mailto:gregg@kellogg-assoc.com> .
|
|
18
|
-
<http://greggkellogg.net/foaf.rdf#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "35bc44e6d0070e5ad50ccbe0d24403c96af2b9bd" .
|
|
19
|
-
<http://greggkellogg.net/foaf.rdf#me> <http://xmlns.com/foaf/0.1/homepage> <http://greggkellogg.net/> .
|
|
20
1
|
<http://rubygems.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
|
|
21
2
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
|
|
22
3
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://blog.datagraph.org/> .
|
|
@@ -27,10 +8,10 @@
|
|
|
27
8
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
|
|
28
9
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
|
|
29
10
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
|
|
30
|
-
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf
|
|
11
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://greggkellogg.net/foaf#me> .
|
|
31
12
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
|
|
32
13
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://bhuga.net/#ben> .
|
|
33
|
-
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://greggkellogg.net/foaf
|
|
14
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://greggkellogg.net/foaf#me> .
|
|
34
15
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
|
|
35
16
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid1 .
|
|
36
17
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#helper> _:genid2 .
|
|
@@ -45,7 +26,7 @@
|
|
|
45
26
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
|
|
46
27
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
|
|
47
28
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://bhuga.net/#ben> .
|
|
48
|
-
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://greggkellogg.net/foaf
|
|
29
|
+
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://greggkellogg.net/foaf#me> .
|
|
49
30
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
|
|
50
31
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
|
|
51
32
|
<http://rubygems.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
|
data/lib/rdf/format.rb
CHANGED
|
@@ -78,6 +78,10 @@ module RDF
|
|
|
78
78
|
# @option options [Symbol, #to_sym] :file_extension (nil)
|
|
79
79
|
# @option options [String, #to_s] :content_type (nil)
|
|
80
80
|
# Note that content_type will be taken from a URL opened using {RDF::Util::File.open_file}.
|
|
81
|
+
# @option options [Boolean] :has_reader (false)
|
|
82
|
+
# Only return a format having a reader.
|
|
83
|
+
# @option options [Boolean] :has_writer (false)
|
|
84
|
+
# Only return a format having a writer.
|
|
81
85
|
# @option options [String] :sample (nil)
|
|
82
86
|
# A sample of input used for performing format detection.
|
|
83
87
|
# If we find no formats, or we find more than one, and we have a sample, we can
|
|
@@ -100,7 +104,7 @@ module RDF
|
|
|
100
104
|
# @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17
|
|
101
105
|
# @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
|
|
102
106
|
mime_type = mime_type.to_s
|
|
103
|
-
mime_type = mime_type.split(';').first
|
|
107
|
+
mime_type = mime_type.split(';').first # remove any media type parameters
|
|
104
108
|
content_types[mime_type]
|
|
105
109
|
# Find a format based on the file name:
|
|
106
110
|
when file_name = options[:file_name]
|
|
@@ -117,17 +121,14 @@ module RDF
|
|
|
117
121
|
RDF::NTriples::Format
|
|
118
122
|
# For anything else, find a match based on the full class name
|
|
119
123
|
else
|
|
120
|
-
@@subclasses.
|
|
121
|
-
if klass.to_sym == format ||
|
|
122
|
-
klass.name.to_s.split('::').map(&:downcase).include?(format.to_s.downcase)
|
|
123
|
-
return klass
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
nil # not found
|
|
124
|
+
@@subclasses.detect { |klass| klass.to_sym == format }
|
|
127
125
|
end
|
|
128
126
|
end
|
|
129
|
-
|
|
127
|
+
|
|
130
128
|
if format.is_a?(Array)
|
|
129
|
+
format = format.select {|f| f.reader} if options[:has_reader]
|
|
130
|
+
format = format.select {|f| f.writer} if options[:has_writer]
|
|
131
|
+
|
|
131
132
|
return format.first if format.uniq.length == 1
|
|
132
133
|
elsif !format.nil?
|
|
133
134
|
return format
|
|
@@ -140,7 +141,12 @@ module RDF
|
|
|
140
141
|
format ||= @@subclasses
|
|
141
142
|
|
|
142
143
|
# Return first format that has a positive detection
|
|
143
|
-
format.detect {|f| f.detect(sample)}
|
|
144
|
+
format.detect {|f| f.detect(sample)} || format.first
|
|
145
|
+
elsif format.is_a?(Array)
|
|
146
|
+
# Otherwise, just return the first matching format
|
|
147
|
+
format.first
|
|
148
|
+
else
|
|
149
|
+
nil
|
|
144
150
|
end
|
|
145
151
|
end
|
|
146
152
|
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
|
@@ -61,6 +61,20 @@ module RDF
|
|
|
61
61
|
include ::Enumerable
|
|
62
62
|
include RDF::Countable # NOTE: must come after ::Enumerable
|
|
63
63
|
|
|
64
|
+
##
|
|
65
|
+
# Returns `true` if this repository supports the given `feature`.
|
|
66
|
+
#
|
|
67
|
+
# Supported features include:
|
|
68
|
+
# * `:context` supports statements with a context, allowing multiple contexts
|
|
69
|
+
# * `:inferrence` supports RDFS inferrence of queryable contents.
|
|
70
|
+
#
|
|
71
|
+
# @param [Symbol, #to_sym] feature
|
|
72
|
+
# @return [Boolean]
|
|
73
|
+
# @since 0.3.5
|
|
74
|
+
def supports?(feature)
|
|
75
|
+
false
|
|
76
|
+
end
|
|
77
|
+
|
|
64
78
|
##
|
|
65
79
|
# Returns all RDF statements.
|
|
66
80
|
#
|
|
@@ -136,7 +150,7 @@ module RDF
|
|
|
136
150
|
# @param [Array(RDF::Resource, RDF::URI, RDF::Term)] triple
|
|
137
151
|
# @return [Boolean]
|
|
138
152
|
def has_triple?(triple)
|
|
139
|
-
|
|
153
|
+
triples.include?(triple)
|
|
140
154
|
end
|
|
141
155
|
|
|
142
156
|
##
|
|
@@ -196,7 +210,7 @@ module RDF
|
|
|
196
210
|
# @param [Array(RDF::Resource, RDF::URI, RDF::Term, RDF::Resource)] quad
|
|
197
211
|
# @return [Boolean]
|
|
198
212
|
def has_quad?(quad)
|
|
199
|
-
|
|
213
|
+
quads.include?(quad)
|
|
200
214
|
end
|
|
201
215
|
|
|
202
216
|
##
|
|
@@ -607,14 +621,17 @@ module RDF
|
|
|
607
621
|
# ntriples = enumerable.dump(:ntriples)
|
|
608
622
|
#
|
|
609
623
|
# @param [Array<Object>] args
|
|
610
|
-
# if the last argument is a hash, it is passed as
|
|
624
|
+
# if the last argument is a hash, it is passed as options to
|
|
611
625
|
# {RDF::Writer.dump}.
|
|
612
626
|
# @return [String]
|
|
613
627
|
# @see RDF::Writer.dump
|
|
628
|
+
# @raise [RDF::WriterError] if no writer found
|
|
614
629
|
# @since 0.2.0
|
|
615
630
|
def dump(*args)
|
|
616
631
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
617
|
-
RDF::Writer.for(*args)
|
|
632
|
+
writer = RDF::Writer.for(*args)
|
|
633
|
+
raise RDF::WriterError, "No writer found using #{args.inspect}" unless writer
|
|
634
|
+
writer.dump(self, nil, options)
|
|
618
635
|
end
|
|
619
636
|
end # Enumerable
|
|
620
637
|
end # RDF
|
data/lib/rdf/mixin/queryable.rb
CHANGED
|
@@ -2,8 +2,9 @@ module RDF
|
|
|
2
2
|
##
|
|
3
3
|
# An RDF query mixin.
|
|
4
4
|
#
|
|
5
|
-
# Classes that include this module
|
|
6
|
-
# yields {RDF::Statement RDF statements}.
|
|
5
|
+
# Classes that include this module should implement a `#query_pattern` method that
|
|
6
|
+
# yields {RDF::Statement RDF statements}. Classes may also implement an optimized
|
|
7
|
+
# `#query_execute` method that yields {RDF::Statement RDF statements}.
|
|
7
8
|
#
|
|
8
9
|
# @see RDF::Graph
|
|
9
10
|
# @see RDF::Repository
|
data/lib/rdf/mixin/type_check.rb
CHANGED
data/lib/rdf/mixin/writable.rb
CHANGED
data/lib/rdf/model/graph.rb
CHANGED
|
@@ -23,6 +23,7 @@ module RDF
|
|
|
23
23
|
include RDF::Resource
|
|
24
24
|
|
|
25
25
|
include RDF::Countable
|
|
26
|
+
include RDF::Durable
|
|
26
27
|
include RDF::Enumerable
|
|
27
28
|
include RDF::Queryable
|
|
28
29
|
include RDF::Mutable
|
|
@@ -122,6 +123,15 @@ module RDF
|
|
|
122
123
|
context.nil?
|
|
123
124
|
end
|
|
124
125
|
|
|
126
|
+
##
|
|
127
|
+
# Returns `false` to indicate that this graph is not durable
|
|
128
|
+
#
|
|
129
|
+
# @return [Boolean]
|
|
130
|
+
# @see RDF::Durable#durable?
|
|
131
|
+
def durable?
|
|
132
|
+
false
|
|
133
|
+
end
|
|
134
|
+
|
|
125
135
|
##
|
|
126
136
|
# Returns all unique RDF contexts for this graph.
|
|
127
137
|
#
|
|
@@ -29,7 +29,7 @@ module RDF; class Literal
|
|
|
29
29
|
# @return [RDF::Literal] `self`
|
|
30
30
|
# @see http://www.w3.org/TR/xmlschema-2/#date
|
|
31
31
|
def canonicalize!
|
|
32
|
-
@string = @object.strftime(FORMAT).sub(/\+00:00|UTC/, 'Z')
|
|
32
|
+
@string = @object.strftime(FORMAT).sub(/\+00:00|UTC/, 'Z') if self.valid?
|
|
33
33
|
self
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -42,7 +42,7 @@ module RDF; class Literal
|
|
|
42
42
|
# @return [Boolean]
|
|
43
43
|
# @since 0.2.1
|
|
44
44
|
def valid?
|
|
45
|
-
super && value !~ %r(\A0000)
|
|
45
|
+
super && object && value !~ %r(\A0000)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
##
|
|
@@ -28,7 +28,7 @@ module RDF; class Literal
|
|
|
28
28
|
# @return [RDF::Literal] `self`
|
|
29
29
|
# @see http://www.w3.org/TR/xmlschema-2/#dateTime
|
|
30
30
|
def canonicalize!
|
|
31
|
-
@string = @object.new_offset(0).strftime('%Y-%m-%dT%H:%M:%S%Z').sub(/\+00:00|UTC/, 'Z')
|
|
31
|
+
@string = @object.new_offset(0).strftime('%Y-%m-%dT%H:%M:%S%Z').sub(/\+00:00|UTC/, 'Z') if self.valid?
|
|
32
32
|
self
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -41,7 +41,7 @@ module RDF; class Literal
|
|
|
41
41
|
# @return [Boolean]
|
|
42
42
|
# @since 0.2.1
|
|
43
43
|
def valid?
|
|
44
|
-
super && value !~ %r(\A0000)
|
|
44
|
+
super && object && value !~ %r(\A0000)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
##
|
|
@@ -41,10 +41,22 @@ module RDF; class Literal
|
|
|
41
41
|
# @return [RDF::Literal] `self`
|
|
42
42
|
# @see http://www.w3.org/TR/xmlschema-2/#time
|
|
43
43
|
def canonicalize!
|
|
44
|
-
@string = @object.utc.strftime('%H:%M:%S%Z').sub(/\+00:00|UTC/, 'Z')
|
|
44
|
+
@string = @object.utc.strftime('%H:%M:%S%Z').sub(/\+00:00|UTC/, 'Z') if self.valid?
|
|
45
45
|
self
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
##
|
|
49
|
+
# Returns `true` if the value adheres to the defined grammar of the
|
|
50
|
+
# datatype.
|
|
51
|
+
#
|
|
52
|
+
# Special case for date and dateTime, for which '0000' is not a valid year
|
|
53
|
+
#
|
|
54
|
+
# @return [Boolean]
|
|
55
|
+
# @since 0.2.1
|
|
56
|
+
def valid?
|
|
57
|
+
super && object
|
|
58
|
+
end
|
|
59
|
+
|
|
48
60
|
##
|
|
49
61
|
# Returns the value as a string.
|
|
50
62
|
#
|
data/lib/rdf/model/value.rb
CHANGED
|
@@ -122,7 +122,7 @@ module RDF
|
|
|
122
122
|
|
|
123
123
|
##
|
|
124
124
|
# Default implementation of raise_error, which returns false.
|
|
125
|
-
# Classes including RDF::TypeCheck will raise
|
|
125
|
+
# Classes including RDF::TypeCheck will raise TypeError
|
|
126
126
|
# instead.
|
|
127
127
|
#
|
|
128
128
|
# @return [false]
|
data/lib/rdf/nquads.rb
CHANGED
|
@@ -36,14 +36,15 @@ module RDF
|
|
|
36
36
|
# @return [Boolean]
|
|
37
37
|
def self.detect(sample)
|
|
38
38
|
!!sample.match(%r(
|
|
39
|
-
(?:\s*(?:<[^>]*>) | (?:_:\w+))
|
|
40
|
-
(?:\s*<[^>]*>)
|
|
39
|
+
(?:\s*(?:<[^>]*>) | (?:_:\w+)) # Subject
|
|
40
|
+
(?:\s*<[^>]*>) # Predicate
|
|
41
41
|
\s*
|
|
42
|
-
(?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"]*"(?:^^|@\S+)?)) # Object
|
|
43
|
-
(?:\s*<[^>]*>)
|
|
42
|
+
(?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
|
|
43
|
+
(?:\s*<[^>]*>) # Context
|
|
44
44
|
\s*\.
|
|
45
|
-
)mx) && (
|
|
46
|
-
|
|
45
|
+
)mx) && !(
|
|
46
|
+
sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
|
|
47
|
+
sample.match(%r(<(html|rdf))i) # Not HTML or XML
|
|
47
48
|
)
|
|
48
49
|
end
|
|
49
50
|
end
|
data/lib/rdf/ntriples.rb
CHANGED
|
@@ -38,7 +38,7 @@ module RDF
|
|
|
38
38
|
#
|
|
39
39
|
# @author [Arto Bendiken](http://ar.to/)
|
|
40
40
|
module NTriples
|
|
41
|
-
require 'iconv' # needed on Ruby 1.8.x
|
|
41
|
+
require 'iconv' unless "".respond_to?(:encode )# needed on Ruby 1.8.x
|
|
42
42
|
require 'rdf/ntriples/format'
|
|
43
43
|
autoload :Reader, 'rdf/ntriples/reader'
|
|
44
44
|
autoload :Writer, 'rdf/ntriples/writer'
|
data/lib/rdf/ntriples/format.rb
CHANGED
|
@@ -16,13 +16,33 @@ module RDF::NTriples
|
|
|
16
16
|
#
|
|
17
17
|
# @see http://www.w3.org/TR/rdf-testcases/#ntriples
|
|
18
18
|
class Format < RDF::Format
|
|
19
|
-
content_type 'text/plain', :extension => :nt
|
|
20
|
-
content_type 'text/ntriples+turtle', :extension => :nt
|
|
19
|
+
content_type 'text/plain', :extension => :nt, :alias => 'text/ntriples+turtle'
|
|
21
20
|
content_encoding 'utf-8'
|
|
22
21
|
|
|
23
22
|
reader { RDF::NTriples::Reader }
|
|
24
23
|
writer { RDF::NTriples::Writer }
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
##
|
|
26
|
+
# Sample detection to see if it matches N-Triples
|
|
27
|
+
#
|
|
28
|
+
# Use a text sample to detect the format of an input file. Sub-classes implement
|
|
29
|
+
# a matcher sufficient to detect probably format matches, including disambiguating
|
|
30
|
+
# between other similar formats.
|
|
31
|
+
#
|
|
32
|
+
# @param [String] sample Beginning several bytes (about 1K) of input.
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
def self.detect(sample)
|
|
35
|
+
!!sample.match(%r(
|
|
36
|
+
(?:(?:<[^>]*>) | (?:_:\w+)) # Subject
|
|
37
|
+
\s*
|
|
38
|
+
(?:<[^>]*>) # Predicate
|
|
39
|
+
\s*
|
|
40
|
+
(?:(?:<[^>]*>) | (?:_:\w+) | (?:"[^"\n]*"(?:^^|@\S+)?)) # Object
|
|
41
|
+
\s*\.
|
|
42
|
+
)mx) && !(
|
|
43
|
+
sample.match(%r(@(base|prefix|keywords)|\{)) || # Not Turtle/N3/TriG
|
|
44
|
+
sample.match(%r(<(html|rdf))i) # Not HTML or XML
|
|
45
|
+
) && !RDF::NQuads::Format.detect(sample)
|
|
46
|
+
end
|
|
27
47
|
end
|
|
28
48
|
end
|
data/lib/rdf/reader.rb
CHANGED
data/lib/rdf/repository.rb
CHANGED
|
@@ -114,16 +114,6 @@ module RDF
|
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
-
##
|
|
118
|
-
# Returns `true` if this repository supports the given `feature`.
|
|
119
|
-
#
|
|
120
|
-
# @param [Symbol, #to_sym] feature
|
|
121
|
-
# @return [Boolean]
|
|
122
|
-
# @since 0.1.10
|
|
123
|
-
def supports?(feature)
|
|
124
|
-
false
|
|
125
|
-
end
|
|
126
|
-
|
|
127
117
|
##
|
|
128
118
|
# Returns a developer-friendly representation of this object.
|
|
129
119
|
#
|
|
@@ -231,7 +221,7 @@ module RDF
|
|
|
231
221
|
|
|
232
222
|
##
|
|
233
223
|
# @private
|
|
234
|
-
# @see RDF::
|
|
224
|
+
# @see RDF::Readable#supports?
|
|
235
225
|
def supports?(feature)
|
|
236
226
|
case feature.to_sym
|
|
237
227
|
when :context then true # statement contexts / named graphs
|
data/lib/rdf/util/cache.rb
CHANGED
|
@@ -21,11 +21,13 @@ module RDF; module Util
|
|
|
21
21
|
# @private
|
|
22
22
|
def self.new(*args)
|
|
23
23
|
# JRuby doesn't support `ObjectSpace#_id2ref` unless the `-X+O`
|
|
24
|
-
# startup option is given,
|
|
24
|
+
# startup option is given. In addition, ObjectSpaceCache is very slow
|
|
25
|
+
# on Rubinius. On those platforms we'll default to using
|
|
25
26
|
# the WeakRef-based cache:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if RUBY_PLATFORM == 'java' || (defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx')
|
|
28
|
+
klass = WeakRefCache
|
|
29
|
+
else
|
|
30
|
+
klass = ObjectSpaceCache
|
|
29
31
|
end
|
|
30
32
|
cache = klass.allocate
|
|
31
33
|
cache.send(:initialize, *args)
|
data/lib/rdf/util/file.rb
CHANGED
|
@@ -23,12 +23,16 @@ module RDF; module Util
|
|
|
23
23
|
#
|
|
24
24
|
# @param [String] filename_or_url to open
|
|
25
25
|
# @param [Hash{Symbol => Object}] options
|
|
26
|
-
#
|
|
26
|
+
# options are ignored in this implementation. Applications are encouraged
|
|
27
|
+
# to override this implementation to provide more control over HTTP
|
|
28
|
+
# headers and redirect following.
|
|
29
|
+
# @option options [Array, String] :headers
|
|
30
|
+
# HTTP Request headers.
|
|
27
31
|
# @return [IO] File stream
|
|
28
32
|
# @yield [IO] File stream
|
|
29
33
|
def self.open_file(filename_or_url, options = {}, &block)
|
|
30
34
|
filename_or_url = $1 if filename_or_url.to_s.match(/^file:(.*)$/)
|
|
31
|
-
|
|
35
|
+
Kernel.open(filename_or_url.to_s, &block)
|
|
32
36
|
end
|
|
33
37
|
end # File
|
|
34
38
|
end; end # RDF::Util
|
data/lib/rdf/version.rb
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
module RDF
|
|
2
2
|
module VERSION
|
|
3
|
-
|
|
4
|
-
MINOR =
|
|
5
|
-
TINY = 4
|
|
6
|
-
EXTRA = 1
|
|
7
|
-
|
|
3
|
+
VERSION_FILE = File.expand_path("../../../VERSION", __FILE__)
|
|
4
|
+
MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")
|
|
8
5
|
STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
|
|
9
6
|
|
|
10
7
|
##
|
data/lib/rdf/writer.rb
CHANGED
metadata
CHANGED
|
@@ -1,98 +1,70 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rdf
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.5
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 3
|
|
9
|
-
- 4
|
|
10
|
-
- 1
|
|
11
|
-
version: 0.3.4.1
|
|
12
6
|
platform: ruby
|
|
13
|
-
authors:
|
|
7
|
+
authors:
|
|
14
8
|
- Arto Bendiken
|
|
15
9
|
- Ben Lavender
|
|
16
10
|
- Gregg Kellogg
|
|
17
11
|
autorequire:
|
|
18
12
|
bindir: bin
|
|
19
13
|
cert_chain: []
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
+
date: 2012-02-07 00:00:00.000000000Z
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
24
17
|
name: addressable
|
|
25
|
-
|
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
18
|
+
requirement: &2152772480 !ruby/object:Gem::Requirement
|
|
27
19
|
none: false
|
|
28
|
-
requirements:
|
|
29
|
-
- -
|
|
30
|
-
- !ruby/object:Gem::Version
|
|
31
|
-
hash: 11
|
|
32
|
-
segments:
|
|
33
|
-
- 2
|
|
34
|
-
- 2
|
|
35
|
-
- 6
|
|
20
|
+
requirements:
|
|
21
|
+
- - ! '>='
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
36
23
|
version: 2.2.6
|
|
37
24
|
type: :runtime
|
|
38
|
-
version_requirements: *id001
|
|
39
|
-
- !ruby/object:Gem::Dependency
|
|
40
|
-
name: yard
|
|
41
25
|
prerelease: false
|
|
42
|
-
|
|
26
|
+
version_requirements: *2152772480
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: yard
|
|
29
|
+
requirement: &2152772020 !ruby/object:Gem::Requirement
|
|
43
30
|
none: false
|
|
44
|
-
requirements:
|
|
45
|
-
- -
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
|
|
48
|
-
segments:
|
|
49
|
-
- 0
|
|
50
|
-
- 7
|
|
51
|
-
- 2
|
|
52
|
-
version: 0.7.2
|
|
31
|
+
requirements:
|
|
32
|
+
- - ! '>='
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 0.7.5
|
|
53
35
|
type: :development
|
|
54
|
-
version_requirements: *id002
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rdf-spec
|
|
57
36
|
prerelease: false
|
|
58
|
-
|
|
37
|
+
version_requirements: *2152772020
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: rdf-spec
|
|
40
|
+
requirement: &2152771560 !ruby/object:Gem::Requirement
|
|
59
41
|
none: false
|
|
60
|
-
requirements:
|
|
42
|
+
requirements:
|
|
61
43
|
- - ~>
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
|
|
64
|
-
segments:
|
|
65
|
-
- 0
|
|
66
|
-
- 3
|
|
67
|
-
- 4
|
|
68
|
-
version: 0.3.4
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 0.3.5
|
|
69
46
|
type: :development
|
|
70
|
-
version_requirements: *id003
|
|
71
|
-
- !ruby/object:Gem::Dependency
|
|
72
|
-
name: rspec
|
|
73
47
|
prerelease: false
|
|
74
|
-
|
|
48
|
+
version_requirements: *2152771560
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: rspec
|
|
51
|
+
requirement: &2152771100 !ruby/object:Gem::Requirement
|
|
75
52
|
none: false
|
|
76
|
-
requirements:
|
|
77
|
-
- -
|
|
78
|
-
- !ruby/object:Gem::Version
|
|
79
|
-
|
|
80
|
-
segments:
|
|
81
|
-
- 2
|
|
82
|
-
- 6
|
|
83
|
-
- 0
|
|
84
|
-
version: 2.6.0
|
|
53
|
+
requirements:
|
|
54
|
+
- - ! '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 2.8.0
|
|
85
57
|
type: :development
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: *2152771100
|
|
60
|
+
description: RDF.rb is a pure-Ruby library for working with Resource Description Framework
|
|
61
|
+
(RDF) data.
|
|
88
62
|
email: public-rdf-ruby@w3.org
|
|
89
|
-
executables:
|
|
63
|
+
executables:
|
|
90
64
|
- rdf
|
|
91
65
|
extensions: []
|
|
92
|
-
|
|
93
66
|
extra_rdoc_files: []
|
|
94
|
-
|
|
95
|
-
files:
|
|
67
|
+
files:
|
|
96
68
|
- AUTHORS
|
|
97
69
|
- CREDITS
|
|
98
70
|
- README
|
|
@@ -173,39 +145,29 @@ files:
|
|
|
173
145
|
- lib/rdf/writer.rb
|
|
174
146
|
- lib/rdf.rb
|
|
175
147
|
homepage: http://rdf.rubyforge.org/
|
|
176
|
-
licenses:
|
|
148
|
+
licenses:
|
|
177
149
|
- Public Domain
|
|
178
150
|
post_install_message:
|
|
179
151
|
rdoc_options: []
|
|
180
|
-
|
|
181
|
-
require_paths:
|
|
152
|
+
require_paths:
|
|
182
153
|
- lib
|
|
183
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
184
155
|
none: false
|
|
185
|
-
requirements:
|
|
186
|
-
- -
|
|
187
|
-
- !ruby/object:Gem::Version
|
|
188
|
-
hash: 53
|
|
189
|
-
segments:
|
|
190
|
-
- 1
|
|
191
|
-
- 8
|
|
192
|
-
- 1
|
|
156
|
+
requirements:
|
|
157
|
+
- - ! '>='
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
193
159
|
version: 1.8.1
|
|
194
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
161
|
none: false
|
|
196
|
-
requirements:
|
|
197
|
-
- -
|
|
198
|
-
- !ruby/object:Gem::Version
|
|
199
|
-
|
|
200
|
-
segments:
|
|
201
|
-
- 0
|
|
202
|
-
version: "0"
|
|
162
|
+
requirements:
|
|
163
|
+
- - ! '>='
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '0'
|
|
203
166
|
requirements: []
|
|
204
|
-
|
|
205
167
|
rubyforge_project: rdf
|
|
206
168
|
rubygems_version: 1.8.10
|
|
207
169
|
signing_key:
|
|
208
170
|
specification_version: 3
|
|
209
171
|
summary: A Ruby library for working with Resource Description Framework (RDF) data.
|
|
210
172
|
test_files: []
|
|
211
|
-
|
|
173
|
+
has_rdoc: false
|