Permalink
Browse files

#require

  • Loading branch information...
1 parent 5e90aa7 commit af0f9435680977ca92410d812a399fa5a245897d @txus committed Jan 29, 2012
Showing with 20 additions and 5 deletions.
  1. +1 −1 kernel/test_case.nsc
  2. +1 −1 kernel/traits.nsc
  3. +18 −3 lib/noscript/runtime.rb
View
2 kernel/test_case.nsc
@@ -1,5 +1,5 @@
!RBIX
-2199918003027222139
+14826142347510856616
0
M
1
View
2 kernel/traits.nsc
@@ -1,5 +1,5 @@
!RBIX
-2199918003027222139
+14826142347510856616
0
M
1
View
21 lib/noscript/runtime.rb
@@ -90,8 +90,8 @@ def method_missing(m, *args)
end
module Kernel
- def noscript_require(file)
- here = File.dirname(caller.first.split(":").first)
+ def noscript_require(file, backtrace=caller)
+ here = File.dirname(backtrace.first.split(":").first)
old_paths = Noscript::CodeLoader.load_paths
Noscript::CodeLoader.load_paths.unshift(here)
Noscript::CodeLoader.run(file)
@@ -175,9 +175,24 @@ def noscript_send(name, *args)
send *args
end
+ noscript_def("require") do |file|
+ backtrace = [caller.detect {|line| line =~ /eval_noscript/}]
+ noscript_require(file, backtrace)
+ end
+
+ noscript_def("ruby require") do |file|
+ require file
+ end
+
+ noscript_def("ruby require relative") do |file|
+ backtrace = [caller.detect {|line| line =~ /eval_noscript/}]
+ here = File.dirname(backtrace.first.split(":").first)
+ require File.expand_path(File.join(here, file))
+ end
+
noscript_alias [:==, :"!="]
noscript_alias [:include, :extend, :def]
- noscript_def("@!") { !self }
+ noscript_def("!") { !self }
noscript_alias :nil?
noscript_alias :inspect

0 comments on commit af0f943

Please sign in to comment.