Reputation: 19249
If I'm writing a helper for an established library, should I create a TheirLibrary::MyHelper
module in their namespace, or stay out and make my own ::TheirLibraryMyHelper
?
I'm thinking to be predictably consistent, libraries often have precedent for adding extensions to their namespace, such as Spec::Rails
, which is a plugin of rails helpers for RSpec, in the existing ::Spec
namespace.
On the other hand, I don't feel I "own" the other authors namespace, so should I have any business adding sub-namespaces to it?
Upvotes: 2
Views: 481
Reputation: 19249
Looking around, I noticed that the convention for "plugin" or "extension" gems are required as:
require 'coolthing/plugin'
which corresponds to the namespace Coolthing::Plugin
while other projects are
require 'coolthing-plugin'
which corresponds to the unique namespace CoolthingPlugin
Generally only those that are "official" are embedded into the original namespace. Those that are follow-on additions from separate parties should use their own namespace.
Upvotes: 0
Reputation: 18747
I would stay out of their namespace (whatever you end up choosing to name your extension namespace) because that means you aren't going to accidentally collide with something they decide to do down the road.
Upvotes: 1