activerdf_rdflite 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,17 @@
1
+ == activerdf_rdflite (1.2.3) Tue, 13 Feb 2007 20:07:01 +0000
2
+ * gems published automatically from Rakefile
3
+ * changing rapper invocation in fetching adapter
4
+ * prevent failing unit tests if ferret not installed
5
+ * bumped dependency of sqlite
6
+
7
+ == activerdf_rdflite (1.2.2)
8
+ * use same bnode function in rdflite.load (same bnodes from one file get same uri)
9
+
10
+ == activerdf_rdflite (1.2.1)
11
+ * bugfix in multijoins
12
+
13
+ == activerdf_rdflite (1.2)
14
+ * speed up rdflite.load using precompiled SQL
15
+
16
+ == activerdf_rdflite (1.1)
17
+ * added rdfs:subPropertyOf reasoning
@@ -4,17 +4,16 @@
4
4
 
5
5
  # FetchingAdapter is an extension to rdflite for fetching RDF from online sources.
6
6
  class FetchingAdapter < RDFLite
7
- ConnectionPool.register_adapter(:fetching,self)
7
+ ConnectionPool.register_adapter(:fetching, self)
8
+
9
+ # TODO: check that rapper is installed
8
10
 
9
11
  # fetches RDF/XML data from given url and adds it to the datastore, using the
10
12
  # source url as context identifier.
11
13
  def fetch url
14
+ # check if url starts with http://
12
15
  return unless url.match(/http:\/\/(.*)/)
13
16
 
14
- # remove fragment identifier from url
15
- hashidx = url.rindex('#')
16
- url = url[0..url.rindex('#')-1] unless hashidx.nil?
17
-
18
17
  $activerdflog.debug "fetching from #{url}"
19
18
 
20
19
  #model = Redland::Model.new
@@ -33,17 +32,3 @@ class FetchingAdapter < RDFLite
33
32
  add_ntriples(triples, context)
34
33
  end
35
34
  end
36
-
37
- #class String
38
- # alias _match match
39
- # def match(*args)
40
- # m = _match(args.first)
41
- # if m && m.length > 1
42
- # args[1..-1].each_with_index do |name, index|
43
- # m.instance_eval "def #{name}; self[#{index+1}] end"
44
- # end
45
- # end
46
- # m
47
- # end
48
- #end
49
-
@@ -5,7 +5,7 @@
5
5
  require 'sqlite3'
6
6
  require 'active_rdf'
7
7
  require 'federation/connection_pool'
8
- require_gem 'uuidtools'
8
+ require 'uuidtools'
9
9
 
10
10
  $activerdflog.info "loading RDFLite adapter"
11
11
 
@@ -35,7 +35,7 @@ class RDFLite < ActiveRdfAdapter
35
35
 
36
36
  @reads = true
37
37
  @writes = true
38
-
38
+
39
39
  # if no file-location given, we use in-memory store
40
40
  file = params[:location] || ':memory:'
41
41
  @db = SQLite3::Database.new(file)
@@ -53,7 +53,7 @@ class RDFLite < ActiveRdfAdapter
53
53
  # we setup the fields not to store object's contents
54
54
  infos.add_field(:subject, :store => :yes, :index => :no, :term_vector => :no)
55
55
  infos.add_field(:object, :store => :no) #, :index => :omit_norms)
56
-
56
+
57
57
  @ferret = if params[:location]
58
58
  Ferret::I.new(:path => params[:location] + '.ferret', :field_infos => infos)
59
59
  else
@@ -96,15 +96,15 @@ class RDFLite < ActiveRdfAdapter
96
96
  # convert non-nil input to internal format
97
97
  quad = [s,p,o,c].collect {|r| r.nil? ? nil : internalise(r) }
98
98
 
99
- # construct where clause for deletion (for all non-nil input)
99
+ # construct where clause for deletion (for all non-nil input)
100
100
  where_clauses = []
101
101
  conditions = []
102
- quad.each_with_index do |r,i|
103
- unless r.nil?
104
- conditions << r
105
- where_clauses << "#{SPOC[i]} = ?"
106
- end
107
- end
102
+ quad.each_with_index do |r,i|
103
+ unless r.nil?
104
+ conditions << r
105
+ where_clauses << "#{SPOC[i]} = ?"
106
+ end
107
+ end
108
108
 
109
109
  # construct delete string
110
110
  ds = 'delete from triple'
@@ -122,7 +122,7 @@ class RDFLite < ActiveRdfAdapter
122
122
 
123
123
  @db
124
124
  end
125
-
125
+
126
126
  # adds triple(s,p,o) to datastore
127
127
  # s,p must be resources, o can be primitive data or resource
128
128
  def add(s,p,o,c=nil)
@@ -0,0 +1,33 @@
1
+ # Author:: Eyal Oren
2
+ # Copyright:: (c) 2005-2006
3
+ # License:: LGPL
4
+
5
+ require 'rubygems'
6
+ require 'test/unit'
7
+ require 'active_rdf'
8
+
9
+ class TestFetchingAdapter < Test::Unit::TestCase
10
+ def setup
11
+ ConnectionPool.clear
12
+ @adapter = ConnectionPool.add(:type => :fetching)
13
+ end
14
+
15
+ def teardown
16
+ end
17
+
18
+ def test_parse_foaf
19
+ @adapter.fetch("http://eyaloren.org/foaf.rdf#me")
20
+ assert @adapter.size > 0
21
+ end
22
+
23
+ def test_sioc_schema
24
+ @adapter.fetch("http://rdfs.org/sioc/ns#")
25
+ assert_equal 461, @adapter.size
26
+ end
27
+
28
+ def test_foaf_schema
29
+ @adapter.fetch("http://xmlns.com/foaf/0.1/")
30
+ # foaf contains 563 triples but with two duplicates
31
+ assert_equal 561, @adapter.size
32
+ end
33
+ end
data/test/test_rdflite.rb CHANGED
@@ -19,7 +19,8 @@ class TestRdfLiteAdapter < Test::Unit::TestCase
19
19
  def test_registration
20
20
  adapter = ConnectionPool.add_data_source(:type => :rdflite)
21
21
  assert_instance_of RDFLite, adapter
22
- assert adapter.keyword_search?
22
+ # we cant garantuee that the rdflite adapter can do keyword search
23
+ # assert adapter.keyword_search?
23
24
  end
24
25
 
25
26
  def test_initialise
@@ -190,9 +191,13 @@ class TestRdfLiteAdapter < Test::Unit::TestCase
190
191
  adapter.load(File.dirname(File.expand_path(__FILE__)) + '/test_data.nt')
191
192
 
192
193
  eyal = RDFS::Resource.new('http://activerdf.org/test/eyal')
193
- assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"blue").execute(:flatten => true)
194
- assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"27").execute(:flatten => true)
195
- assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"eyal oren").execute(:flatten => true)
194
+
195
+ # we cant garantuee that ferret is installed
196
+ if adapter.keyword_search?
197
+ assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"blue").execute(:flatten => true)
198
+ assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"27").execute(:flatten => true)
199
+ assert_equal eyal, Query.new.distinct(:s).where(:s,:keyword,"eyal oren").execute(:flatten => true)
200
+ end
196
201
  end
197
202
 
198
203
  def test_bnodes
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: activerdf_rdflite
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.2
7
- date: 2007-01-30 00:00:00 +00:00
6
+ version: 1.2.3
7
+ date: 2007-02-13 00:00:00 +00:00
8
8
  summary: an RDF database for usage in ActiveRDF (based on sqlite3)
9
9
  require_paths:
10
10
  - lib
@@ -31,14 +31,15 @@ authors:
31
31
  files:
32
32
  - LICENSE
33
33
  - README
34
- - Rakefile
35
- - test/test_rdflite.rb
36
- - test/test_data.nt
34
+ - CHANGELOG
37
35
  - test/test_bnode_data.nt
36
+ - test/test_data.nt
37
+ - test/test_fetching.rb
38
+ - test/test_rdflite.rb
38
39
  - lib/activerdf_rdflite
40
+ - lib/activerdf_rdflite/fetching.rb
39
41
  - lib/activerdf_rdflite/init.rb
40
42
  - lib/activerdf_rdflite/rdflite.rb
41
- - lib/activerdf_rdflite/fetching.rb
42
43
  - lib/activerdf_rdflite/suggesting.rb
43
44
  test_files: []
44
45
 
@@ -87,5 +88,5 @@ dependencies:
87
88
  requirements:
88
89
  - - ">="
89
90
  - !ruby/object:Gem::Version
90
- version: 1.1.0.1
91
+ version: 1.2.1
91
92
  version:
data/Rakefile DELETED
@@ -1,45 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/clean'
4
- require 'rake/gempackagetask'
5
- require 'rake/rdoctask'
6
- require '../tools/rakehelp'
7
- require 'fileutils'
8
- include FileUtils
9
-
10
- setup_tests
11
- setup_rdoc ['README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc']
12
-
13
- desc "test and package gem"
14
- task :default => [:test, :package]
15
-
16
- # get @VERSION from commandline
17
- @VERSION = '1.2.2'
18
- NAME="activerdf_rdflite"
19
- GEMNAME="#{NAME}-#{@VERSION}.gem"
20
-
21
- # define package task
22
- setup_gem(NAME,@VERSION) do |spec|
23
- spec.summary = "an RDF database for usage in ActiveRDF (based on sqlite3)"
24
- spec.description = spec.summary
25
- spec.author="Eyal Oren <eyal.oren@deri.org"
26
- spec.add_dependency('gem_plugin', '>= 0.2.1')
27
- spec.add_dependency('uuidtools')
28
- spec.add_dependency('activerdf', '>= 1.2')
29
- spec.add_dependency('sqlite3-ruby', '>= 1.1.0.1')
30
- end
31
-
32
- task :install => [:package] do
33
- sh %{sudo gem install pkg/#{name}-#{version}.gem}
34
- end
35
-
36
- task :uninstall => [:clean] do
37
- sh %{sudo gem uninstall #{name}}
38
- end
39
-
40
- task :reinstall => [:uninstall, :install]
41
-
42
- task :upload => :package do |task|
43
- sh "scp pkg/#{GEMNAME} eyal@activerdf.org:/home/eyal/webs/activerdf/gems/"
44
- end
45
-