rdfobjects 0.6.0 → 0.6.1
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.
- data/lib/rdf_objects/collection.rb +9 -2
- data/lib/rdf_objects/parsers.rb +11 -5
- metadata +2 -2
@@ -3,8 +3,15 @@ module RDFObject
|
|
3
3
|
def uris
|
4
4
|
return self.keys
|
5
5
|
end
|
6
|
-
def
|
7
|
-
|
6
|
+
def find_by_predicate(predicate)
|
7
|
+
if predicate.could_be_a_safe_curie?
|
8
|
+
predicate = Curie.parse predicate
|
9
|
+
end
|
10
|
+
self.find_all {|r|
|
11
|
+
if r[1][predicate]
|
12
|
+
r[1]
|
13
|
+
end
|
14
|
+
}
|
8
15
|
end
|
9
16
|
|
10
17
|
def find_or_create(uri)
|
data/lib/rdf_objects/parsers.rb
CHANGED
@@ -131,7 +131,8 @@ module RDFObject
|
|
131
131
|
tmp_object = scanner.scan_until(/>\s?\.\s*\n?$/)
|
132
132
|
tmp_object.sub!(/^</,'')
|
133
133
|
tmp_object.sub!(/>\s?\.\s*\n?$/,'')
|
134
|
-
object =
|
134
|
+
object = tmp_object
|
135
|
+
type = "uri"
|
135
136
|
else
|
136
137
|
language = nil
|
137
138
|
data_type = nil
|
@@ -154,9 +155,10 @@ module RDFObject
|
|
154
155
|
data_type = scanner.scan_until(/>/)
|
155
156
|
data_type.sub!(/>$/,'')
|
156
157
|
end
|
157
|
-
object = Literal.new(tmp_object,{:data_type=>data_type,:language=>language})
|
158
|
+
object = Literal.new(tmp_object,{:data_type=>data_type,:language=>language})
|
159
|
+
type = "literal"
|
158
160
|
end
|
159
|
-
|
161
|
+
{:subject=>subject, :predicate=>predicate, :object=>object, :type=>type}
|
160
162
|
end
|
161
163
|
|
162
164
|
def data=(ntriples)
|
@@ -173,8 +175,12 @@ module RDFObject
|
|
173
175
|
@ntriples.each do | assertion |
|
174
176
|
next if assertion[0, 1] == "#" # Ignore comments
|
175
177
|
triple = parse_ntriple(assertion)
|
176
|
-
resource = @collection.find_or_create(triple[
|
177
|
-
|
178
|
+
resource = @collection.find_or_create(triple[:subject])
|
179
|
+
object = case triple[:type]
|
180
|
+
when "literal" then triple[:object]
|
181
|
+
when "uri" then @collection.find_or_create(triple[:object])
|
182
|
+
end
|
183
|
+
resource.assert(triple[:predicate],object)
|
178
184
|
end
|
179
185
|
@collection
|
180
186
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdfobjects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Singer
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-13 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|