# Fully qualifying classes underneath the vendor directory

**URL:** <https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690>\
**Category:** Ruby\
**Created:** [May 16, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690 "2006-05-16T19:59:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 16, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690/1 "2006-05-16T19:59:45Z")

</div>

Can I qualify classes using the first directory name under vendor?

Say I have:

vendor/html-scanner/html/node.rb

Can I qualify the Node class using

HTML-Scanner::HTML::Node?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 16, 2006, 8:10pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690/2 "2006-05-16T20:10:16Z")

</div>

Without declaring the namespace using ‘module’?

It might be possible to add a bunch of funky dynamic code that moves  
classes into different namespaces according to their location in the  
filesystem, but it would be a pain. Just declare the namespace  
explicitly.  
-tim

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 16, 2006, 9:35pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690/3 "2006-05-16T21:35:15Z")

</div>

Sorry, I wasn’t clear enough.

What I mean is, can I address the class based on the directory  
underneath the vendor directory. Assume the class already exists.

Tim B. wrote:

> Without declaring the namespace using ‘module’?
> 
> It might be possible to add a bunch of funky dynamic code that moves  
> classes into different namespaces according to their location in the  
> filesystem, but it would be a pain. Just declare the namespace  
> explicitly.  
> -tim

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 16, 2006, 11:19pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690/4 "2006-05-16T23:19:02Z")

</div>

Actually, I’m trying to resolve some mysterious namespace collision and  
I’m thinking that if I qualify specifically enough, I’ll be able to get  
around it. But that doesn’t appear to be the case.

I have done this:  
HTML::Node::Tag.new(parent, line, pos, name, attributes, closing)

but I still can’t successfully instantiate this Tag object. I just  
can’t believe that there is another HTML::Node::Tag class floating  
around.

There is too much auto-magic-overloading stuff going on and I don’t know  
where it’s happening.

Wes

Kirk H. wrote:

> On Tuesday 16 May 2006 11:59 am, Wes G. wrote:
> 
> > Can I qualify classes using the first directory name under vendor?
> > 
> > Say I have:
> > 
> > vendor/html-scanner/html/node.rb
> > 
> > Can I qualify the Node class using
> > 
> > HTML-Scanner::HTML::Node?
> 
> There is nothing automatic to make this happen. It needs extra magic  
> that you  
> would have to write yourself.
> 
> For instance, if node.rb looked something like this:
> 
> class Node
> 
> # Node stuff here…
> 
> end
> 
> Then you could write your own require-like command:
> 
> myrequire ‘vendor/html-scanner/html/node’
> 
> That would look at that path, translate it into the desired nested  
> Module  
> statements, and then load node.rb into that space.
> 
> Is that really what you are needing, though? What are you trying to do?  
> If  
> we know that, we may well be able to suggest a simpler approach.
> 
> Thanks,
> 
> Kirk H.

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 16, 2006, 10:58pm UTC](https://www.ruby-forum.com/t/fully-qualifying-classes-underneath-the-vendor-directory/60690/5 "2006-05-16T22:58:26Z")

</div>

On Tuesday 16 May 2006 11:59 am, Wes G. wrote:

> Can I qualify classes using the first directory name under vendor?
> 
> Say I have:
> 
> vendor/html-scanner/html/node.rb
> 
> Can I qualify the Node class using
> 
> HTML-Scanner::HTML::Node?

There is nothing automatic to make this happen. It needs extra magic  
that you  
would have to write yourself.

For instance, if node.rb looked something like this:

class Node

# Node stuff here…

end

Then you could write your own require-like command:

myrequire ‘vendor/html-scanner/html/node’

That would look at that path, translate it into the desired nested  
Module  
statements, and then load node.rb into that space.

Is that really what you are needing, though? What are you trying to do?  
If  
we know that, we may well be able to suggest a simpler approach.

Thanks,

Kirk H.
