Permalink
Browse files

cleaned up bootstrap script

  • Loading branch information...
1 parent 61ae647 commit 6607dcd9bc4fc7eb1ff3223319489b0a53dac5fc @oneup committed Jun 26, 2009
Showing with 37 additions and 25 deletions.
  1. 0 {ruby_fix → }/activeresource.rb
  2. 0 {ruby_fix → }/from_future_import.rb
  3. +37 −25 play.rb
View
0 ruby_fix/activeresource.rb → activeresource.rb
File renamed without changes.
View
0 ruby_fix/from_future_import.rb → from_future_import.rb
File renamed without changes.
View
62 play.rb
@@ -3,39 +3,51 @@
# RUBY PREREQUISITS
require "rubygems"
require "yaml"
-require "ruby_fix/from_future_import.rb" # gemify this !
-require "ruby_fix/activeresource.rb" # gemify this !
+
+require "from_future_import.rb" # @todo replace by activesupport / activestring (mine)
+require "activeresource.rb"
begin
+ # LOAD THE UNIVERSE
+ require_package "backend"
-# LOAD THE UNIVERSE
-require_package "backend"
-# CODE GAMES!
-$game_name = ARGV[0] || $config['default_game']
-require_package $game_name
+ # CODE GAMES!
+ $game_name = ARGV[0] || $config['default_game']
+ if $game_name.ends_with? "/" # clean game name
+ $game_name = $game_name[0...$game_name.size-1]
+ end
-if $game_name.ends_with? "/"
- $game_name = $game_name[0...$game_name.size-1]
-end
+ require_package $game_name
-println "no game #{$game_name} found" and exit unless $game_name.is_folder?
+ println "no game #{$game_name} found" and exit unless $game_name.is_folder?
-# PLAY!
-class_name = $game_name.classify
-$game_class = class_name.instantiate rescue quit("Your game class needs to be called #{class_name}")
-begin
- $game_class.run
-rescue Exit => e
- println "\nGAME OVER: #{e}\n"
+ # PLAY!
+ class_name = $game_name.classify
+ $game_class = class_name.instantiate rescue quit("Your game class needs to be called #{class_name}")
+
+ begin
+ $game_class.run
+ rescue Exit => e # @todo should not be handled via exception
+ println "\nGAME OVER: #{e}\n"
+ end
+ # get this exception REPL shell running
+ #rescue Exception => e
+ # println "GRR, EXCEPTION!"
+ # println e.message
+ # println e.backtrace
+ #
+ # repl
end
-# get this exception REPL shell running
-#rescue Exception => e
-# println "GRR, EXCEPTION!"
-# println e.message
-# println e.backtrace
-#
-# repl
+def repl
+ s = gets.trim
+ begin
+ result = eval(s)
+ rescue Exception => e
+ puts "Exception: #{e.inspect}"
+ rescue SyntaxError => e
+ puts "SyntaxError: #{e.inspect}"
+ end
end

0 comments on commit 6607dcd

Please sign in to comment.