Skip to content

Commit 53fc933

Browse files
committed
Hacked in quick fixes for # based URIs
1 parent fb86aaa commit 53fc933

File tree

7 files changed

+80
-8
lines changed

7 files changed

+80
-8
lines changed

Rakefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'rake/testtask'
55
require 'rake/clean'
66

77
NAME = "dowl"
8-
VER = "0.2"
8+
VER = "0.3"
99

1010
RDOC_OPTS = ['--quiet', '--title', 'dowl Reference', '--main', 'README']
1111

@@ -55,7 +55,7 @@ end
5555
desc "Install from a locally built copy of the gem"
5656
task :install do
5757
sh %{rake package}
58-
sh %{sudo gem install pkg/#{NAME}-#{VER}}
58+
sh %{sudo gem install --no-ri --no-rdoc pkg/#{NAME}-#{VER}}
5959
end
6060

6161
desc "Uninstall the gem"

examples/example.ttl

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# General description of the schema
1414
############################################################################
1515

16-
<http://www.example.org/dowl/>
16+
<http://www.example.org/dowl>
1717
a owl:Ontology;
1818
dcterms:title "An Example"@en ;
1919
rdfs:comment "This is a simple example"@en ;

examples/example2.ttl

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#General Namespaces
2+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
3+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
4+
@prefix owl: <http://www.w3.org/2002/07/owl#>.
5+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
6+
@prefix dcterms: <http://purl.org/dc/terms/>.
7+
@prefix dctypes: <http://purl.org/dc/dcmitype/>.
8+
@prefix vs: <http://www.w3.org/2003/06/sw-vocab-status/ns#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
10+
@prefix ex: <http://www.example.org/dowl#>.
11+
12+
############################################################################
13+
# General description of the schema
14+
############################################################################
15+
16+
<http://www.example.org/dowl/>
17+
a owl:Ontology;
18+
dcterms:title "An Example"@en ;
19+
rdfs:comment "This is a simple example"@en ;
20+
foaf:maker <http://www.ldodds.com#me> ;
21+
foaf:maker <http://www.example.org/unknown> ;
22+
dcterms:created "2010-02-19"^^xsd:date ;
23+
dcterms:modified "2010-09-28"^^xsd:date .
24+
25+
<http://www.ldodds.com#me> a foaf:Person ;
26+
foaf:name "Leigh Dodds" .
27+
28+
<http://www.example.org/unknown> a foaf:Person .
29+
30+
############################################################################
31+
# Classes
32+
############################################################################
33+
34+
ex:SomeClass
35+
a owl:Class;
36+
rdfs:label "Some Class"@en;
37+
rdfs:comment "A Class of Things."@en;
38+
rdfs:seeAlso <http://en.wikipedia.org/>;
39+
vs:term_status "testing".
40+
41+
############################################################################
42+
# Object Properties
43+
############################################################################
44+
45+
ex:objectProperty
46+
a owl:ObjectProperty;
47+
rdfs:label "object property"@en;
48+
rdfs:comment "associates Some Class with another thing"@en;
49+
rdfs:range ex:SomeClass;
50+
rdfs:domain ex:SomeClass;
51+
vs:term_status "testing".

lib/dowl/class.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(resource, schema)
1010
end
1111

1212
def uri
13-
return @resource.uri.to_s
13+
return @resource.to_s
1414
end
1515

1616
def sub_class_of()

lib/dowl/ontology.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def initialize(resource, schema)
3131
super(resource, schema)
3232
end
3333

34-
def uri()
35-
return @resource.to_s
34+
def uri()
35+
return @resource.to_s
3636
end
3737

3838
def title()

lib/dowl/util.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ def initialize(resource, schema)
2323
def short_name()
2424
uri = @resource.to_s
2525
ontology_uri = @schema.ontology.uri
26-
return uri.gsub(ontology_uri, "")
26+
if ontology_uri.end_with?("#") || ontology_uri.end_with?("/")
27+
ontology_uri = ontology_uri[0..-2]
28+
end
29+
name = uri.gsub(/#{ontology_uri}(\/|#)?/, "")
30+
return name
2731
end
2832

2933
def label()

tests/tc_schema.rb

+18-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,25 @@ def test_read_classes_from_sample()
2121
classes = schema.classes()
2222
assert_not_nil classes
2323
assert_equal(2, classes.length)
24+
25+
c = classes["http://www.example.org/dowl/SomeClass"]
26+
assert_equal("SomeClass", c.short_name)
27+
assert_equal("http://www.example.org/dowl/SomeClass", c.uri)
28+
2429
end
25-
30+
31+
def test_hash_uris()
32+
file = "examples/example2.ttl"
33+
schema = DOWL::Schema.create_from_file(File.expand_path(file))
34+
classes = schema.classes()
35+
assert_not_nil classes
36+
assert_equal(1, classes.length)
37+
c = classes.values[0]
38+
assert_equal("SomeClass", c.short_name)
39+
assert_equal("http://www.example.org/dowl#SomeClass", c.uri)
40+
end
41+
42+
2643
def test_identify_owl_classes()
2744
model = RDF::Graph.new()
2845
model << RDF::Statement.new( RDF::URI.new("http://www.example.com/"), RDF.type, DOWL::Namespaces::OWL.Class)

0 commit comments

Comments
 (0)