public
Description: Johnson wraps JavaScript in a loving Ruby embrace.
Homepage: http://github.com/jbarnette/johnson/wikis
Clone URL: git://github.com/jbarnette/johnson.git
Make sure bin/johnson doesn't talk about context at all.
jbarnette (author)
Sat May 31 11:00:34 -0700 2008
commit  931eea8d2fa38679cf0cab0d3e8cdfcc824f65a3
tree    c781367b8b41ef48807fc46734e175de37b833d6
parent  59807b0f2fbcd193aeec31f8676bffad951fc772
...
9
10
11
12
13
 
 
14
15
16
...
46
47
48
49
 
50
51
52
...
55
56
57
58
 
59
60
61
 
62
63
64
65
66
 
67
68
69
...
9
10
11
 
 
12
13
14
15
16
...
46
47
48
 
49
50
51
52
...
55
56
57
 
58
59
60
 
61
62
63
64
65
 
66
67
68
69
0
@@ -9,8 +9,8 @@ end
0
 
0
 require "readline"
0
 
0
-CONTEXT = cx = Johnson::Runtime.new
0
-CONTEXT[:alert] = lambda { |m| puts m }
0
+RUNTIME = js = Johnson::Runtime.new
0
+RUNTIME[:alert] = lambda { |m| puts m }
0
 
0
 EXIT_VERBS = [nil] + %w(exit quit)
0
 
0
@@ -46,7 +46,7 @@ rescue Exception => e
0
 end
0
 
0
 def eval_in_js(expression)
0
-  rescued { puts "=> " + CONTEXT.evaluate(expression, "(console)").inspect }
0
+  rescued { puts "=> " + RUNTIME.evaluate(expression, "(console)").inspect }
0
 end
0
 
0
 def eval_in_ruby(expression, bind_to)
0
@@ -55,15 +55,15 @@ end
0
 
0
 options = Johnson::CLI::Options.parse!(ARGV)
0
 options.load_paths.each { |d| $LOAD_PATH << d }
0
-options.files_to_preload.each { |f| CONTEXT.load(f) }
0
+options.files_to_preload.each { |f| RUNTIME.load(f) }
0
 
0
 unless options.files_to_evaluate.empty?
0
-  options.files_to_evaluate.each { |f| CONTEXT.load(f) }
0
+  options.files_to_evaluate.each { |f| RUNTIME.load(f) }
0
   exit
0
 end
0
 
0
 unless options.expressions.empty?
0
-  options.expressions.each { |e| CONTEXT.evaluate(e, '-e') }
0
+  options.expressions.each { |e| RUNTIME.evaluate(e, '-e') }
0
   exit
0
 end
0
 

Comments