Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Whitespace
- def self.trollify path, code
- code.chomp!.gsub!(/([ \t]+)$/) do |match|
- "; sleep(1)" * match.length
- end
- code.gsub!(/\brequire_relative\s*\(?\s*(.+?)\s*\)?;?$/) do |match|
- "Whitespace::require_relative #{$1}, binding(), '#{path}'"
- end
- code
- end
- def self.require_relative s, b = binding(), path = ""
- s = File.expand_path(s, path)
- return if /\bwhitespace(?:.rb)?[^\/]/ =~ s
- eval trollify(File.dirname(s), File.open(s).read), b
- end
- end
- caller_file = caller.first.split(/:\d/, 2).first
- abs_path = File.expand_path(caller_file, File.dirname(caller_file))
- Whitespace::require_relative abs_path, binding()
- exit
Add Comment
Please, Sign In to add comment