Require constants into current namespace
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.travis.yml
Gemfile
Gemfile.lock
README.md
Rakefile
require-here.gemspec

README.md

require-here

Keep your namespaces clean. Require constants into current namespace

Build Status

Example

# File: a.rb

module GenericModuleName
  def self.method
    :a
  end
end

# File: b.rb

module GenericModuleName
  def self.method
    :b
  end
end

# File: space.rb

require 'require_here'

module Space
  module OnePlace
    require_here './a'
  end

  module AnotherPlace
    require_here './b'
  end
end

# The modules are not included into the global namespace.
GenericModuleName rescue $!
# => #<NameError: uninitialized constant Object::GenericModuleName>

# Also they are not reopened.
Space::OnePlace::GenericModuleName.method
# => :a
Space::AnotherPlace::GenericModuleName.method
# => :b