[Kde-bindings] KDE/kdebindings/ruby/soprano
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Fri Nov 7 18:51:10 UTC 2008
SVN commit 881308 by rdale:
2008-11-07 Richard Dale <richard.j.dale at gmail.com>
* Improved the ActiveRDF adapter
* Added a ':service' option which defaults to 'org.soprano.Server'
* The adapter was read-only
* Fixed bugs in deleting statements from the store
* Improved the test script, although it still doesn't work very well
* Added inspect and pretty_print methods for Soprano::Statements
* Variable values in a Soprano::BindingSet can be accessed as 'myset[:mykey]'
CCMAIL: kde-bindings at kde.org
AM activerdf-soprano/lib/activerdf_soprano/activerdf_soprano.rb activerdf-soprano/lib/activerdf_soprano/soprano.rb#877445
M +2 -0 activerdf-soprano/lib/activerdf_soprano/init.rb
D activerdf-soprano/lib/activerdf_soprano/soprano.rb
M +34 -13 activerdf-soprano/test/test_soprano_adapter.rb
M +18 -0 soprano.rb
M +2 -0 sopranohandlers.cpp
** trunk/KDE/kdebindings/ruby/soprano/activerdf-soprano/lib/activerdf_soprano/activerdf_soprano.rb #property svn:mergeinfo
+
--- trunk/KDE/kdebindings/ruby/soprano/activerdf-soprano/lib/activerdf_soprano/init.rb #881307:881308
@@ -7,5 +7,7 @@
end
$: << File.dirname(File.expand_path(file))
+require 'Qt4'
require 'soprano'
+require 'activerdf_soprano'
require 'literal'
--- trunk/KDE/kdebindings/ruby/soprano/activerdf-soprano/test/test_soprano_adapter.rb #881307:881308
@@ -11,6 +11,8 @@
class TestSopranoAdapter < Test::Unit::TestCase
def setup
+ @test_service = 'org.soprano.Server'
+ # @test_service = 'org.kde.NepomukServer'
ConnectionPool.clear
end
@@ -18,7 +20,7 @@
end
def test_registration
- adapter = ConnectionPool.add_data_source(:type => :soprano)
+ adapter = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service)
assert_instance_of SopranoAdapter, adapter
end
@@ -28,7 +30,7 @@
end
def test_simple_query
- adapter = ConnectionPool.add_data_source(:type => :soprano)
+ adapter = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person')
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -39,11 +41,13 @@
assert_instance_of RDFS::Resource, result
assert_equal 'eyaloren.org', result.uri
+
+ adapter.clear
end
def test_federated_query
- adapter1 = ConnectionPool.add_data_source(:type => :soprano)
- adapter2 = ConnectionPool.add_data_source(:type => :soprano, :fake_symbol_to_get_unique_adapter => true)
+ adapter1 = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person')
+ adapter2 = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person', :fake_symbol_to_get_unique_adapter => true)
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -61,10 +65,12 @@
assert_equal 2, results.size
results.all? {|result| assert result.instance_of?(RDFS::Resource) }
+
+ adapter1.clear
end
def test_query_with_block
- adapter = ConnectionPool.add_data_source(:type => :redland)
+ adapter = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person')
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -75,18 +81,22 @@
assert_equal 'eyaloren.org', s.uri
assert_equal 'foaf:age', p.uri
end
+
+ adapter.clear
end
def test_load_from_file
- adapter = ConnectionPool.add_data_source :type => :soprano, :model => 'test_load'
+ adapter = ConnectionPool.add_data_source :type => :soprano, :service => @test_service, :model => 'test_person'
# adapter.load("/tmp/test_person_data.nt", "turtle")
# adapter.load("/home/metaman/workspaces/deri-workspace/activerdf/test/test_person_data.nt", "turtle")
adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
- assert_equal 28, adapter.size
+ assert_equal 28, adapter.size
+
+ adapter.clear
end
def test_person_data
- ConnectionPool.add_data_source :type => :soprano, :model => 'test_person'
+ ConnectionPool.add_data_source :type => :soprano, :service => @test_service, :model => 'test_person'
Namespace.register(:test, 'http://activerdf.org/test/')
eyal = Namespace.lookup(:test, :eyal)
@@ -102,11 +112,13 @@
ObjectManager.construct_classes
assert eyal.instance_of?(TEST::Person)
assert eyal.instance_of?(RDFS::Resource)
+
+ adapter.clear
end
def test_federated_query
- adapter1 = ConnectionPool.add_data_source(:type => :soprano)
- adapter2 = ConnectionPool.add_data_source(:type => :soprano, :fake_symbol_to_get_unique_adapter => true)
+ adapter1 = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person')
+ adapter2 = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person', :fake_symbol_to_get_unique_adapter => true)
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -124,10 +136,12 @@
assert_equal 2, results.size
results.all? {|result| assert result.instance_of?(RDFS::Resource) }
+
+ adapter1.clear
end
def test_query_with_block
- adapter = ConnectionPool.add_data_source(:type => :soprano)
+ adapter = ConnectionPool.add_data_source(:type => :soprano, :service => @test_service, :model => 'test_person')
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -138,10 +152,12 @@
assert_equal 'eyaloren.org', s.uri
assert_equal 'foaf:age', p.uri
end
+
+ adapter.clear
end
def test_person_data
- adapter = ConnectionPool.add_data_source :type => :soprano, :model => 'test_person'
+ adapter = ConnectionPool.add_data_source :type => :soprano, :service => @test_service, :model => 'test_person'
adapter.load("#{File.dirname(__FILE__)}/test_person_data.nt", "turtle")
Namespace.register(:test, 'http://activerdf.org/test/')
@@ -157,10 +173,11 @@
ObjectManager.construct_classes
assert eyal.instance_of?(TEST::Person)
assert eyal.instance_of?(RDFS::Resource)
+ adapter.clear
end
def test_sparql_query
- adapter = ConnectionPool.add_data_source :type => :soprano
+ adapter = ConnectionPool.add_data_source :type => :soprano, :service => @test_service, :model => 'test_person'
eyal = RDFS::Resource.new 'eyaloren.org'
age = RDFS::Resource.new 'foaf:age'
@@ -172,5 +189,9 @@
results = query.execute
assert results.include?('eyaloren.org')
+
+ adapter.clear
end
end
+
+# kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
--- trunk/KDE/kdebindings/ruby/soprano/soprano.rb #881307:881308
@@ -105,6 +105,18 @@
end
class Statement < Qt::Base
+ def inspect
+ str = super
+ str.sub(/>$/, " valid?=%s, subject=%s, predicate=%s, object=%s, context=%s>" %
+ [isValid, subject.inspect, predicate.inspect, object.inspect, context.inspect])
+ end
+
+ def pretty_print(pp)
+ str = to_s
+ pp.text str.sub(/>$/, " valid?=%s,\n subject=%s,\n predicate=%s,\n object=%s,\n context=%s>" %
+ [isValid, subject.inspect, predicate.inspect, object.inspect, context.inspect])
+ end
+
def self.demarshall(arg)
arg.beginStructure
subject = Soprano::Node.demarshall(arg)
@@ -134,6 +146,10 @@
arg.endStructure
return set
end
+
+ def [](v)
+ value(v.to_s)
+ end
end
class NodeIterator < Qt::Base
@@ -199,3 +215,5 @@
end
end
+
+# kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent off;
--- trunk/KDE/kdebindings/ruby/soprano/sopranohandlers.cpp #881307:881308
@@ -46,3 +46,5 @@
{ "QList<const Soprano::Serializer*>", marshall_SopranoBindingSetList },
{ 0, 0 }
};
+
+// kate: space-indent on; indent-width 4; replace-tabs on; mixed-indent off;
More information about the Kde-bindings
mailing list