rdf-mongo 1.99.0 → 2.0.0.beta1
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/mongo/version.rb +1 -1
- data/lib/rdf/mongo.rb +62 -42
- metadata +41 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf15f8c6d12d55bd85991a3e6bf8ab4ee318568b
|
4
|
+
data.tar.gz: 78e563de1eccb9af04635ebf61cd3b8feb181858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf281484d6946e53cd6edaf7c83715fe98021f4114cfaf2efad1c1525eb6b39f2ae90de862cdbaa38e6df54513855bd6dfe547356e433ae38657c16e67d34ccf
|
7
|
+
data.tar.gz: 87489d3773aaed971a6060d37139a22440d493ca1ad321fa2e141e1f0e35672212dde03a8a37ea350edd60d8af1b1398b71f85bdab7b640e33c154b181ecf075
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.beta1
|
data/lib/rdf/mongo/version.rb
CHANGED
data/lib/rdf/mongo.rb
CHANGED
@@ -80,7 +80,7 @@ module RDF
|
|
80
80
|
t, k1, lt = :ct, :c, :cl
|
81
81
|
end
|
82
82
|
h = {k1 => v, t => k, lt => ll}
|
83
|
-
h.delete_if {|
|
83
|
+
h.delete_if {|kk,_| h[kk].nil?}
|
84
84
|
end
|
85
85
|
|
86
86
|
##
|
@@ -108,41 +108,63 @@ module RDF
|
|
108
108
|
|
109
109
|
class Repository < ::RDF::Repository
|
110
110
|
# The Mongo database instance
|
111
|
-
# @!attribute [r] db
|
112
111
|
# @return [Mongo::DB]
|
113
|
-
attr_reader :
|
112
|
+
attr_reader :client
|
114
113
|
|
115
114
|
# The collection used for storing quads
|
116
|
-
# @!attribute [r] coll
|
117
115
|
# @return [Mongo::Collection]
|
118
|
-
attr_reader :
|
116
|
+
attr_reader :collection
|
119
117
|
|
120
118
|
##
|
121
119
|
# Initializes this repository instance.
|
122
120
|
#
|
123
|
-
# @
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
# @
|
130
|
-
#
|
131
|
-
#
|
121
|
+
# @overload initialize(options = {}, &block)
|
122
|
+
# @param [Hash{Symbol => Object}] options
|
123
|
+
# @option options [String, #to_s] :title (nil)
|
124
|
+
# @option options [URI, #to_s] :uri (nil)
|
125
|
+
# URI in the form `mongodb://host:port/db`. The URI should also identify the collection use, but appending a `collection` path component such as `mongodb://host:port/db/collection`, this ensures that the collection will be maintained if cloned. See [Mongo::Client options](https://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial-2-0/#uri-options-conversions) for more information on Mongo URIs.
|
126
|
+
#
|
127
|
+
# @overload initialize(options = {}, &block)
|
128
|
+
# @param [Hash{Symbol => Object}] options
|
129
|
+
# See [Mongo::Client options](https://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial-2-0/#uri-options-conversions) for more information on Mongo Client options.
|
130
|
+
# @option options [String, #to_s] :title (nil)
|
131
|
+
# @option options [String] :host
|
132
|
+
# a single address or an array of addresses, which may contain a port designation
|
133
|
+
# @option options [Integer] :port (27017) applied to host address(es)
|
134
|
+
# @option options [String] :database ('quadb')
|
135
|
+
# @option options [String] :collection ('quads')
|
136
|
+
#
|
132
137
|
# @yield [repository]
|
133
138
|
# @yieldparam [Repository] repository
|
134
139
|
def initialize(options = {}, &block)
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
140
|
+
collection = nil
|
141
|
+
if options[:uri]
|
142
|
+
options = options.dup
|
143
|
+
uri = RDF::URI(options.delete(:uri))
|
144
|
+
_, db, coll = uri.path.split('/')
|
145
|
+
collection = coll || options.delete(:collection)
|
146
|
+
db ||= "quadb"
|
147
|
+
uri.path = "/#{db}" if coll
|
148
|
+
@client = ::Mongo::Client.new(uri.to_s, options)
|
149
|
+
else
|
150
|
+
warn "[DEPRECATION] RDF::Mongo::Repository#initialize expects a uri argument. Called from #{Gem.location_of_caller.join(':')}" unless options.empty?
|
151
|
+
options[:database] ||= options.delete(:db) # 1.x compat
|
152
|
+
options[:database] ||= 'quadb'
|
153
|
+
hosts = Array(options[:host] || 'localhost')
|
154
|
+
hosts.map! {|h| "#{h}:#{options[:port]}"} if options[:port]
|
155
|
+
@client = ::Mongo::Client.new(hosts, options)
|
156
|
+
end
|
157
|
+
|
158
|
+
@collection = @client[options.delete(:collection) || 'quads']
|
159
|
+
@collection.indexes.create_many([
|
160
|
+
{key: {s: 1}},
|
161
|
+
{key: {p: 1}},
|
162
|
+
{key: {o: "hashed"}},
|
163
|
+
{key: {c: 1}},
|
164
|
+
{key: {s: 1, p: 1}},
|
165
|
+
#{key: {s: 1, o: "hashed"}}, # Muti-key hashed indexes not allowed
|
166
|
+
#{key: {p: 1, o: "hashed"}}, # Muti-key hashed indexes not allowed
|
167
|
+
])
|
146
168
|
super(options, &block)
|
147
169
|
end
|
148
170
|
|
@@ -150,6 +172,7 @@ module RDF
|
|
150
172
|
def supports?(feature)
|
151
173
|
case feature.to_sym
|
152
174
|
when :graph_name then true
|
175
|
+
when :validity then @options.fetch(:with_validity, true)
|
153
176
|
else false
|
154
177
|
end
|
155
178
|
end
|
@@ -159,16 +182,16 @@ module RDF
|
|
159
182
|
st_mongo = statement.to_mongo
|
160
183
|
st_mongo[:ct] ||= :default # Indicate statement is in the default graph
|
161
184
|
#puts "insert statement: #{st_mongo.inspect}"
|
162
|
-
@
|
185
|
+
@collection.update_one(st_mongo, st_mongo, upsert: true)
|
163
186
|
end
|
164
187
|
|
165
188
|
# @see RDF::Mutable#delete_statement
|
166
189
|
def delete_statement(statement)
|
167
190
|
case statement.graph_name
|
168
191
|
when nil
|
169
|
-
@
|
192
|
+
@collection.delete_one(statement.to_mongo.merge('ct'=>:default))
|
170
193
|
else
|
171
|
-
@
|
194
|
+
@collection.delete_one(statement.to_mongo)
|
172
195
|
end
|
173
196
|
end
|
174
197
|
|
@@ -180,24 +203,24 @@ module RDF
|
|
180
203
|
##
|
181
204
|
# @private
|
182
205
|
# @see RDF::Countable#empty?
|
183
|
-
def empty?; @
|
206
|
+
def empty?; @collection.count == 0; end
|
184
207
|
|
185
208
|
##
|
186
209
|
# @private
|
187
210
|
# @see RDF::Countable#count
|
188
211
|
def count
|
189
|
-
@
|
212
|
+
@collection.count
|
190
213
|
end
|
191
214
|
|
192
215
|
def clear_statements
|
193
|
-
@
|
216
|
+
@collection.delete_many
|
194
217
|
end
|
195
218
|
|
196
219
|
##
|
197
220
|
# @private
|
198
221
|
# @see RDF::Enumerable#has_statement?
|
199
222
|
def has_statement?(statement)
|
200
|
-
|
223
|
+
@collection.find(statement.to_mongo).count > 0
|
201
224
|
end
|
202
225
|
##
|
203
226
|
# @private
|
@@ -205,10 +228,8 @@ module RDF
|
|
205
228
|
def each_statement(&block)
|
206
229
|
@nodes = {} # reset cache. FIXME this should probably be in Node.intern
|
207
230
|
if block_given?
|
208
|
-
@
|
209
|
-
|
210
|
-
block.call(RDF::Statement.from_mongo(data))
|
211
|
-
end
|
231
|
+
@collection.find().each do |document|
|
232
|
+
block.call(RDF::Statement.from_mongo(document))
|
212
233
|
end
|
213
234
|
end
|
214
235
|
enum_statement
|
@@ -219,7 +240,7 @@ module RDF
|
|
219
240
|
# @private
|
220
241
|
# @see RDF::Enumerable#has_graph?
|
221
242
|
def has_graph?(value)
|
222
|
-
|
243
|
+
@collection.find(RDF::Mongo::Conversion.to_mongo(value, :graph_name)).count > 0
|
223
244
|
end
|
224
245
|
|
225
246
|
protected
|
@@ -228,17 +249,16 @@ module RDF
|
|
228
249
|
# @private
|
229
250
|
# @see RDF::Queryable#query_pattern
|
230
251
|
# @see RDF::Query::Pattern
|
231
|
-
def query_pattern(pattern, &block)
|
252
|
+
def query_pattern(pattern, options = {}, &block)
|
253
|
+
return enum_for(:query_pattern, pattern, options) unless block_given?
|
232
254
|
@nodes = {} # reset cache. FIXME this should probably be in Node.intern
|
233
255
|
|
234
256
|
# A pattern graph_name of `false` is used to indicate the default graph
|
235
257
|
pm = pattern.to_mongo
|
236
258
|
pm.merge!(c: nil, ct: :default) if pattern.graph_name == false
|
237
259
|
#puts "query using #{pm.inspect}"
|
238
|
-
@
|
239
|
-
|
240
|
-
block.call(RDF::Statement.from_mongo(data))
|
241
|
-
end
|
260
|
+
@collection.find(pm).each do |document|
|
261
|
+
block.call(RDF::Statement.from_mongo(document))
|
242
262
|
end
|
243
263
|
end
|
244
264
|
|
metadata
CHANGED
@@ -1,85 +1,98 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pius Uzamere
|
8
|
+
- Gregg Kellogg
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rdf
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.0.0.beta
|
21
|
+
- - "<"
|
18
22
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
23
|
+
version: '3'
|
20
24
|
type: :runtime
|
21
25
|
prerelease: false
|
22
26
|
version_requirements: !ruby/object:Gem::Requirement
|
23
27
|
requirements:
|
24
|
-
- - "
|
28
|
+
- - ">="
|
25
29
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
30
|
+
version: 2.0.0.beta
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
27
34
|
- !ruby/object:Gem::Dependency
|
28
35
|
name: mongo
|
29
36
|
requirement: !ruby/object:Gem::Requirement
|
30
37
|
requirements:
|
31
38
|
- - "~>"
|
32
39
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
40
|
+
version: '2.2'
|
34
41
|
type: :runtime
|
35
42
|
prerelease: false
|
36
43
|
version_requirements: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
45
|
- - "~>"
|
39
46
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
47
|
+
version: '2.2'
|
41
48
|
- !ruby/object:Gem::Dependency
|
42
49
|
name: rdf-spec
|
43
50
|
requirement: !ruby/object:Gem::Requirement
|
44
51
|
requirements:
|
45
|
-
- - "
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.0.beta
|
55
|
+
- - "<"
|
46
56
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
57
|
+
version: '3'
|
48
58
|
type: :development
|
49
59
|
prerelease: false
|
50
60
|
version_requirements: !ruby/object:Gem::Requirement
|
51
61
|
requirements:
|
52
|
-
- - "
|
62
|
+
- - ">="
|
53
63
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
64
|
+
version: 2.0.0.beta
|
65
|
+
- - "<"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3'
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
69
|
name: rspec
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
58
71
|
requirements:
|
59
72
|
- - "~>"
|
60
73
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
74
|
+
version: '3.4'
|
62
75
|
type: :development
|
63
76
|
prerelease: false
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
65
78
|
requirements:
|
66
79
|
- - "~>"
|
67
80
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
81
|
+
version: '3.4'
|
69
82
|
- !ruby/object:Gem::Dependency
|
70
83
|
name: rspec-its
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
72
85
|
requirements:
|
73
86
|
- - "~>"
|
74
87
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
88
|
+
version: '1.2'
|
76
89
|
type: :development
|
77
90
|
prerelease: false
|
78
91
|
version_requirements: !ruby/object:Gem::Requirement
|
79
92
|
requirements:
|
80
93
|
- - "~>"
|
81
94
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
95
|
+
version: '1.2'
|
83
96
|
- !ruby/object:Gem::Dependency
|
84
97
|
name: yard
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,19 +111,21 @@ dependencies:
|
|
98
111
|
name: bson_ext
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
100
113
|
requirements:
|
101
|
-
- - "
|
114
|
+
- - "~>"
|
102
115
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
116
|
+
version: '1.12'
|
104
117
|
type: :development
|
105
118
|
prerelease: false
|
106
119
|
version_requirements: !ruby/object:Gem::Requirement
|
107
120
|
requirements:
|
108
|
-
- - "
|
121
|
+
- - "~>"
|
109
122
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
123
|
+
version: '1.12'
|
111
124
|
description: rdf-mongo is a storage adapter for integrating MongoDB and rdf.rb, a
|
112
125
|
Ruby library for working with Resource Description Framework (RDF) data.
|
113
|
-
email:
|
126
|
+
email:
|
127
|
+
- pius@alum.mit.edu
|
128
|
+
- gregg@greggkellogg.net
|
114
129
|
executables: []
|
115
130
|
extensions: []
|
116
131
|
extra_rdoc_files: []
|
@@ -122,7 +137,7 @@ files:
|
|
122
137
|
- lib/rdf/mongo/version.rb
|
123
138
|
homepage: http://ruby-rdf.github.com/rdf-mongo
|
124
139
|
licenses:
|
125
|
-
- MIT
|
140
|
+
- MIT
|
126
141
|
metadata: {}
|
127
142
|
post_install_message: Have fun! :)
|
128
143
|
rdoc_options: []
|
@@ -132,15 +147,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
147
|
requirements:
|
133
148
|
- - ">="
|
134
149
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
150
|
+
version: '2.0'
|
136
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
152
|
requirements:
|
138
|
-
- - "
|
153
|
+
- - ">"
|
139
154
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
155
|
+
version: 1.3.1
|
141
156
|
requirements: []
|
142
157
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.5.1
|
144
159
|
signing_key:
|
145
160
|
specification_version: 4
|
146
161
|
summary: A storage adapter for integrating MongoDB and rdf.rb, a Ruby library for
|