semantic_naming 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/semantic_naming/uri.rb +9 -1
- data/test/uri_test.rb +12 -0
- metadata +2 -2
data/lib/semantic_naming/uri.rb
CHANGED
@@ -79,8 +79,16 @@ module N
|
|
79
79
|
|
80
80
|
# Get a string representation in the form of 'namespace:name'. It is
|
81
81
|
# possible to select a different separator from ':'
|
82
|
+
#
|
83
|
+
# If this uri is not part of a namespace, the whole uri string will
|
84
|
+
# be returned.
|
82
85
|
def to_name_s(separator = ':')
|
83
|
-
|
86
|
+
nspace = namespace
|
87
|
+
if(nspace)
|
88
|
+
"#{nspace}#{separator}#{local_name}"
|
89
|
+
else
|
90
|
+
@uri_s
|
91
|
+
end
|
84
92
|
end
|
85
93
|
|
86
94
|
# This creates a helpers for a nice notation of
|
data/test/uri_test.rb
CHANGED
@@ -224,6 +224,18 @@ class URITest < Test::Unit::TestCase
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
|
+
def test_to_name_s
|
228
|
+
assert_equal('rdftest:foo', N::RDFTEST.foo.to_name_s)
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_to_name_s_separator
|
232
|
+
assert_equal('rdftest#foo', N::RDFTEST.foo.to_name_s('#'))
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_to_name_s_nogo
|
236
|
+
assert_equal('http://unknownnamespacething.com/thing', N::URI.new('http://unknownnamespacething.com/thing').to_name_s)
|
237
|
+
end
|
238
|
+
|
227
239
|
def test_hash
|
228
240
|
assert_equal(N::RDFTEST.testme.to_s.hash, N::RDFTEST.testme.hash)
|
229
241
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantic_naming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Hahn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-26 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|