README.md in open_namespace-0.4.1 vs README.md in open_namespace-0.4.2
- old
+ new
@@ -1,11 +1,10 @@
# OpenNamespace
* [Source](https://github.com/postmodern/open_namespace)
* [Issues](https://github.com/postmodern/open_namespace/issues)
* [Documentation](http://rubydoc.info/gems/open_namespace/frames)
-* [Email](mailto:postmodern.mod3 at gmail.com)
## Description
OpenNamespace allows namespaces to require and find classes and modules from
RubyGems. Using OpenNamespace you can make a `Plugins` module able to
@@ -14,60 +13,78 @@
## Features
* Provides implicit loading of constants via `const_defined?`.
* Provides implicit loading of constants via `const_missing`.
* Provides explicit loading of constants via `require_const`.
+* Can auto-load other sub-gems (ex: `foo-bar`) from the main gem's namespace
+ (ex: `Foo`).
## Examples
-Explicit and implicit loading of constants:
+Include it into a namespace:
- require 'open_namespace'
+```ruby
+require 'open_namespace'
- module Project
- module Plugins
- include OpenNamespace
- end
- end
+module Project
+ module Plugins
+ include OpenNamespace
+ end
+end
+```
- # explicitly load constants
- Project::Plguins.require_const :foo_bar
- # => Project::Plugins::FooBar
+Explicitly load constants via their file name:
- # explicitly load constants with odd capitalization
- Project::Plugins.require_const :tcp_session
- # => Project::Plugins::TCPSession
+```ruby
+Project::Plugins.require_const :foo_bar
+# => Project::Plugins::FooBar
+```
- # explicitly load constants via sub-paths
- Project::Plguins.require_const 'templates/erb'
- # => Project::Plugins::Templates::Erb
+Explicitly load constants containing uppercase acronyms:
- # implicitly load constants via const_missing
- Project::Plugins::Other
- # => Project::Plugins::Other
+```ruby
+Project::Plugins.require_const :tcp_session
+# => Project::Plugins::TCPSession
+```
+Explicitly load constants from nested directories:
+
+```ruby
+Project::Plugins.require_const 'templates/erb'
+# => Project::Plugins::Templates::Erb
+```
+
+Implicitly load constants via `const_missing`:
+
+```ruby
+Project::Plugins::Other
+# => Project::Plugins::Other
+```
+
Loading constants from alternate namespace root directories:
- module Project
- module UI
- module CommandLine
- module Commands
- include OpenNamespace
+```ruby
+module Project
+ module UI
+ module CommandLine
+ module Commands
+ include OpenNamespace
- self.namespace_root = File.join('project','ui','command_line','commands')
- end
- end
+ self.namespace_root = File.join(__dir__,'commands')
end
end
+ end
+end
- Project::UI::CommandLine::Commands.require_const :help
- # => Project::UI::CommandLine::Commands::Help
+Project::UI::CommandLine::Commands.require_const :help
+# => Project::UI::CommandLine::Commands::Help
+```
## Install
- $ gem install open_namespace
+```shell
+$ gem install open_namespace
+```
## License
-
-Copyright (c) 2010-2012 Hal Brodigan
See {file:LICENSE.txt} for license information.