rdf 0.1.6.1 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rdf/format.rb +1 -1
- data/lib/rdf/mixin/enumerable.rb +6 -6
- data/lib/rdf/mixin/mutable.rb +1 -1
- data/lib/rdf/model/graph.rb +42 -2
- data/lib/rdf/model/value.rb +8 -0
- data/lib/rdf/query/pattern.rb +2 -2
- data/lib/rdf/query/variable.rb +9 -0
- data/lib/rdf/repository.rb +9 -1
- data/lib/rdf/version.rb +2 -2
- metadata +3 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/rdf/format.rb
CHANGED
@@ -109,7 +109,7 @@ module RDF
|
|
109
109
|
else
|
110
110
|
format = format.to_s.downcase
|
111
111
|
@@subclasses.each do |klass|
|
112
|
-
if klass.name.to_s.split('::').map
|
112
|
+
if klass.name.to_s.split('::').map { |x| x.downcase }.include?(format)
|
113
113
|
return klass
|
114
114
|
end
|
115
115
|
end
|
data/lib/rdf/mixin/enumerable.rb
CHANGED
@@ -146,7 +146,7 @@ module RDF
|
|
146
146
|
# @see #each_triple
|
147
147
|
# @see #enum_triple
|
148
148
|
def triples(options = {})
|
149
|
-
enum_statement.map
|
149
|
+
enum_statement.map { |statement| statement.to_triple }
|
150
150
|
end
|
151
151
|
|
152
152
|
##
|
@@ -205,7 +205,7 @@ module RDF
|
|
205
205
|
# @see #each_quad
|
206
206
|
# @see #enum_quad
|
207
207
|
def quads(options = {})
|
208
|
-
enum_statement.map
|
208
|
+
enum_statement.map { |statement| statement.to_quad }
|
209
209
|
end
|
210
210
|
|
211
211
|
##
|
@@ -267,7 +267,7 @@ module RDF
|
|
267
267
|
# @see #enum_subject
|
268
268
|
def subjects(options = {})
|
269
269
|
if options[:unique] == false
|
270
|
-
enum_statement.map
|
270
|
+
enum_statement.map { |statement| statement.subject }
|
271
271
|
else
|
272
272
|
enum_subject.to_a
|
273
273
|
end
|
@@ -334,7 +334,7 @@ module RDF
|
|
334
334
|
# @see #enum_predicate
|
335
335
|
def predicates(options = {})
|
336
336
|
if options[:unique] == false
|
337
|
-
enum_statement.map
|
337
|
+
enum_statement.map { |statement| statement.predicate }
|
338
338
|
else
|
339
339
|
enum_predicate.to_a
|
340
340
|
end
|
@@ -401,7 +401,7 @@ module RDF
|
|
401
401
|
# @see #enum_object
|
402
402
|
def objects(options = {})
|
403
403
|
if options[:unique] == false
|
404
|
-
enum_statement.map
|
404
|
+
enum_statement.map { |statement| statement.object }
|
405
405
|
else
|
406
406
|
enum_object.to_a
|
407
407
|
end
|
@@ -468,7 +468,7 @@ module RDF
|
|
468
468
|
# @see #enum_context
|
469
469
|
def contexts(options = {})
|
470
470
|
if options[:unique] == false
|
471
|
-
enum_statement.map
|
471
|
+
enum_statement.map { |statement| statement.context }
|
472
472
|
else
|
473
473
|
enum_context.to_a
|
474
474
|
end
|
data/lib/rdf/mixin/mutable.rb
CHANGED
data/lib/rdf/model/graph.rb
CHANGED
@@ -14,6 +14,36 @@ module RDF
|
|
14
14
|
# @return [Array<Statement>]
|
15
15
|
attr_accessor :data
|
16
16
|
|
17
|
+
##
|
18
|
+
# Creates a new `Graph` instance populated by the RDF data returned by
|
19
|
+
# dereferencing the given context URL.
|
20
|
+
#
|
21
|
+
# @overload
|
22
|
+
# @param [String, #to_s] url
|
23
|
+
# @param [Hash{Symbol => Object}] options
|
24
|
+
# @yield [graph]
|
25
|
+
# @yieldparam [Graph] graph
|
26
|
+
# @return [void]
|
27
|
+
#
|
28
|
+
# @overload
|
29
|
+
# @param [String, #to_s] url
|
30
|
+
# @param [Hash{Symbol => Object}] options
|
31
|
+
# @return [Graph]
|
32
|
+
#
|
33
|
+
# @return [void]
|
34
|
+
def self.load(url, options = {}, &block)
|
35
|
+
self.new(url, options) do |graph|
|
36
|
+
graph.load! unless graph.unnamed?
|
37
|
+
|
38
|
+
if block_given?
|
39
|
+
case block.arity
|
40
|
+
when 1 then block.call(graph)
|
41
|
+
else graph.instance_eval(&block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
17
47
|
##
|
18
48
|
# @param [Resource] context
|
19
49
|
# @param [Hash{Symbol => Object}] options
|
@@ -26,8 +56,8 @@ module RDF
|
|
26
56
|
else RDF::URI.new(context)
|
27
57
|
end
|
28
58
|
|
29
|
-
@
|
30
|
-
@options
|
59
|
+
@options = options.dup
|
60
|
+
@data = @options.delete(:data) || []
|
31
61
|
|
32
62
|
if block_given?
|
33
63
|
case block.arity
|
@@ -37,6 +67,16 @@ module RDF
|
|
37
67
|
end
|
38
68
|
end
|
39
69
|
|
70
|
+
##
|
71
|
+
# @return [void]
|
72
|
+
def load!(*args)
|
73
|
+
case
|
74
|
+
when args.empty?
|
75
|
+
load(context.to_s, context ? {:base_uri => context}.merge(@options) : @options)
|
76
|
+
else super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
40
80
|
##
|
41
81
|
# Returns `true` to indicate that this is a graph.
|
42
82
|
#
|
data/lib/rdf/model/value.rb
CHANGED
data/lib/rdf/query/pattern.rb
CHANGED
@@ -108,7 +108,7 @@ class RDF::Query
|
|
108
108
|
#
|
109
109
|
# @return [Boolean]
|
110
110
|
def bound?
|
111
|
-
!variables.empty? && variables.values.all?
|
111
|
+
!variables.empty? && variables.values.all? { |var| var.bound? }
|
112
112
|
end
|
113
113
|
|
114
114
|
##
|
@@ -124,7 +124,7 @@ class RDF::Query
|
|
124
124
|
#
|
125
125
|
# @return [Boolean]
|
126
126
|
def unbound?
|
127
|
-
!variables.empty? && variables.values.all?
|
127
|
+
!variables.empty? && variables.values.all? { |var| var.unbound? }
|
128
128
|
end
|
129
129
|
|
130
130
|
##
|
data/lib/rdf/query/variable.rb
CHANGED
@@ -54,6 +54,15 @@ class RDF::Query
|
|
54
54
|
@name, @value = name.to_sym, value
|
55
55
|
end
|
56
56
|
|
57
|
+
##
|
58
|
+
# Returns `true`.
|
59
|
+
#
|
60
|
+
# @return [Boolean]
|
61
|
+
# @see RDF::Value#variable?
|
62
|
+
def variable?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
57
66
|
##
|
58
67
|
# Returns `true` if this variable has a name.
|
59
68
|
#
|
data/lib/rdf/repository.rb
CHANGED
@@ -108,7 +108,15 @@ module RDF
|
|
108
108
|
end
|
109
109
|
|
110
110
|
##
|
111
|
-
#
|
111
|
+
# Returns a developer-friendly representation of this object.
|
112
|
+
#
|
113
|
+
# @return [String]
|
114
|
+
def inspect
|
115
|
+
sprintf("#<%s:%#0x(%s)>", self.class.name, object_id, uri.to_s)
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Outputs a developer-friendly representation of this object to
|
112
120
|
# `stderr`.
|
113
121
|
#
|
114
122
|
# @return [void]
|
data/lib/rdf/version.rb
CHANGED
metadata
CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.1.6.1
|
8
|
+
- 7
|
9
|
+
version: 0.1.7
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Arto Bendiken
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-16 00:00:00 +02:00
|
20
19
|
default_executable: rdf
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|