Also, as long as you have your code under Bar, only Bar is really polluted.  In 
the case of 

module Foo
  module Bar
    class Stuff; end
  end
end

If another (Gem B) you can do the same thing:

module Foo
  module Bazz
    class Things; end
  end
end

Foo::Bar is isolated from Foo::Bazz and you avoid the issues the Joe mentioned.

Best,
Rob


On Jan 5, 2012, at 9:36 , Ben Hughes wrote:

> Marvin,
> 
> It will work, just declare the module in Gem A:
> 
> module Foo
>   module Bar
>     class Stuff; end
>   end
> end
> 
> If another (Gem B) you can do the same thing:
> 
> module Foo
>   module Bar
>     class Things; end
>   end
> end
> 
> The key here is to declare the module explicitly like the above; you can't 
> just do:
> 
> class Foo::Bar::Stuff
> end
> 
> Because the reference Foo is not already defined.
> 
> Ben
> 
> 
> On Thu, Jan 5, 2012 at 3:06 PM, Marvin Humphrey <[email protected]> 
> wrote:
> Greets,
> 
> I'd like to release a gem foo-bar, which contains the classes
> Foo::Bar::Stuff and Foo::Bar::Things.  Is it possible to do this without
> claiming the namespace "Foo"?
> 
> The motivation here is to release multiple *unrelated* gems under the same
> top-level namespace.  None of them should require a prerequisite 'foo'.
> 
> I'm having difficulty seeing how this would work because it doesn't seem to be
> possible to create a class "Foo::Bar" unless a class or module named "Foo"
> already exists.  Thus, each gem would need to create "Foo", presumably
> introducing a conflict if they are ever loaded within the same process.
> 
> Marvin Humphrey
> 
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
> 
> 
> -- 
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to