rdf-mongo 0.1.9 → 0.1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rdf/mongo.rb +9 -16
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.9
|
1
|
+
0.1.9.1
|
data/lib/rdf/mongo.rb
CHANGED
@@ -8,7 +8,7 @@ module Mongo
|
|
8
8
|
if block_given?
|
9
9
|
each {|statement| block.call(RDF::Statement.from_mongo(statement)) }
|
10
10
|
else
|
11
|
-
self
|
11
|
+
self
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -89,9 +89,6 @@ module RDF
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
92
|
def db
|
96
93
|
@db
|
97
94
|
end
|
@@ -103,6 +100,13 @@ module RDF
|
|
103
100
|
def initialize(options = {:host => 'localhost', :port => 27017, :db => 'quadb'})
|
104
101
|
@db = ::Mongo::Connection.new(options[:host], options[:port]).db(options[:db])
|
105
102
|
@coll = @db['quads']
|
103
|
+
@coll.create_index("s")
|
104
|
+
@coll.create_index("p")
|
105
|
+
@coll.create_index("o")
|
106
|
+
@coll.create_index("c")
|
107
|
+
@coll.create_index([["s", ::Mongo::ASCENDING], ["p", ::Mongo::ASCENDING]])
|
108
|
+
@coll.create_index([["s", ::Mongo::ASCENDING], ["o", ::Mongo::ASCENDING]])
|
109
|
+
@coll.create_index([["p", ::Mongo::ASCENDING], ["o", ::Mongo::ASCENDING]])
|
106
110
|
end
|
107
111
|
|
108
112
|
# @see RDF::Enumerable#each.
|
@@ -113,7 +117,6 @@ module RDF
|
|
113
117
|
else
|
114
118
|
statements = @coll.find()
|
115
119
|
enumerator!.new(statements,:rdf_each)
|
116
|
-
#nasty ... in Ruby 1.9, Enumerator doesn't exist under Enumerable
|
117
120
|
end
|
118
121
|
end
|
119
122
|
|
@@ -137,16 +140,13 @@ module RDF
|
|
137
140
|
query(pattern.to_hash)
|
138
141
|
when Array
|
139
142
|
query(RDF::Statement.new(*pattern))
|
140
|
-
when Hash
|
141
|
-
|
143
|
+
when Hash
|
142
144
|
statements = query_hash(pattern)
|
143
145
|
the_statements = statements || []
|
144
146
|
case block_given?
|
145
147
|
when true
|
146
148
|
the_statements.each {|s| block.call(RDF::Statement.from_mongo(s))}
|
147
149
|
else
|
148
|
-
#e = enumerator!.new(statements.extend(RDF::Queryable),:rdf_each)
|
149
|
-
#s = the_statements.extend(RDF::Enumerable, RDF::Queryable)
|
150
150
|
def the_statements.each(&block)
|
151
151
|
if block_given?
|
152
152
|
super {|statement| block.call(RDF::Statement.from_mongo(statement)) }
|
@@ -168,11 +168,6 @@ module RDF
|
|
168
168
|
def query_hash(hash)
|
169
169
|
return @coll.find if hash.empty?
|
170
170
|
h = RDF::Statement.new(hash).to_mongo
|
171
|
-
# h = {}
|
172
|
-
# (h[:s] = hash[:subject]) if hash[:subject]
|
173
|
-
# (h[:p] = hash[:predicate]) if hash[:predicate]
|
174
|
-
# (h[:o] = hash[:object]) if hash[:object]
|
175
|
-
# (h[:c] = hash[:context]) if hash[:context]
|
176
171
|
@coll.find(h)
|
177
172
|
end
|
178
173
|
|
@@ -183,8 +178,6 @@ module RDF
|
|
183
178
|
require 'enumerator' unless defined?(::Enumerable)
|
184
179
|
@@enumerator_klass = defined?(::Enumerable::Enumerator) ? ::Enumerable::Enumerator : ::Enumerator
|
185
180
|
end
|
186
|
-
|
187
|
-
|
188
181
|
end
|
189
182
|
end
|
190
183
|
end
|
metadata
CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
|
9
|
+
- 1
|
10
|
+
version: 0.1.9.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Pius Uzamere
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-27 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|