Skip to content

Commit

Permalink
Moves some comments around
Browse files Browse the repository at this point in the history
  • Loading branch information
bougyman committed Apr 11, 2024
1 parent fce11c5 commit 6c2979e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/namespacer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

# Top-level namespace to keep Rubyists namespaces in isolation
module Rubyists
# Wrap some namespace around top-level AST nodes of 'module' or 'class' type
# Namespace for the namespacer tool
module Namespacer
# Do the rewriting with the rewriter class
# Do the AST rewriting with the Rewriter class
class Rewriter < Parser::TreeRewriter
attr_accessor(:namespaces)

Expand Down Expand Up @@ -44,6 +44,7 @@ def _on_module(node)
end
end

# Wrap some namespace around top-level AST nodes of 'module' or 'class' type
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
Expand All @@ -56,5 +57,5 @@ def self.namespace!(string_or_io, namespaces)

if $PROGRAM_NAME == __FILE__
warn 'Wrapping myself'
puts Rubyists::Namespacer.namespace!(File.read(__FILE__), 'Rubyists::Namespacer')
puts Rubyists::Namespacer.namespace!(File.read(__FILE__), 'Wrapped::Smoke::Test')
end

0 comments on commit 6c2979e

Please sign in to comment.