lightrdf 0.3.0 → 0.3.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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.3.1 2011-03-18
2
+
3
+ * Fix in Node#all_triples method
4
+
1
5
  === 0.3.0 2011-03-17
2
6
 
3
7
  * Recursive addition of nodes to a graph
data/lib/lightrdf/node.rb CHANGED
@@ -66,8 +66,12 @@ module RDF
66
66
  triples
67
67
  end
68
68
 
69
- def all_triples
70
- graph.triples
69
+ def all_triples done=[]
70
+ return [] if done.include?(self)
71
+ done << self
72
+ triples = self.triples
73
+ triples.map { |s,p,o| [s,o] }.flatten.uniq.each { |node| triples += graph[node].all_triples(done) }
74
+ triples
71
75
  end
72
76
 
73
77
  def merge node
data/lib/lightrdf.rb CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module RDF
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
 
8
8
  require 'rubygems'
data/lightrdf.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{lightrdf}
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Ignacio"]
9
- s.date = %q{2011-03-17}
9
+ s.date = %q{2011-03-18}
10
10
  s.default_executable = %q{yarfp}
11
11
  s.description = %q{RDF library}
12
12
  s.email = %q{joseignacio.fernandez@gmail.com}
@@ -138,7 +138,27 @@ class TestLightRDF < Test::Unit::TestCase
138
138
  assert_equal [Node("ex:bob")], g[Node("ex:alice")].foaf::knows
139
139
  assert_equal ["26"], g[Node("ex:bob")].foaf::age
140
140
  end
141
-
141
+
142
+ def test_all_triples
143
+ a = Node('ex:alice')
144
+ a.foaf::name = "Alice"
145
+ b = Node("ex:bob")
146
+ b.foaf::age = "26"
147
+ a.foaf::knows = b
148
+ c = Node("ex:charlie")
149
+ c.foaf::age = "27"
150
+
151
+ g = RDF::Graph.new
152
+ g << a
153
+ g << b
154
+ g << c
155
+
156
+ g.triples -= a.all_triples
157
+
158
+ assert_equal 1, g.triples.size
159
+ assert_equal ["27"], g[Node("ex:charlie")].foaf::age
160
+ end
161
+
142
162
  def test_graph_merge!
143
163
  a = Node('ex:bob')
144
164
  a.foaf::name = "Bob"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Ignacio
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-17 00:00:00 +01:00
17
+ date: 2011-03-18 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency