Module: Rubyists::Namespacer
- Defined in:
- lib/namespacer.rb,
lib/namespacer/version.rb,
lib/namespacer/rewriter.rb
Overview
Namespace for the namespacer tool
Defined Under Namespace
Classes: Rewriter
Constant Summary collapse
- VERSION =
'0.1.10'
Class Method Summary collapse
-
.namespace!(string_or_io, namespaces) ⇒ String
Wrap some namespace(s) around top-level AST nodes of ‘module’ or ‘class’ type.
Class Method Details
.namespace!(string_or_io, namespaces) ⇒ String
Wrap some namespace(s) around top-level AST nodes of ‘module’ or ‘class’ type
20 21 22 23 24 25 26 |
# File 'lib/namespacer.rb', line 20 def self.namespace!(string_or_io, namespaces) buffer = Parser::Source::Buffer.new("(#{namespaces})") buffer.source = string_or_io.is_a?(IO) ? string_or_io.read : string_or_io parser = Parser::CurrentRuby.new rewriter = Rubyists::Namespacer::Rewriter.new namespaces rewriter.rewrite(buffer, parser.parse(buffer)) end |