rdf-aggregate-repo 1.1.0.1 → 1.99.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 071df965575f4007e99728b60463dd145accb85c
4
- data.tar.gz: 0ffc8849b0d2a324f28d76842bcb7a221bc0bc7f
3
+ metadata.gz: 3a4dd65e6ddcb82e9abbe6477d60a823ba6a443b
4
+ data.tar.gz: ee446e02cb255fef1405b856ce582a79b7906ca1
5
5
  SHA512:
6
- metadata.gz: 874b8cdc42f583f2484d8a50ec2e18706b9c7b633b5755e43817761e373d6b764cb5d1d9cf32ff7737e54802e310d941c373e8c09ad74f992ec4cd90ecccb7e3
7
- data.tar.gz: 3f9dbfefca6ae23e173c0a1ea290cfd81751de34d6ec217c8882e500c6f3a1db741c7fa4f1102bf5094cf19de3c491dd5cbe413ce5126135df6ea4864b08757b
6
+ metadata.gz: 76ea80547ca6e67842191f92a940eb47d4300184ce30a775ae10f05c90b45f75e2631ecc01606491e57a4ea5295d7c7603c4234684e76d8c38e14c81d66edad1
7
+ data.tar.gz: 721aac81e2d62d5fe0f15121f170bb1b31ed5a740039e159dbf7fbd413dcfa19d781d3889a98fc01b2751705121e753a778b1fe340f570a1ab74f52e70a246a8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0.1
1
+ 1.99.0
@@ -62,7 +62,7 @@ module RDF
62
62
 
63
63
  @sources = queryable
64
64
  @defaults = []
65
- @contexts = []
65
+ @named_graphs = []
66
66
 
67
67
  if block_given?
68
68
  case block.arity
@@ -100,14 +100,14 @@ module RDF
100
100
 
101
101
  ##
102
102
  # Add a named graph projection. Dynamically binds to the
103
- # last `queryable` having a matching context.
103
+ # last `queryable` having a matching graph.
104
104
  #
105
105
  # @param [RDF::Resource] name
106
106
  # @return [RDF::AggregateRepo] self
107
107
  def named(name)
108
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
109
+ raise ArgumentError, "name does not exist in loaded sources" unless sources.any?{|s| s.has_graph?(name)}
110
+ @named_graphs << name
111
111
  end
112
112
 
113
113
  # Repository overrides
@@ -196,43 +196,16 @@ module RDF
196
196
  end
197
197
 
198
198
  ##
199
- # Returns `true` if any constituent grahp contains the given RDF context.
199
+ # Returns `true` if any constituent grahp contains the given RDF graph.
200
200
  #
201
201
  # @param [RDF::Resource, false] value
202
- # Use value `false` to query for the default context
202
+ # Use value `false` to query for the default graph
203
203
  # @return [Boolean]
204
- # @see RDF::Enumerable#has_context?
205
- def has_context?(value)
206
- @contexts.include?(value)
204
+ # @see RDF::Enumerable#has_graph?
205
+ def has_graph?(value)
206
+ @named_graphs.include?(value)
207
207
  end
208
208
 
209
- ##
210
- # Iterates the given block for each unique RDF context, other than the default context.
211
- #
212
- # If no block was given, returns an enumerator.
213
- #
214
- # The order in which values are yielded is undefined.
215
- #
216
- # @overload each_context
217
- # @yield [context]
218
- # each context term
219
- # @yieldparam [RDF::Resource] context
220
- # @yieldreturn [void] ignored
221
- # @return [void]
222
- #
223
- # @overload each_context
224
- # @return [Enumerator]
225
- #
226
- # @return [void]
227
- # @see RDF::Enumerable#each_context
228
- def each_context(&block)
229
- if block_given?
230
- @contexts.each(&block)
231
- end
232
- enum_context
233
- end
234
-
235
-
236
209
  ##
237
210
  # Iterate over each graph, in order, finding named graphs from the most recently added `source`.
238
211
  #
@@ -248,18 +221,17 @@ module RDF
248
221
  # @return [void]
249
222
  #
250
223
  # @overload each_graph
251
- # @return [Enumerator]
224
+ # @return [Enumerator<RDF::Graph>]
252
225
  #
253
- # @return [void]
254
226
  # @see RDF::Enumerable#each_graph
255
227
  def each_graph(&block)
256
228
  if block_given?
257
- block.call(default_graph)
229
+ yield default_graph
258
230
 
259
- # Send context from appropriate source
260
- each_context do |context|
261
- source = sources.reverse.detect {|s| s.has_context?(context)}
262
- block.call(RDF::Graph.new(context, :data => source))
231
+ # Send graph from appropriate source
232
+ @named_graphs.each do |graph_name|
233
+ source = sources.reverse.detect {|s| s.has_graph?(graph_name)}
234
+ block.call(RDF::Graph.new(graph_name, data: source))
263
235
  end
264
236
  end
265
237
  enum_graph
@@ -277,20 +249,21 @@ module RDF
277
249
  case
278
250
  when sources.length == 0 || defaults.length == 0
279
251
  RDF::Graph.new
280
- when defaults.length == 1 && sources.length == 1
281
- RDF::Graph.new((defaults.first || nil), :data => sources.first)
252
+ when defaults == [false] && sources.length == 1
253
+ # Trivial case
254
+ RDF::Graph.new(nil, data: sources.first)
282
255
  else
283
- # Otherwise, create a MergeGraph from the set of pairs of source and context
284
- RDF::MergeGraph.new(:name => nil) do |graph|
256
+ # Otherwise, create a MergeGraph from the set of pairs of source and graph_name
257
+ RDF::MergeGraph.new(name: nil) do |graph|
285
258
  if defaults == [false]
286
259
  graph.sources.each do |s|
287
260
  # Add default graph from each source
288
261
  source s, false
289
262
  end
290
263
  else
291
- defaults.each do |context|
264
+ defaults.each do |graph_name|
292
265
  # add the named graph
293
- graph.source sources.reverse.detect {|s| s.has_context?(context)}, context
266
+ graph.source sources.reverse.detect {|s| s.has_graph?(graph_name)}, graph_name
294
267
  end
295
268
  end
296
269
  end
@@ -312,7 +285,7 @@ module RDF
312
285
  # @return [void] ignored
313
286
  # @see RDF::Queryable#query_pattern
314
287
  def query_pattern(pattern, &block)
315
- case pattern.context
288
+ case pattern.graph_name
316
289
  when nil
317
290
  # Query against all graphs
318
291
  each_graph {|graph| graph.send(:query_pattern, pattern, &block)}
@@ -321,15 +294,15 @@ module RDF
321
294
  default_graph.send(:query_pattern, pattern, &block)
322
295
  when RDF::Query::Variable
323
296
  # Query against all named graphs
324
- each_context do |context|
325
- source = sources.reverse.detect {|s| s.has_context?(context)}
326
- RDF::Graph.new(context, :data => source).send(:query_pattern, pattern, &block)
297
+ each_graph do |graph|
298
+ source = sources.reverse.detect {|s| s.has_graph?(graph.graph_name)}
299
+ RDF::Graph.new(graph.graph_name, data: source).send(:query_pattern, pattern, &block)
327
300
  end
328
301
  else
329
- # Query against a specific context
330
- if @contexts.include?(pattern.context)
331
- source = sources.reverse.detect {|s| s.has_context?(pattern.context)}
332
- RDF::Graph.new(pattern.context, :data => source).send(:query_pattern, pattern, &block)
302
+ # Query against a specific graph
303
+ if @named_graphs.include?(pattern.graph_name)
304
+ source = sources.reverse.detect {|s| s.has_graph?(pattern.graph_name)}
305
+ RDF::Graph.new(pattern.graph_name, data: source).send(:query_pattern, pattern, &block)
333
306
  end
334
307
  end
335
308
  end
@@ -35,21 +35,21 @@ module RDF
35
35
  # Name of this graph, used for setting the context on returned `Statements`.
36
36
  #
37
37
  # @return [Array<RDF::URI, false>]
38
- attr_reader :context
38
+ attr_reader :graph_name
39
39
 
40
40
  ##
41
41
  # Create a new aggregation instance.
42
42
  #
43
43
  # @overload initialize(queryable = [], options = {})
44
44
  # @param [Hash{Symbol => Object}] options ({})
45
- # @option options [RDF::Resource] :context
46
- # @option options [RDF::Resource] :name alias for :context
45
+ # @option options [RDF::Resource] :graph_name
46
+ # @option options [RDF::Resource] :name alias for :graph_name
47
47
  # @yield merger
48
48
  # @yieldparam [RDF::MergeGraph] self
49
49
  # @yieldreturn [void] ignored
50
50
  def initialize(options = {}, &block)
51
51
  @sources = []
52
- @context = options[:context] || options[:name]
52
+ @graph_name = options[:graph_name] || options[:name]
53
53
 
54
54
  if block_given?
55
55
  case block.arity
@@ -83,7 +83,7 @@ module RDF
83
83
  # @return [Boolean]
84
84
  # @note The next release, graphs will not be named, this will return true
85
85
  def unnamed?
86
- @context.nil?
86
+ @graph_name.nil?
87
87
  end
88
88
 
89
89
  ##
@@ -98,21 +98,21 @@ module RDF
98
98
  # Add a queryable to the set of constituent queryable instances
99
99
  #
100
100
  # @param [RDF::Queryable] queryable
101
- # @param [RDF::Resource] context
101
+ # @param [RDF::Resource] graph_name
102
102
  # @return [RDF::MergeGraph] self
103
- def source(queryable, context)
104
- @sources << [queryable, context]
103
+ def source(queryable, graph_name)
104
+ @sources << [queryable, graph_name]
105
105
  self
106
106
  end
107
107
  alias_method :add, :source
108
108
 
109
109
  ##
110
- # Set the context for statements in this graph
110
+ # Set the graph_name for statements in this graph
111
111
  #
112
112
  # @param [RDF::Resource, false] name
113
113
  # @return [RDF::MergeGraph] self
114
114
  def name(name)
115
- @context = name
115
+ @graph_name = name
116
116
  self
117
117
  end
118
118
 
@@ -145,7 +145,7 @@ module RDF
145
145
  def has_statement?(statement)
146
146
  sources.any? do |(source, ctx)|
147
147
  statement = statement.dup
148
- statement.context = ctx
148
+ statement.graph_name = ctx
149
149
  source.has_statement?(statement)
150
150
  end
151
151
  end
@@ -156,38 +156,27 @@ module RDF
156
156
  return enum_for(:each) unless block_given?
157
157
 
158
158
  # Add everything to a new graph for de-duplication
159
- tmp = RDF::Graph.new(@context, :data => RDF::Repository.new)
160
- sources.each do |(source, ctx)|
161
- tmp << RDF::Graph.new(ctx || nil, :data => source)
159
+ tmp = RDF::Graph.new(@graph_name, data: RDF::Repository.new)
160
+ sources.each do |(source, gn)|
161
+ tmp << RDF::Graph.new(gn || nil, data: source)
162
162
  end
163
163
  tmp.each(&block)
164
164
  end
165
165
 
166
166
  ##
167
167
  # @private
168
- # @see RDF::Enumerable#has_context?
169
- def has_context?(value)
170
- @context == value
168
+ # @see RDF::Enumerable#has_graph?
169
+ def has_graph?(value)
170
+ @graph_name == value
171
171
  end
172
172
 
173
- ##
174
- # @private
175
- # @see RDF::Enumerable#each_context
176
- def each_context(&block)
177
- if block_given?
178
- block.call(context) if context
179
- end
180
- enum_context
181
- end
182
-
183
-
184
173
  ##
185
174
  # Iterate over each graph, in order, finding named graphs from the most recently added `source`.
186
175
  #
187
176
  # @see RDF::Enumerable#each_graph
188
177
  def each_graph(&block)
189
178
  if block_given?
190
- block.call(self)
179
+ yield self
191
180
  end
192
181
  enum_graph
193
182
  end
@@ -199,8 +188,8 @@ module RDF
199
188
  # @see RDF::Queryable#query_pattern
200
189
  def query_pattern(pattern, &block)
201
190
  pattern = pattern.dup
202
- sources.each do |(source, ctx)|
203
- pattern.context = ctx
191
+ sources.each do |(source, gn)|
192
+ pattern.graph_name = gn
204
193
  source.send(:query_pattern, pattern, &block)
205
194
  end
206
195
  end
metadata CHANGED
@@ -1,23 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-aggregate-repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0.1
4
+ version: 1.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-09 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.1'
20
- - - "<"
21
18
  - !ruby/object:Gem::Version
22
19
  version: '1.99'
23
20
  type: :runtime
@@ -25,9 +22,6 @@ dependencies:
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.1'
30
- - - "<"
31
25
  - !ruby/object:Gem::Version
32
26
  version: '1.99'
33
27
  - !ruby/object:Gem::Dependency
@@ -35,9 +29,6 @@ dependencies:
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.1'
40
- - - "<"
41
32
  - !ruby/object:Gem::Version
42
33
  version: '1.99'
43
34
  type: :development
@@ -45,9 +36,6 @@ dependencies:
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
38
  - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '1.1'
50
- - - "<"
51
39
  - !ruby/object:Gem::Version
52
40
  version: '1.99'
53
41
  - !ruby/object:Gem::Dependency
@@ -55,9 +43,6 @@ dependencies:
55
43
  requirement: !ruby/object:Gem::Requirement
56
44
  requirements:
57
45
  - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '1.1'
60
- - - "<"
61
46
  - !ruby/object:Gem::Version
62
47
  version: '1.99'
63
48
  type: :development
@@ -65,9 +50,6 @@ dependencies:
65
50
  version_requirements: !ruby/object:Gem::Requirement
66
51
  requirements:
67
52
  - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.1'
70
- - - "<"
71
53
  - !ruby/object:Gem::Version
72
54
  version: '1.99'
73
55
  - !ruby/object:Gem::Dependency
@@ -76,14 +58,14 @@ dependencies:
76
58
  requirements:
77
59
  - - "~>"
78
60
  - !ruby/object:Gem::Version
79
- version: '3.0'
61
+ version: '3.2'
80
62
  type: :development
81
63
  prerelease: false
82
64
  version_requirements: !ruby/object:Gem::Requirement
83
65
  requirements:
84
66
  - - "~>"
85
67
  - !ruby/object:Gem::Version
86
- version: '3.0'
68
+ version: '3.2'
87
69
  - !ruby/object:Gem::Dependency
88
70
  name: rspec-its
89
71
  requirement: !ruby/object:Gem::Requirement
@@ -138,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
120
  requirements:
139
121
  - - ">="
140
122
  - !ruby/object:Gem::Version
141
- version: 1.9.2
123
+ version: 1.9.3
142
124
  required_rubygems_version: !ruby/object:Gem::Requirement
143
125
  requirements:
144
126
  - - ">="