talia_core 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/config/talia_core.yml +2 -0
- data/config/talia_core.yml.example +3 -1
- data/generators/talia_base/templates/app/controllers/ontologies_controller.rb +2 -2
- data/generators/talia_base/templates/app/controllers/sources_controller.rb +1 -1
- data/lib/swicky/api_result.rb +57 -0
- data/lib/swicky/json_encoder.rb +175 -0
- data/lib/swicky/notebook.rb +128 -0
- data/lib/talia_core/active_source.rb +1 -1
- data/lib/talia_core/active_source_parts/xml/generic_reader.rb +2 -7
- data/lib/talia_core/active_source_parts/xml/rdf_builder.rb +9 -56
- data/lib/talia_core/active_source_parts/xml/source_builder.rb +5 -1
- data/lib/talia_core/initializer.rb +2 -2
- data/lib/talia_core/rdf_import.rb +4 -4
- data/lib/talia_core/rdf_resource.rb +15 -15
- data/lib/talia_util/rake_tasks.rb +1 -1
- data/lib/talia_util/rdf_update.rb +4 -4
- data/lib/talia_util/uri_helper.rb +20 -0
- data/lib/talia_util/util.rb +4 -4
- data/lib/talia_util/xml/base_builder.rb +47 -0
- data/lib/talia_util/xml/rdf_builder.rb +172 -0
- data/test/swicky/json_encoder_test.rb +116 -0
- data/test/swicky/notebook_test.rb +107 -0
- data/test/talia_core/rdf_resource_test.rb +1 -1
- data/test/talia_util/rdf_builder_test.rb +87 -0
- metadata +13 -6
- data/lib/talia_core/active_source_parts/xml/base_builder.rb +0 -47
- data/lib/talia_util/some_sigla.xml +0 -1960
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'test_helper')
|
2
|
+
require 'rexml/document'
|
3
|
+
|
4
|
+
module TaliaUtil
|
5
|
+
|
6
|
+
# Test the Generic Xml Import
|
7
|
+
class RdfBuilderTest < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@my_xml = ''
|
11
|
+
@my_builder = Xml::RdfBuilder.send(:new, :target => @my_xml, :indent => 2)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_make_namespace
|
15
|
+
pred_uri = URI.parse('http://www.foobar.com/bar/moo')
|
16
|
+
namespace = @my_builder.send(:make_namespace, pred_uri)
|
17
|
+
assert_equal('foobar', namespace)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_make_namespace_multi
|
21
|
+
pred_uri = URI.parse('http://www.foobar.com/bar/moo')
|
22
|
+
pred_uri_2 = URI.parse('http://www.foobar.com/bar/foo')
|
23
|
+
pred_uri_3 = URI.parse('http://www.foobar.com/bar/boo')
|
24
|
+
@my_builder.send(:make_namespace, pred_uri)
|
25
|
+
@my_builder.send(:make_namespace, pred_uri)
|
26
|
+
@my_builder.send(:make_namespace, pred_uri_2)
|
27
|
+
namespace = @my_builder.send(:make_namespace, pred_uri_3)
|
28
|
+
assert_equal('foobar3', namespace)
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_make_predicate_namespace_hash
|
33
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo#first')
|
34
|
+
assert_equal('foobar:first', predspace)
|
35
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo#second')
|
36
|
+
assert_equal('foobar:second', predspace)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_make_predicate_namespace_slash
|
40
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo/first')
|
41
|
+
assert_equal('foobar:first', predspace)
|
42
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo/second')
|
43
|
+
assert_equal('foobar:second', predspace)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_make_predicate_namespace_multi
|
47
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo/first')
|
48
|
+
assert_equal('foobar:first', predspace)
|
49
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo#first')
|
50
|
+
assert_equal('foobar2:first', predspace)
|
51
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo#second')
|
52
|
+
assert_equal('foobar2:second', predspace)
|
53
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/moo/second')
|
54
|
+
assert_equal('foobar:second', predspace)
|
55
|
+
predspace = @my_builder.send(:make_predicate_namespace, 'http://www.foobar.com/bar/boo/first')
|
56
|
+
assert_equal('foobar3:first', predspace)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_prepare_triples
|
60
|
+
triple_hash = @my_builder.send(:prepare_triples, test_triples)
|
61
|
+
assert_equal({
|
62
|
+
N::LOCAL.foobar.to_s => { N::URI.new('foobar:first') => ['worksit', 'worksit2'] },
|
63
|
+
N::TALIA.whatever.to_s => {
|
64
|
+
N::URI.new('talia:predicate') => [ N::URI.new('http://www.barbaa.com/fun') ],
|
65
|
+
N::URI.new('foobar2:first') => [ N::URI.new('http://www.barbaa.com/fun') ]
|
66
|
+
}
|
67
|
+
}, triple_hash)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_open_for_triples
|
71
|
+
xml = Xml::RdfBuilder.xml_string_for_triples(test_triples)
|
72
|
+
assert_nothing_raised { REXML::Document.new(xml) }
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def test_triples
|
78
|
+
[
|
79
|
+
[ N::LOCAL.foobar, 'http://www.foobar.com/bar/moo/first', "worksit"],
|
80
|
+
[ N::LOCAL.foobar, 'http://www.foobar.com/bar/moo/first', "worksit2"],
|
81
|
+
[ N::TALIA.whatever, N::TALIA.predicate, N::URI.new('http://www.barbaa.com/fun')],
|
82
|
+
[ N::TALIA.whatever, 'http://www.foobar.com/bar/moo#first', N::URI.new('http://www.barbaa.com/fun')]
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talia_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Giacomi
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2010-02-
|
16
|
+
date: 2010-02-11 00:00:00 +01:00
|
17
17
|
default_executable: talia
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.7.0
|
48
48
|
version:
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: assit
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 2.
|
67
|
+
version: 2.1.3
|
68
68
|
version:
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bjj
|
@@ -293,6 +293,9 @@ files:
|
|
293
293
|
- lib/loader_helper.rb
|
294
294
|
- lib/mysql.rb
|
295
295
|
- lib/progressbar.rb
|
296
|
+
- lib/swicky/api_result.rb
|
297
|
+
- lib/swicky/json_encoder.rb
|
298
|
+
- lib/swicky/notebook.rb
|
296
299
|
- lib/talia_core.rb
|
297
300
|
- lib/talia_core/active_source.rb
|
298
301
|
- lib/talia_core/active_source_parts/class_methods.rb
|
@@ -300,7 +303,6 @@ files:
|
|
300
303
|
- lib/talia_core/active_source_parts/predicate_handler.rb
|
301
304
|
- lib/talia_core/active_source_parts/rdf.rb
|
302
305
|
- lib/talia_core/active_source_parts/sql_helper.rb
|
303
|
-
- lib/talia_core/active_source_parts/xml/base_builder.rb
|
304
306
|
- lib/talia_core/active_source_parts/xml/generic_reader.rb
|
305
307
|
- lib/talia_core/active_source_parts/xml/rdf_builder.rb
|
306
308
|
- lib/talia_core/active_source_parts/xml/source_builder.rb
|
@@ -359,9 +361,11 @@ files:
|
|
359
361
|
- lib/talia_util/progressbar.rb
|
360
362
|
- lib/talia_util/rake_tasks.rb
|
361
363
|
- lib/talia_util/rdf_update.rb
|
362
|
-
- lib/talia_util/some_sigla.xml
|
363
364
|
- lib/talia_util/test_helpers.rb
|
365
|
+
- lib/talia_util/uri_helper.rb
|
364
366
|
- lib/talia_util/util.rb
|
367
|
+
- lib/talia_util/xml/base_builder.rb
|
368
|
+
- lib/talia_util/xml/rdf_builder.rb
|
365
369
|
- lib/version.rb
|
366
370
|
- tasks/talia_core_tasks.rake
|
367
371
|
- README.rdoc
|
@@ -397,6 +401,8 @@ test_files:
|
|
397
401
|
- test/custom_template_test.rb
|
398
402
|
- test/test_helper.rb
|
399
403
|
- test/core_ext/string_test.rb
|
404
|
+
- test/swicky/json_encoder_test.rb
|
405
|
+
- test/swicky/notebook_test.rb
|
400
406
|
- test/talia_core/active_source_predicate_test.rb
|
401
407
|
- test/talia_core/active_source_rdf_test.rb
|
402
408
|
- test/talia_core/active_source_test.rb
|
@@ -423,3 +429,4 @@ test_files:
|
|
423
429
|
- test/talia_core/workflow/workflow_base_test.rb
|
424
430
|
- test/talia_util/import_job_helper_test.rb
|
425
431
|
- test/talia_util/io_helper_test.rb
|
432
|
+
- test/talia_util/rdf_builder_test.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module TaliaCore
|
2
|
-
module ActiveSourceParts
|
3
|
-
module Xml
|
4
|
-
|
5
|
-
# Base class for builders that create source-related XML. This uses a Builder::XmlMarkup object
|
6
|
-
# in the background which does the actual XML writing.
|
7
|
-
#
|
8
|
-
# All builders will be used through the #open method, which can be passed either a Builder::XmlMarkup
|
9
|
-
# object, or the options to create one.
|
10
|
-
class BaseBuilder
|
11
|
-
|
12
|
-
# Creates a new builder. The options are equivalent for the options of the
|
13
|
-
# underlying Xml builder. The builder itself will be passed to the block that
|
14
|
-
# is called by this method.
|
15
|
-
# If you pass a :builder option instead, it will use the given builder instead
|
16
|
-
# of creating a new one
|
17
|
-
def self.open(options)
|
18
|
-
my_builder = self.new(options)
|
19
|
-
my_builder.send(:build_structure) do
|
20
|
-
yield(my_builder)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Quick helper: Returns the xml for one source as a string
|
25
|
-
def self.build_source(source)
|
26
|
-
xml = ''
|
27
|
-
|
28
|
-
open(:target => xml, :indent => 2) do |builder|
|
29
|
-
builder.write_source(source)
|
30
|
-
end
|
31
|
-
|
32
|
-
xml
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
# Create a new builder
|
38
|
-
def initialize(options)
|
39
|
-
@builder = options[:builder]
|
40
|
-
@builder ||= Builder::XmlMarkup.new(options)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|