Skip to content

Commit

Permalink
A little more of a sandbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
orangea committed Sep 27, 2009
1 parent 02825d0 commit 840fdef
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions public/tryruby_sandbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,53 @@ def to_s
end
end

class Object
attr_reader :tryruby_line, :tryruby_past_commands, :tryruby_current_includes
@tryruby_line, @tryruby_past_commands, @tryruby_current_includes = ARGV
module TryRuby
Line, Past_commands, current_includes = ARGV
def current_includes
current_includes
end
def current_includes<<(item)
current_includes << item
end
end
ARGV = []

poem = <<POEM_EOF
blah blah blah
My toast has flown from my hand
And my toast has gone to the
moon.
But when I saw it on television,
Planting our flag on Halley's
comet,
More still did I want to eat it.
POEM_EOF

def require(path)
result = ''
path = path.sub(/\.rb$/, "")
return false unless ['popup'].include?(path)
if Object.tryruby_current_includes.include?(path)

else
Thread.new do
result = File.read(path)
Object.tryruby_current_includes << path
#def require(path)
# result = ''
# path = path.sub(/\.rb$/, "")
# return false unless ['popup'].include?(path)
# if Object.tryruby_current_includes.include?(path)
# Thread.new do
#
# end.join
# else
# Thread.new do
# result = File.read(path)
# Object.tryruby_current_includes << path
# end.join
# end
# true
#end
def require(require_path)
result = false
Thread.new do
path = require_path.sub(/\.rb$/, "")
if ['popup'].include?(path) and !TryRuby::Current_includes.include?(path)
TryRuby::Current_includes << path
result = true
end
end
true
end.join
result
end

$stdout = FakeStdout.new
Expand Down

0 comments on commit 840fdef

Please sign in to comment.