rdf 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/VERSION +1 -1
- data/lib/rdf.rb +1 -1
- data/lib/rdf/cli.rb +2 -2
- data/lib/rdf/mixin/enumerable.rb +40 -11
- data/lib/rdf/mixin/mutable.rb +1 -1
- data/lib/rdf/mixin/queryable.rb +1 -1
- data/lib/rdf/mixin/writable.rb +4 -4
- data/lib/rdf/model/literal.rb +1 -1
- data/lib/rdf/model/literal/string.rb +38 -0
- data/lib/rdf/model/statement.rb +2 -1
- data/lib/rdf/model/uri.rb +3 -3
- data/lib/rdf/model/value.rb +1 -1
- data/lib/rdf/ntriples/writer.rb +1 -1
- data/lib/rdf/query.rb +3 -3
- data/lib/rdf/query/pattern.rb +1 -1
- data/lib/rdf/query/solutions.rb +1 -1
- data/lib/rdf/transaction.rb +1 -1
- metadata +9 -11
data/README
CHANGED
@@ -355,6 +355,7 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
|
355
355
|
[RDF::N3]: http://ruby-rdf.github.com/rdf-n3
|
356
356
|
[RDF::RDFa]: http://ruby-rdf.github.com/rdf-rdfa
|
357
357
|
[RDF::RDFXML]: http://ruby-rdf.github.com/rdf-rdfxml
|
358
|
+
[RDF::TriG]: http://ruby-rdf.github.com/rdf-trig
|
358
359
|
[RDF::TriX]: http://ruby-rdf.github.com/rdf-trix
|
359
360
|
[RDF::Turtle]: http://ruby-rdf.github.com/rdf-turtle
|
360
361
|
[RDF::Raptor]: http://ruby-rdf.github.com/rdf-raptor
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
data/lib/rdf.rb
CHANGED
data/lib/rdf/cli.rb
CHANGED
@@ -166,8 +166,8 @@ module RDF
|
|
166
166
|
end
|
167
167
|
|
168
168
|
##
|
169
|
-
# Parse each file, STDIN or specified string in options[:evaluate]
|
170
|
-
# a reader
|
169
|
+
# Parse each file, STDIN or specified string in `options[:evaluate]`
|
170
|
+
# yielding a reader
|
171
171
|
#
|
172
172
|
# @param [Array<String>] files
|
173
173
|
# @yield [reader]
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
@@ -75,6 +75,37 @@ module RDF
|
|
75
75
|
false
|
76
76
|
end
|
77
77
|
|
78
|
+
##
|
79
|
+
# Returns `true` if all statements are valid
|
80
|
+
#
|
81
|
+
# @return [Boolean] `true` or `false`
|
82
|
+
# @since 0.3.11
|
83
|
+
def valid?
|
84
|
+
each_statement do |s|
|
85
|
+
return false if s.invalid?
|
86
|
+
end
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Returns `true` if value is not valid
|
92
|
+
#
|
93
|
+
# @return [Boolean] `true` or `false`
|
94
|
+
# @since 0.2.1
|
95
|
+
def invalid?
|
96
|
+
!valid?
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Default validate! implementation, overridden in concrete classes
|
101
|
+
# @return [RDF::Literal] `self`
|
102
|
+
# @raise [ArgumentError] if the value is invalid
|
103
|
+
# @since 0.3.9
|
104
|
+
def validate!
|
105
|
+
raise ArgumentError if invalid?
|
106
|
+
end
|
107
|
+
alias_method :validate, :validate!
|
108
|
+
|
78
109
|
##
|
79
110
|
# Returns all RDF statements.
|
80
111
|
#
|
@@ -124,7 +155,7 @@ module RDF
|
|
124
155
|
end
|
125
156
|
|
126
157
|
##
|
127
|
-
# Returns an enumerator for {#each_statement}.
|
158
|
+
# Returns an enumerator for {RDF::Enumerable#each_statement}.
|
128
159
|
# FIXME: enum_for doesn't seem to be working properly
|
129
160
|
# in JRuby 1.7, so specs are marked pending
|
130
161
|
#
|
@@ -186,7 +217,7 @@ module RDF
|
|
186
217
|
end
|
187
218
|
|
188
219
|
##
|
189
|
-
# Returns an enumerator for {#each_triple}.
|
220
|
+
# Returns an enumerator for {RDF::Enumerable#each_triple}.
|
190
221
|
#
|
191
222
|
# @return [Enumerator]
|
192
223
|
# @see #each_triple
|
@@ -247,7 +278,7 @@ module RDF
|
|
247
278
|
end
|
248
279
|
|
249
280
|
##
|
250
|
-
# Returns an enumerator for {#each_quad}.
|
281
|
+
# Returns an enumerator for {RDF::Enumerable#each_quad}.
|
251
282
|
#
|
252
283
|
# @return [Enumerator]
|
253
284
|
# @see #each_quad
|
@@ -315,7 +346,7 @@ module RDF
|
|
315
346
|
end
|
316
347
|
|
317
348
|
##
|
318
|
-
# Returns an enumerator for {#each_subject}.
|
349
|
+
# Returns an enumerator for {RDF::Enumerable#each_subject}.
|
319
350
|
#
|
320
351
|
# @return [Enumerator]
|
321
352
|
# @see #each_subject
|
@@ -383,7 +414,7 @@ module RDF
|
|
383
414
|
end
|
384
415
|
|
385
416
|
##
|
386
|
-
# Returns an enumerator for {#each_predicate}.
|
417
|
+
# Returns an enumerator for {RDF::Enumerable#each_predicate}.
|
387
418
|
#
|
388
419
|
# @return [Enumerator]
|
389
420
|
# @see #each_predicate
|
@@ -451,7 +482,7 @@ module RDF
|
|
451
482
|
end
|
452
483
|
|
453
484
|
##
|
454
|
-
# Returns an enumerator for {#each_object}.
|
485
|
+
# Returns an enumerator for {RDF::Enumerable#each_object}.
|
455
486
|
#
|
456
487
|
# @return [Enumerator]
|
457
488
|
# @see #each_object
|
@@ -519,7 +550,7 @@ module RDF
|
|
519
550
|
end
|
520
551
|
|
521
552
|
##
|
522
|
-
# Returns an enumerator for {#each_context}.
|
553
|
+
# Returns an enumerator for {RDF::Enumerable#each_context}.
|
523
554
|
#
|
524
555
|
# @return [Enumerator]
|
525
556
|
# @see #each_context
|
@@ -559,7 +590,7 @@ module RDF
|
|
559
590
|
end
|
560
591
|
|
561
592
|
##
|
562
|
-
# Returns an enumerator for {#each_graph}.
|
593
|
+
# Returns an enumerator for {RDF::Enumerable#each_graph}.
|
563
594
|
#
|
564
595
|
# @return [Enumerator]
|
565
596
|
# @see #each_graph
|
@@ -597,14 +628,12 @@ module RDF
|
|
597
628
|
# terms.
|
598
629
|
#
|
599
630
|
# The return value is a `Hash` instance that has the structure:
|
600
|
-
#
|
631
|
+
# `{subject => {predicate => [*objects]}}`.
|
601
632
|
#
|
602
633
|
# @return [Hash]
|
603
634
|
def to_hash
|
604
635
|
result = {}
|
605
636
|
each_statement do |statement|
|
606
|
-
next if statement.invalid? # skip any incomplete statements
|
607
|
-
|
608
637
|
result[statement.subject] ||= {}
|
609
638
|
values = (result[statement.subject][statement.predicate] ||= [])
|
610
639
|
values << statement.object unless values.include?(statement.object)
|
data/lib/rdf/mixin/mutable.rb
CHANGED
@@ -157,7 +157,7 @@ module RDF
|
|
157
157
|
##
|
158
158
|
# Deletes the given RDF statements from the underlying storage.
|
159
159
|
#
|
160
|
-
# Defaults to invoking {#delete_statement} for each given statement.
|
160
|
+
# Defaults to invoking {RDF::Mutable#delete_statement} for each given statement.
|
161
161
|
#
|
162
162
|
# Subclasses of {RDF::Repository} may wish to override this method if
|
163
163
|
# they are capable of more efficiently deleting multiple statements at
|
data/lib/rdf/mixin/queryable.rb
CHANGED
@@ -14,7 +14,7 @@ module RDF
|
|
14
14
|
##
|
15
15
|
# Queries `self` for RDF statements matching the given `pattern`.
|
16
16
|
#
|
17
|
-
# This method delegates to the protected {#query_pattern} method for the
|
17
|
+
# This method delegates to the protected {RDF::Queryable#query_pattern} method for the
|
18
18
|
# actual lower-level query pattern matching implementation.
|
19
19
|
#
|
20
20
|
# @example
|
data/lib/rdf/mixin/writable.rb
CHANGED
@@ -54,7 +54,7 @@ module RDF
|
|
54
54
|
when value.respond_to?(:each_statement)
|
55
55
|
insert_statements(value)
|
56
56
|
nil
|
57
|
-
when (statement = Statement.from(value))
|
57
|
+
when (statement = Statement.from(value))
|
58
58
|
statement
|
59
59
|
else
|
60
60
|
raise ArgumentError.new("not a valid statement: #{value.inspect}")
|
@@ -73,7 +73,7 @@ module RDF
|
|
73
73
|
# Inserts statements from the given RDF reader into the underlying
|
74
74
|
# storage or output stream.
|
75
75
|
#
|
76
|
-
# Defaults to passing the reader to the {#insert_statements} method.
|
76
|
+
# Defaults to passing the reader to the {RDF::Writable#insert_statements} method.
|
77
77
|
#
|
78
78
|
# Subclasses of {RDF::Repository} may wish to override this method in
|
79
79
|
# case their underlying storage can efficiently import RDF data directly
|
@@ -91,7 +91,7 @@ module RDF
|
|
91
91
|
# Inserts the given RDF graph into the underlying storage or output
|
92
92
|
# stream.
|
93
93
|
#
|
94
|
-
# Defaults to passing the graph to the {#insert_statements} method.
|
94
|
+
# Defaults to passing the graph to the {RDF::Writable#insert_statements} method.
|
95
95
|
#
|
96
96
|
# Subclasses of {RDF::Repository} may wish to override this method in
|
97
97
|
# case their underlying storage architecture is graph-centric rather
|
@@ -112,7 +112,7 @@ module RDF
|
|
112
112
|
# Inserts the given RDF statements into the underlying storage or output
|
113
113
|
# stream.
|
114
114
|
#
|
115
|
-
# Defaults to invoking {#insert_statement} for each given statement.
|
115
|
+
# Defaults to invoking {RDF::Writable#insert_statement} for each given statement.
|
116
116
|
#
|
117
117
|
# Subclasses of {RDF::Repository} may wish to override this method if
|
118
118
|
# they are capable of more efficiently inserting multiple statements at
|
data/lib/rdf/model/literal.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
module RDF; class Literal
|
2
|
+
##
|
3
|
+
# A String literal.
|
4
|
+
#
|
5
|
+
# @see http://www.w3.org/TR/xmlschema-2/#string
|
6
|
+
# @since 0.3.11
|
7
|
+
class String < Literal
|
8
|
+
DATATYPE = XSD.string
|
9
|
+
GRAMMAR = nil
|
10
|
+
|
11
|
+
##
|
12
|
+
# @param [Object] value
|
13
|
+
# @option options [String] :lexical (nil)
|
14
|
+
def initialize(value, options = {})
|
15
|
+
@datatype = options[:datatype] || self.class.const_get(:DATATYPE)
|
16
|
+
@string = options[:lexical] if options.has_key?(:lexical)
|
17
|
+
@string ||= value if value.is_a?(String)
|
18
|
+
@object = value.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Converts this literal into its canonical lexical representation.
|
23
|
+
#
|
24
|
+
# @return [RDF::Literal] `self`
|
25
|
+
# @see http://www.w3.org/TR/xml-exc-c14n/
|
26
|
+
def canonicalize!
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Returns the value as a string.
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
def to_s
|
35
|
+
@string || @object
|
36
|
+
end
|
37
|
+
end # XML
|
38
|
+
end; end # RDF::Literal
|
data/lib/rdf/model/statement.rb
CHANGED
data/lib/rdf/model/uri.rb
CHANGED
@@ -122,7 +122,7 @@ module RDF
|
|
122
122
|
##
|
123
123
|
# Creates a new `RDF::URI` instance based on the given `uri` string.
|
124
124
|
#
|
125
|
-
# This is just an alias for {
|
125
|
+
# This is just an alias for {RDF::URI#initialize} for compatibity
|
126
126
|
# with `Addressable::URI.parse`.
|
127
127
|
#
|
128
128
|
# @param [String, #to_s] str
|
@@ -136,7 +136,7 @@ module RDF
|
|
136
136
|
# @param [RDF::URI, String, #to_s] uri
|
137
137
|
#
|
138
138
|
# @overload URI.new(options = {})
|
139
|
-
# @param [Hash{Symbol => Object} options
|
139
|
+
# @param [Hash{Symbol => Object}] options
|
140
140
|
def initialize(uri_or_options)
|
141
141
|
case uri_or_options
|
142
142
|
when Hash
|
@@ -509,7 +509,7 @@ module RDF
|
|
509
509
|
alias_method :ends_with?, :end_with?
|
510
510
|
|
511
511
|
##
|
512
|
-
# Checks whether this URI the same term as `other
|
512
|
+
# Checks whether this URI the same term as `other`.
|
513
513
|
#
|
514
514
|
# @example
|
515
515
|
# RDF::URI('http://t.co/').eql?(RDF::URI('http://t.co/')) #=> true
|
data/lib/rdf/model/value.rb
CHANGED
data/lib/rdf/ntriples/writer.rb
CHANGED
@@ -4,7 +4,7 @@ module RDF::NTriples
|
|
4
4
|
#
|
5
5
|
# Output is serialized for UTF-8, to serialize as ASCII
|
6
6
|
# (with) unicode escapes, set :encoding => Encoding::ASCII as
|
7
|
-
# an option to {#initialize}.
|
7
|
+
# an option to {RDF::NTriples::Writer#initialize}.
|
8
8
|
#
|
9
9
|
# @example Obtaining an NTriples writer class
|
10
10
|
# RDF::Writer.for(:ntriples) #=> RDF::NTriples::Writer
|
data/lib/rdf/query.rb
CHANGED
@@ -6,7 +6,7 @@ module RDF
|
|
6
6
|
# contexts if the name is an RDF::Term or bound RDF::Query::Variable.
|
7
7
|
# Names that are against unbound variables match either default
|
8
8
|
# or named contexts.
|
9
|
-
# The name of `false
|
9
|
+
# The name of `false` will only match against the default context.
|
10
10
|
#
|
11
11
|
# Variable names cause the variable to be added to the solution set
|
12
12
|
# elements.
|
@@ -131,7 +131,7 @@ module RDF
|
|
131
131
|
# contexts if the name is an RDF::Term or bound RDF::Query::Variable.
|
132
132
|
# Names that are against unbound variables match either detault
|
133
133
|
# or named contexts.
|
134
|
-
# The name of `false
|
134
|
+
# The name of `false` will only match against the default context.
|
135
135
|
# @yield [query]
|
136
136
|
# @yieldparam [RDF::Query] query
|
137
137
|
# @yieldreturn [void] ignored
|
@@ -234,7 +234,7 @@ module RDF
|
|
234
234
|
# contexts if the name is an RDF::Term or bound RDF::Query::Variable.
|
235
235
|
# Names that are against unbound variables match either detault
|
236
236
|
# or named contexts.
|
237
|
-
# The name of `false
|
237
|
+
# The name of `false` will only match against the default context.
|
238
238
|
#
|
239
239
|
# @param [RDF::Queryable] queryable
|
240
240
|
# the graph or repository to query
|
data/lib/rdf/query/pattern.rb
CHANGED
@@ -124,7 +124,7 @@ module RDF; class Query
|
|
124
124
|
# If the optional `bindings` are given, variables will be substituted with their values
|
125
125
|
# when executing the query.
|
126
126
|
#
|
127
|
-
# To match triples only in the default context, set context to `false
|
127
|
+
# To match triples only in the default context, set context to `false`.
|
128
128
|
#
|
129
129
|
# @example
|
130
130
|
# Pattern.new(:s, :p, :o).execute(RDF::Repository.load('data.nt'))
|
data/lib/rdf/query/solutions.rb
CHANGED
@@ -106,7 +106,7 @@ module RDF; class Query
|
|
106
106
|
# Reorders this solution sequence by the given `variables`.
|
107
107
|
#
|
108
108
|
# Variables may be symbols or {Query::Variable} instances.
|
109
|
-
# A variable may also be a Procedure/Lambda, compatible with
|
109
|
+
# A variable may also be a Procedure/Lambda, compatible with `::Enumerable#sort`.
|
110
110
|
# This takes two arguments (solutions) and returns -1, 0, or 1 equivalently to <=>.
|
111
111
|
#
|
112
112
|
# If called with a block, variables are ignored, and the block is invoked with
|
data/lib/rdf/transaction.rb
CHANGED
@@ -83,7 +83,7 @@ module RDF
|
|
83
83
|
#
|
84
84
|
# Transactions do not support the `RDF::Enumerable` protocol directly.
|
85
85
|
# To enumerate the RDF statements to be inserted or deleted, use the
|
86
|
-
# {#inserts} and {#deletes} accessors.
|
86
|
+
# {RDF::Transaction#inserts} and {RDF::Transaction#deletes} accessors.
|
87
87
|
#
|
88
88
|
# @return [Boolean]
|
89
89
|
# @see RDF::Readable#readable?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-11-
|
14
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: addressable
|
@@ -36,7 +36,7 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ! '>='
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.8.3
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.8.3
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rdf-spec
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.3.
|
55
|
+
version: 0.3.11
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.3.
|
63
|
+
version: 0.3.11
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: rspec
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ! '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 2.
|
71
|
+
version: 2.12.0
|
72
72
|
type: :development
|
73
73
|
prerelease: false
|
74
74
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 2.
|
79
|
+
version: 2.12.0
|
80
80
|
description: RDF.rb is a pure-Ruby library for working with Resource Description Framework
|
81
81
|
(RDF) data.
|
82
82
|
email: public-rdf-ruby@w3.org
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/rdf/model/literal/double.rb
|
115
115
|
- lib/rdf/model/literal/integer.rb
|
116
116
|
- lib/rdf/model/literal/numeric.rb
|
117
|
+
- lib/rdf/model/literal/string.rb
|
117
118
|
- lib/rdf/model/literal/time.rb
|
118
119
|
- lib/rdf/model/literal/token.rb
|
119
120
|
- lib/rdf/model/literal/xml.rb
|
@@ -183,9 +184,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
- - ! '>='
|
184
185
|
- !ruby/object:Gem::Version
|
185
186
|
version: '0'
|
186
|
-
segments:
|
187
|
-
- 0
|
188
|
-
hash: -3969937466314581252
|
189
187
|
requirements: []
|
190
188
|
rubyforge_project: rdf
|
191
189
|
rubygems_version: 1.8.24
|