Skip to content

Commit

Permalink
JRUBY-2722 for real this time AND Rails works
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7205 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
enebo committed Jul 17, 2008
1 parent 10b0ce3 commit 1561011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
11 changes: 0 additions & 11 deletions src/org/jruby/Ruby.java
Expand Up @@ -1830,15 +1830,6 @@ public IRubyObject setValue(IRubyObject newValue) {
public void defineReadonlyVariable(String name, IRubyObject value) { public void defineReadonlyVariable(String name, IRubyObject value) {
globalVariables.defineReadonly(name, new ValueAccessor(value)); globalVariables.defineReadonly(name, new ValueAccessor(value));
} }

/* FIXME: Helper method...we need to do something better than this */
private String tweakPath(String filename) {
File f = new File(filename);

if (f.exists() && !f.isAbsolute() && !filename.startsWith("./")) filename = "./" + filename;

return filename;
}


public Node parseFile(InputStream in, String file, DynamicScope scope) { public Node parseFile(InputStream in, String file, DynamicScope scope) {
return parser.parse(file, in, scope, new ParserConfiguration(0, false, false, true)); return parser.parse(file, in, scope, new ParserConfiguration(0, false, false, true));
Expand Down Expand Up @@ -2036,8 +2027,6 @@ private void printErrorPos(ThreadContext context, PrintStream errorStream) {
} }


public void loadFile(String scriptName, InputStream in, boolean wrap) { public void loadFile(String scriptName, InputStream in, boolean wrap) {
if (!Ruby.isSecurityRestricted()) scriptName = tweakPath(scriptName);

IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this) : getTopSelf(); IRubyObject self = wrap ? TopSelfFactory.createTopSelf(this) : getTopSelf();
ThreadContext context = getCurrentContext(); ThreadContext context = getCurrentContext();
String file = context.getFile(); String file = context.getFile();
Expand Down
5 changes: 4 additions & 1 deletion src/org/jruby/runtime/load/LoadService.java
Expand Up @@ -494,7 +494,10 @@ private LoadServiceResource findFile(String name, boolean checkCWD) {
RubyFile.expandUserPath(runtime.getCurrentContext(), name)); RubyFile.expandUserPath(runtime.getCurrentContext(), name));
if (current.isFile()) { if (current.isFile()) {
try { try {
return new LoadServiceResource(current.toURI().toURL(), current.getPath()); // relative paths without ./ on front get absolute path
String resourcePath = name.startsWith("./") ? name : current.getPath();

return new LoadServiceResource(current.toURI().toURL(), resourcePath);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
throw runtime.newIOErrorFromException(e); throw runtime.newIOErrorFromException(e);
} }
Expand Down

0 comments on commit 1561011

Please sign in to comment.