Method: Web.load_narf

Defined in:
lib/web/runner.rb

.load_narf(scriptname, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/web/runner.rb', line 53

def Web::load_narf( scriptname, options = {} )
  Web::process(options) do
    begin
      raise "Web::load -- no scriptname to run (nil)" unless scriptname

      narf_src = File.open(scriptname,'r'){|f|f.read}
      ruby_src = narf_src.gsub( SHEBANG_PATTERN, '' )
      
      script = PHPRB.new(ruby_src)
      script.filename = scriptname
      Web::puts( script.result )
      
    # print out html on syntax error
    rescue SyntaxError => err
      if (options[:testing])
        raise err
      else
        message = err.message
        # munging message is hard, and I am afraid
        Web::print_message( err.class.to_s, "<table><tr><td><pre>#{message}</pre></td></tr></table>" )
      end
    end
  end
end