Permalink
Browse files

Handle creation of objects with complex object paths when path starts…

… with "::"

Closes #552
  • Loading branch information...
1 parent d756bdb commit 60ff55b93c12953bf685b0ded6ee0a86f947d626 @lsegal committed Jul 15, 2012
Showing with 18 additions and 1 deletion.
  1. +3 −1 lib/yard/code_objects/base.rb
  2. +15 −0 spec/code_objects/base_spec.rb
@@ -170,7 +170,9 @@ def new(namespace, name, *args, &block)
if name.to_s[0,2] == NSEP
name = name.to_s[2..-1]
namespace = Registry.root
- elsif name =~ /(?:#{NSEPQ})([^:]+)$/
+ end
+
+ if name =~ /(?:#{NSEPQ})([^:]+)$/
return new(Proxy.new(namespace, $`), $1, *args, &block)
end
@@ -28,6 +28,21 @@
YARD::Registry.at("MYMODULE").should be_instance_of(ClassObject)
end
+ it "should simplify complex namespace paths" do
+ obj = ClassObject.new(:root, "A::B::C::D")
+ obj.name.should == :D
+ obj.path.should == "A::B::C::D"
+ obj.namespace.should == P("A::B::C")
+ end
+
+ # @bug gh-552
+ it "should simplify complex namespace paths when path starts with ::" do
+ obj = ClassObject.new(:root, "::A::B::C::D")
+ obj.name.should == :D
+ obj.path.should == "A::B::C::D"
+ obj.namespace.should == P("A::B::C")
+ end
+
it "should recall the block if #new is called on an existing object" do
o1 = ClassObject.new(:root, :Me) do |o|
o.docstring = "DOCSTRING"

0 comments on commit 60ff55b

Please sign in to comment.