Method: Thor::Util.namespaces_in_content
- Defined in:
- lib/vendor/thor/lib/thor/util.rb
.namespaces_in_content(contents, file = __FILE__) ⇒ Object
Given the contents, evaluate it inside the sandbox and returns the namespaces defined in the sandbox.
Parameters
contents<String>
Returns
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vendor/thor/lib/thor/util.rb', line 58 def self.namespaces_in_content(contents, file=__FILE__) old_constants = Thor::Base.subclasses.dup Thor::Base.subclasses.clear load_thorfile(file, contents) new_constants = Thor::Base.subclasses.dup Thor::Base.subclasses.replace(old_constants) new_constants.map!{ |c| c.namespace } new_constants.compact! new_constants end |