Sha256: c0fce0ff48d41ccae2d6deff2853915a59a713c9e2b3a5ba29c4513acc9cfdaf

Contents?: true

Size: 595 Bytes

Versions: 9

Compression:

Stored size: 595 Bytes

Contents

require 'internal/node'

class Node
  def obfusc(begin_nodes=[])
    n = self

    # The outputted code must do the following:
    #   1. Evaluate each of the begin nodes (BEGIN {...}).
    #   2. Evaluate the main node.
    return <<-END
  require 'internal/node'
  if RUBY_VERSION != "#{RUBY_VERSION}" then
    $stderr.puts "Wrong Ruby version; please use #{RUBY_VERSION}"
    exit 1
  end
  begin_nodes = Marshal.load(#{Marshal.dump(begin_nodes).inspect})
  n = Marshal.load(#{Marshal.dump(n).inspect})
  begin_nodes.each do |node|
    node.eval(self)
  end
  n.eval(self)
    END
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-internal-0.8.5 lib/internal/node/obfusc.rb
ruby-internal-0.8.4 lib/internal/node/obfusc.rb
ruby-internal-0.8.3 lib/internal/node/obfusc.rb
ruby-internal-0.8.2 lib/internal/node/obfusc.rb
ruby-internal-0.8.1 lib/internal/node/obfusc.rb
ruby-internal-0.8.0 lib/internal/node/obfusc.rb
ruby-internal-0.7.3 lib/internal/node/obfusc.rb
ruby-internal-0.7.2 lib/internal/node/obfusc.rb
ruby-internal-0.7.1 lib/internal/node/obfusc.rb