rdf-aggregate-repo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/README.md +66 -0
- data/UNLICENSE +24 -0
- data/VERSION +1 -0
- data/etc/doap.ttl +33 -0
- data/lib/rdf/aggregate_repo.rb +244 -0
- data/lib/rdf/aggregate_repo/merge_graph.rb +196 -0
- data/lib/rdf/aggregate_repo/version.rb +18 -0
- metadata +122 -0
data/AUTHORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* Gregg Kellogg <gregg@greggkellogg.net>
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# RDF::AggregateRepo
|
2
|
+
|
3
|
+
An aggregate RDF::Repository supporting a subset of named graphs and zero or more named graphs mapped to the default graph.
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/rdf-aggregate-repo.png)](http://badge.fury.io/rb/rdf-aggregate-repo)
|
6
|
+
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-aggregate-repo.png?branch=master)](http://travis-ci.org/ruby-rdf/rdf-aggregate-repo)
|
7
|
+
|
8
|
+
## Description
|
9
|
+
|
10
|
+
Maps named graphs from one or more `RDF::Queryable` instances into a single object, allowing a specific set of _named graphs_ to be seen, as well as a _default graph_ made up from one or more _named graphs_. This is used to implement [SPARQL Datasets][].
|
11
|
+
|
12
|
+
## Examples
|
13
|
+
|
14
|
+
require 'rdf'
|
15
|
+
require 'rdf/nquads'
|
16
|
+
repo = RDF::Repository.load("http://ruby-rdf.github.com/rdf/etc/doap.nq")
|
17
|
+
|
18
|
+
# Instantiate a new aggregate repo based on an existing repo
|
19
|
+
aggregate = RDF::AggregateRepo.new(repo)
|
20
|
+
|
21
|
+
# Use the default graph from the repo as the default graph of the aggregate
|
22
|
+
aggregate.add_default(false)
|
23
|
+
|
24
|
+
# Use a single named graph
|
25
|
+
aggregate.add_named(RDF::URI("http://greggkellogg.net/foaf#me"))
|
26
|
+
|
27
|
+
# Retrieve all contexts
|
28
|
+
aggreggate.contexts.to_a #=> [RDF::URI("http://greggkellogg.net/foaf#me")]
|
29
|
+
|
30
|
+
## Dependencies
|
31
|
+
|
32
|
+
* [Ruby](http://ruby-lang.org/) (>= 1.8.7) or (>= 1.8.1 with [Backports][])
|
33
|
+
* [RDF.rb][] (>= 1.0)
|
34
|
+
|
35
|
+
## Mailing List
|
36
|
+
|
37
|
+
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
|
38
|
+
|
39
|
+
## Author
|
40
|
+
|
41
|
+
* [Gregg Kellogg](http://github.com/gkellogg) - <http://kellogg-assoc.com/>
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
* Do your best to adhere to the existing coding conventions and idioms.
|
46
|
+
* Don't use hard tabs, and don't leave trailing whitespace on any line.
|
47
|
+
Before committing, run `git diff --check` to make sure of this.
|
48
|
+
* Do document every method you add using [YARD][] annotations. Read the
|
49
|
+
[tutorial][YARD-GS] or just look at the existing code for examples.
|
50
|
+
* Don't touch the `.gemspec` or `VERSION` files. If you need to change them,
|
51
|
+
do so on your private branch only.
|
52
|
+
* Do feel free to add yourself to the `CREDITS` file and the
|
53
|
+
corresponding list in the the `README`. Alphabetical order applies.
|
54
|
+
* Don't touch the `AUTHORS` file. If your contributions are significant
|
55
|
+
enough, be assured we will eventually add you in there.
|
56
|
+
* Do note that in order for us to merge any non-trivial changes (as a rule
|
57
|
+
of thumb, additions larger than about 15 lines of code), we need an
|
58
|
+
explicit [public domain dedication][PDD] on record from you.
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
This is free and unencumbered public domain software. For more information,
|
63
|
+
see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
|
64
|
+
|
65
|
+
[RDF.rb]: http://ruby-rdf.github.com/
|
66
|
+
[SPARQL Datasets]: http://www.w3.org/TR/sparql11-query/#rdfDataset
|
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/etc/doap.ttl
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
2
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
3
|
+
@prefix dc: <http://purl.org/dc/terms/> .
|
4
|
+
@prefix earl: <http://www.w3.org/ns/earl#> .
|
5
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
6
|
+
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
7
|
+
@prefix ex: <http://example.org/> .
|
8
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
9
|
+
|
10
|
+
<http://rubygems.org/gems/rdf-turtle> a doap:Project, earl:Software ;
|
11
|
+
doap:name "RDF::AggregateRepo" ;
|
12
|
+
doap:homepage <http://ruby-rdf.github.com/rdf-aggregate-repo> ;
|
13
|
+
doap:license <http://creativecommons.org/licenses/publicdomain/> ;
|
14
|
+
doap:shortdesc "An aggregate RDF::Repository supporting a subset of named graphs and zero or more named graphs mapped to the default graph."@en ;
|
15
|
+
doap:description "A gem extending RDF.rb with SPARQL dataset construction semantics."@en ;
|
16
|
+
doap:created "2013-04-26"^^xsd:date ;
|
17
|
+
doap:programming-language "Ruby" ;
|
18
|
+
doap:implements <http://www.w3.org/TR/sparql11-query/#specifyingDataset> ;
|
19
|
+
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
|
20
|
+
<http://dbpedia.org/resource/Ruby_(programming_language)> ;
|
21
|
+
doap:download-page <http://rubygems.org/gems/rdf-aggregate-repo> ;
|
22
|
+
doap:mailing-list <http://lists.w3.org/Archives/Public/public-rdf-ruby/> ;
|
23
|
+
doap:bug-database <http://github.com/ruby-rdf/rdf-aggregate-repo/issues> ;
|
24
|
+
doap:blog <http://greggkellogg.net/> ;
|
25
|
+
doap:developer <http://greggkellogg.net/foaf#me> ;
|
26
|
+
doap:maintainer <http://greggkellogg.net/foaf#me> ;
|
27
|
+
doap:documenter <http://greggkellogg.net/foaf#me> ;
|
28
|
+
foaf:maker <http://greggkellogg.net/foaf#me> ;
|
29
|
+
dc:title "RDF::AggregateRepo" ;
|
30
|
+
dc:description "A gem extending RDF.rb with SPARQL dataset construction semantics."@en ;
|
31
|
+
dc:date "2013-04-26"^^xsd:date ;
|
32
|
+
dc:creator <http://greggkellogg.net/foaf#me> ;
|
33
|
+
dc:isPartOf <http://rubygems.org/gems/rdf> .
|
@@ -0,0 +1,244 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
|
3
|
+
module RDF
|
4
|
+
autoload :MergeGraph, 'rdf/aggregate_repo/merge_graph'
|
5
|
+
autoload :VERSION, 'rdf/aggregate_repo/version'
|
6
|
+
|
7
|
+
##
|
8
|
+
# An aggregated RDF repository.
|
9
|
+
#
|
10
|
+
# Aggregates the default and named graphs from one or more instances
|
11
|
+
# implementing RDF::Queryable. By default, the aggregate projects
|
12
|
+
# no default or named graphs, which must be added explicitly.
|
13
|
+
#
|
14
|
+
# Adding the existing default graph (identified with the name `false`)
|
15
|
+
# adds the merge of all default graphs from the specified `queryable`
|
16
|
+
# instances.
|
17
|
+
#
|
18
|
+
# Adding a named graph, adds the last graph found having that name
|
19
|
+
# from the specified `queryable` instances.
|
20
|
+
#
|
21
|
+
# Updating a previously non-existing named graph, appends to the last source. Updating the default graph updates to the merge of the graphs.
|
22
|
+
#
|
23
|
+
# @example Constructing an aggregate with arguments
|
24
|
+
# aggregate = RDF::AggregateRepo.new(repo1, repo2)
|
25
|
+
#
|
26
|
+
# @example Constructing an aggregate with closure
|
27
|
+
# aggregate = RDF::AggregateRepo.new do
|
28
|
+
# source repo1
|
29
|
+
# source repo2
|
30
|
+
# default false
|
31
|
+
# named RDF::URI("http://example/")
|
32
|
+
# named RDF::URI("http://other/")
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# @todo Allow graph names to reassigned with queryable
|
36
|
+
class AggregateRepo < RDF::Repository
|
37
|
+
##
|
38
|
+
# The set of aggregated `queryable` instances included in this aggregate
|
39
|
+
#
|
40
|
+
# @return [Array<RDF::Queryable>]
|
41
|
+
attr_reader :sources
|
42
|
+
|
43
|
+
##
|
44
|
+
# Names of the named graphs making up the default graph, or
|
45
|
+
# false, if it is made up from the merger of all default
|
46
|
+
# graphs
|
47
|
+
#
|
48
|
+
# @return [Array<RDF::URI, false>]
|
49
|
+
attr_reader :defaults
|
50
|
+
|
51
|
+
##
|
52
|
+
# Create a new aggregation instance.
|
53
|
+
#
|
54
|
+
# @overload initialize(queryable = [], options = {})
|
55
|
+
# @param [Array<RDF::Queryable>] queryable ([])
|
56
|
+
# @param [Hash{Symbol => Object}] options ({})
|
57
|
+
# @yield aggregation
|
58
|
+
# @yieldparam [RDF::AggregateRepo] aggregation
|
59
|
+
# @yieldreturn [void] ignored
|
60
|
+
def initialize(*queryable, &block)
|
61
|
+
@options = queryable.last.is_a?(Hash) ? queryable.last.dup : {}
|
62
|
+
|
63
|
+
@sources = queryable
|
64
|
+
@defaults = []
|
65
|
+
@contexts = []
|
66
|
+
|
67
|
+
if block_given?
|
68
|
+
case block.arity
|
69
|
+
when 1 then block.call(self)
|
70
|
+
else instance_eval(&block)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Add a queryable to the set of constituent queryable instances
|
77
|
+
#
|
78
|
+
# @param [RDF::Queryable] queryable
|
79
|
+
# @return [RDF::AggregateRepo] self
|
80
|
+
def source(queryable)
|
81
|
+
@sources << queryable
|
82
|
+
@default_graph = nil
|
83
|
+
self
|
84
|
+
end
|
85
|
+
alias_method :add, :source
|
86
|
+
|
87
|
+
##
|
88
|
+
# Set the default graph based on zero or more
|
89
|
+
# named graphs, or the merge of all default graphs if `false`
|
90
|
+
#
|
91
|
+
# @param [Array<RDF::Resource>, false] names
|
92
|
+
# @return [RDF::AggregateRepo] self
|
93
|
+
def default(*names)
|
94
|
+
if names.any? {|n| n == false} && names.length > 1
|
95
|
+
raise ArgumentError, "If using merge of default graphs, there can be only one"
|
96
|
+
end
|
97
|
+
@default_graph = nil
|
98
|
+
@defaults = names
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# Add a named graph projection. Dynamically binds to the
|
103
|
+
# last `queryable` having a matching context.
|
104
|
+
#
|
105
|
+
# @param [RDF::Resource] name
|
106
|
+
# @return [RDF::AggregateRepo] self
|
107
|
+
def named(name)
|
108
|
+
raise ArgumentError, "name must be an RDF::Resource: #{name.inspect}" unless name.is_a?(RDF::Resource)
|
109
|
+
raise ArgumentError, "name does not exist in loaded sources" unless sources.any?{|s| s.has_context?(name)}
|
110
|
+
@contexts << name
|
111
|
+
end
|
112
|
+
|
113
|
+
# Repository overrides
|
114
|
+
|
115
|
+
##
|
116
|
+
# Not writable
|
117
|
+
#
|
118
|
+
# @return [false]
|
119
|
+
def writable?; false; end
|
120
|
+
|
121
|
+
##
|
122
|
+
# @private
|
123
|
+
# @see RDF::Durable#durable?
|
124
|
+
def durable?
|
125
|
+
sources.all?(&:durable?)
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# @private
|
130
|
+
# @see RDF::Countable#empty?
|
131
|
+
def empty?
|
132
|
+
count == 0
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# @private
|
137
|
+
# @see RDF::Countable#count
|
138
|
+
def count
|
139
|
+
each_graph.to_a.reduce(0) {|memo, g| memo += g.count}
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# @private
|
144
|
+
# @see RDF::Enumerable#has_statement?
|
145
|
+
def has_statement?(statement)
|
146
|
+
each_graph.to_a.any? {|g| g.has_statement?(statement)}
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# @private
|
151
|
+
# @see RDF::Repository#each_statement
|
152
|
+
# @see RDF::Enumerable#each_statement
|
153
|
+
def each_statement(&block)
|
154
|
+
if block_given?
|
155
|
+
# Invoke {#each} in the containing class:
|
156
|
+
each(&block)
|
157
|
+
end
|
158
|
+
enum_statement
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# @private
|
163
|
+
# @see RDF::Enumerable#each
|
164
|
+
def each(&block)
|
165
|
+
if block_given?
|
166
|
+
each_graph {|g| g.each(&block)}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# @private
|
172
|
+
# @see RDF::Enumerable#has_context?
|
173
|
+
def has_context?(value)
|
174
|
+
@contexts.include?(value)
|
175
|
+
end
|
176
|
+
|
177
|
+
##
|
178
|
+
# @private
|
179
|
+
# @see RDF::Enumerable#each_context
|
180
|
+
def each_context(&block)
|
181
|
+
if block_given?
|
182
|
+
@contexts.each(&block)
|
183
|
+
end
|
184
|
+
enum_context
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
##
|
189
|
+
# Iterate over each graph, in order, finding named graphs from the most recently added `source`.
|
190
|
+
#
|
191
|
+
# @see RDF::Enumerable#each_graph
|
192
|
+
def each_graph(&block)
|
193
|
+
if block_given?
|
194
|
+
block.call(default_graph)
|
195
|
+
|
196
|
+
# Send context from appropriate source
|
197
|
+
each_context do |context|
|
198
|
+
source = sources.reverse.detect {|s| s.has_context?(context)}
|
199
|
+
block.call(RDF::Graph.new(context, :data => source))
|
200
|
+
end
|
201
|
+
end
|
202
|
+
enum_graph
|
203
|
+
end
|
204
|
+
|
205
|
+
protected
|
206
|
+
|
207
|
+
##
|
208
|
+
def query_pattern(pattern, &block)
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# Default graph of this aggregate, either a projection of the source
|
213
|
+
# default graph (if `false`), a particular named graph from the
|
214
|
+
# last source in which it appears, or a MergeGraph composed of the
|
215
|
+
# graphs which compose it.
|
216
|
+
#
|
217
|
+
# @return [RDF::Graph]
|
218
|
+
def default_graph
|
219
|
+
@default_graph ||= begin
|
220
|
+
case
|
221
|
+
when sources.length == 0 || defaults.length == 0
|
222
|
+
RDF::Graph.new
|
223
|
+
when defaults.length == 1 && sources.length == 1
|
224
|
+
RDF::Graph.new((defaults.first || nil), :data => sources.first)
|
225
|
+
else
|
226
|
+
# Otherwise, create a MergeGraph from the set of pairs of source and context
|
227
|
+
RDF::MergeGraph.new(:name => nil) do
|
228
|
+
if defaults == [false]
|
229
|
+
sources.each do |s|
|
230
|
+
# Add default graph from each source
|
231
|
+
source s, false
|
232
|
+
end
|
233
|
+
else
|
234
|
+
each_context do |context|
|
235
|
+
# add the named graph
|
236
|
+
source sources.reverse.detect {|s| s.has_context?(context)}, context
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'rdf'
|
2
|
+
|
3
|
+
module RDF
|
4
|
+
##
|
5
|
+
# A Merged graph.
|
6
|
+
#
|
7
|
+
# Implements a merged graph, containing statements from one or more source graphs. This is done through lazy evaluation of the sources, so that a copy of each source isn't required.
|
8
|
+
#
|
9
|
+
# This class can also be used to change the context (graph name) of triples from the name used in the source.
|
10
|
+
#
|
11
|
+
# @example Constructing a merge with arguments
|
12
|
+
# aggregate = RDF::AggregateRepo.new(repo1, repo2)
|
13
|
+
#
|
14
|
+
# @example Constructing an aggregate with closure
|
15
|
+
# aggregate = RDF::MergeGraph.new do
|
16
|
+
# source graph1, context1
|
17
|
+
# source graph2, context2
|
18
|
+
# name false
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# @see http://www.w3.org/TR/rdf11-mt/#dfn-merge
|
22
|
+
class MergeGraph
|
23
|
+
include RDF::Value
|
24
|
+
include RDF::Countable
|
25
|
+
include RDF::Enumerable
|
26
|
+
include RDF::Queryable
|
27
|
+
|
28
|
+
##
|
29
|
+
# The set of aggregated `queryable` instances included in this aggregate
|
30
|
+
#
|
31
|
+
# @return [Array<Array<(RDF::Queryable, RDF::Resource)>>]
|
32
|
+
attr_reader :sources
|
33
|
+
|
34
|
+
##
|
35
|
+
# Name of this graph, used for setting the context on returned `Statements`.
|
36
|
+
#
|
37
|
+
# @return [Array<RDF::URI, false>]
|
38
|
+
attr_reader :context
|
39
|
+
|
40
|
+
##
|
41
|
+
# Create a new aggregation instance.
|
42
|
+
#
|
43
|
+
# @overload initialize(queryable = [], options = {})
|
44
|
+
# @param [Hash{Symbol => Object}] options ({})
|
45
|
+
# @option options [RDF::Resource] :context
|
46
|
+
# @option options [RDF::Resource] :name alias for :context
|
47
|
+
# @yield merger
|
48
|
+
# @yieldparam [RDF::MergeGraph] self
|
49
|
+
# @yieldreturn [void] ignored
|
50
|
+
def initialize(options = {}, &block)
|
51
|
+
@sources = []
|
52
|
+
@context = options[:context] || options[:name]
|
53
|
+
|
54
|
+
if block_given?
|
55
|
+
case block.arity
|
56
|
+
when 1 then block.call(self)
|
57
|
+
else instance_eval(&block)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
##
|
64
|
+
# Returns `true` to indicate that this is a graph.
|
65
|
+
#
|
66
|
+
# @return [Boolean]
|
67
|
+
def graph?
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Returns `true` if this is a named graph.
|
73
|
+
#
|
74
|
+
# @return [Boolean]
|
75
|
+
# @note The next release, graphs will not be named, this will return false
|
76
|
+
def named?
|
77
|
+
!unnamed?
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Returns `true` if this is a unnamed graph.
|
82
|
+
#
|
83
|
+
# @return [Boolean]
|
84
|
+
# @note The next release, graphs will not be named, this will return true
|
85
|
+
def unnamed?
|
86
|
+
@context.nil?
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# MergeGraph is writable if any source is writable. Updates go to the last writable source.
|
91
|
+
#
|
92
|
+
# @return [Boolean]
|
93
|
+
def writable?; sources.any?(&:writable?); end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Add a queryable to the set of constituent queryable instances
|
97
|
+
#
|
98
|
+
# @param [RDF::Queryable] queryable
|
99
|
+
# @return [RDF::MergeGraph] self
|
100
|
+
def source(queryable, context)
|
101
|
+
@sources << [queryable, context]
|
102
|
+
self
|
103
|
+
end
|
104
|
+
alias_method :add, :source
|
105
|
+
|
106
|
+
##
|
107
|
+
# Set the context for statements in this graph
|
108
|
+
#
|
109
|
+
# @param [RDF::Resource, false] name
|
110
|
+
# @return [RDF::MergeGraph] self
|
111
|
+
def name(name)
|
112
|
+
@context = name
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
# Repository overrides
|
117
|
+
|
118
|
+
##
|
119
|
+
# @private
|
120
|
+
# @see RDF::Durable#durable?
|
121
|
+
def durable?
|
122
|
+
sources.all?(&:durable?)
|
123
|
+
end
|
124
|
+
|
125
|
+
##
|
126
|
+
# @private
|
127
|
+
# @see RDF::Countable#empty?
|
128
|
+
def empty?
|
129
|
+
count == 0
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# @private
|
134
|
+
# @see RDF::Countable#count
|
135
|
+
def count
|
136
|
+
each_statement.to_a.length
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# @private
|
141
|
+
# @see RDF::Enumerable#has_statement?
|
142
|
+
def has_statement?(statement)
|
143
|
+
sources.any? do |(source, ctx)|
|
144
|
+
statement = statement.dup
|
145
|
+
statement.context = ctx
|
146
|
+
source.has_statement?(statement)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# @see RDF::Enumerable#each_statement
|
152
|
+
def each(&block)
|
153
|
+
# Add everything to a new graph for de-duplication
|
154
|
+
tmp = RDF::Graph.new(@context)
|
155
|
+
sources.each do |(source, ctx)|
|
156
|
+
tmp << RDF::Graph.new(ctx || nil, :data => source)
|
157
|
+
end
|
158
|
+
tmp.each(&block)
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# @private
|
163
|
+
# @see RDF::Enumerable#has_context?
|
164
|
+
def has_context?(value)
|
165
|
+
@context == value
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# @private
|
170
|
+
# @see RDF::Enumerable#each_context
|
171
|
+
def each_context(&block)
|
172
|
+
if block_given?
|
173
|
+
block.call(context) if context
|
174
|
+
end
|
175
|
+
enum_context
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
##
|
180
|
+
# Iterate over each graph, in order, finding named graphs from the most recently added `source`.
|
181
|
+
#
|
182
|
+
# @see RDF::Enumerable#each_graph
|
183
|
+
def each_graph(&block)
|
184
|
+
if block_given?
|
185
|
+
block.call(self)
|
186
|
+
end
|
187
|
+
enum_graph
|
188
|
+
end
|
189
|
+
|
190
|
+
protected
|
191
|
+
|
192
|
+
##
|
193
|
+
def query_pattern(pattern, &block)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RDF::Turtle::VERSION
|
2
|
+
VERSION_FILE = File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "..", "VERSION")
|
3
|
+
MAJOR, MINOR, TINY, EXTRA = File.read(VERSION_FILE).chop.split(".")
|
4
|
+
|
5
|
+
STRING = [MAJOR, MINOR, TINY, EXTRA].compact.join('.')
|
6
|
+
|
7
|
+
##
|
8
|
+
# @return [String]
|
9
|
+
def self.to_s() STRING end
|
10
|
+
|
11
|
+
##
|
12
|
+
# @return [String]
|
13
|
+
def self.to_str() STRING end
|
14
|
+
|
15
|
+
##
|
16
|
+
# @return [Array(Integer, Integer, Integer)]
|
17
|
+
def self.to_a() STRING.split(".") end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdf-aggregate-repo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gregg Kellogg
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdf
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdf-spec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.8'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.8'
|
78
|
+
description: A gem extending RDF.rb with SPARQL dataset construction semantics.
|
79
|
+
email: public-rdf-ruby@w3.org
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files: []
|
83
|
+
files:
|
84
|
+
- AUTHORS
|
85
|
+
- README.md
|
86
|
+
- UNLICENSE
|
87
|
+
- VERSION
|
88
|
+
- etc/doap.ttl
|
89
|
+
- lib/rdf/aggregate_repo/merge_graph.rb
|
90
|
+
- lib/rdf/aggregate_repo/version.rb
|
91
|
+
- lib/rdf/aggregate_repo.rb
|
92
|
+
homepage: http://ruby-rdf.github.com/rdf-aggregate-repo
|
93
|
+
licenses:
|
94
|
+
- Public Domain
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.8.7
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
hash: 2958421905290465049
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.8.25
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: An aggregate RDF::Repository supporting a subset of named graphs and zero
|
120
|
+
or more named graphs mapped to the default graph.
|
121
|
+
test_files: []
|
122
|
+
has_rdoc: false
|