semantic_naming 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
- "#{namespace}#{separator}#{local_name}"
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.5
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-25 00:00:00 +01:00
12
+ date: 2009-11-26 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15