3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/ruby_on_ruby/file_loader.rb', line 3
def self.setup(context)
context.eval " XMLHttpRequest = function() {\n this.open = function(type, url) {\n this.responseText = loadFile(url);\n };\n this.send = function() {};\n this.status = 200;\n this.responseText = \"\";\n return this;\n };\n JS\n\n context['loadFile'] = lambda do |this, url|\n begin\n if url && url =~ /\\A\\.\\/lib\\/([\\w\\_\\-\\/]+\\.rb)\\Z/i\n file_name = $1\n File.read(File.expand_path(\"../../../vendor/javascripts/emscripted-ruby/lib/\#{file_name}\", __FILE__), :encoding => \"binary\")\n else\n nil\n end\n rescue => e\n puts \"Exception when loading \#{url}: \#{e.message}\"\n raise\n end\n end\nend\n"
|