Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e395dd78e954
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 38c1d3fea6a6
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 25, 2015

  1. Copy the full SHA
    1bafb83 View commit details
  2. Copy the full SHA
    38c1d3f View commit details
Showing with 12 additions and 11 deletions.
  1. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  2. +11 −10 truffle/src/main/java/org/jruby/truffle/runtime/loader/SourceLoader.java
Original file line number Diff line number Diff line change
@@ -288,7 +288,7 @@ public boolean isRunningOnWindows() {
}

public void loadFile(String fileName, Node currentNode) throws IOException {
if (new File(fileName).isAbsolute() || fileName.startsWith("jruby:") || fileName.startsWith("truffle:")) {
if (new File(fileName).isAbsolute() || fileName.startsWith(SourceLoader.JRUBY_SCHEME) || fileName.startsWith(SourceLoader.TRUFFLE_SCHEME)) {
loadFileAbsolute(fileName, currentNode);
} else {
loadFileAbsolute(new File(this.getRuntime().getCurrentDirectory() + File.separator + fileName).getCanonicalPath(), currentNode);
Original file line number Diff line number Diff line change
@@ -44,31 +44,32 @@ private Source loadInlineScript() {
StandardCharsets.UTF_8), "-e");
}

private Source loadResource(String canonicalPath) throws IOException {
if (!canonicalPath.toLowerCase(Locale.ENGLISH).endsWith(".rb")) {
throw new FileNotFoundException(canonicalPath);
private Source loadResource(String path) throws IOException {
if (!path.toLowerCase(Locale.ENGLISH).endsWith(".rb")) {
throw new FileNotFoundException(path);
}

final Class relativeClass;
final String relativePath;

if (canonicalPath.startsWith(TRUFFLE_SCHEME)) {
if (path.startsWith(TRUFFLE_SCHEME)) {
relativeClass = RubyContext.class;
relativePath = canonicalPath.substring(TRUFFLE_SCHEME.length());
} else if (canonicalPath.startsWith(JRUBY_SCHEME)) {
relativePath = path.substring(TRUFFLE_SCHEME.length());
} else if (path.startsWith(JRUBY_SCHEME)) {
relativeClass = Ruby.class;
relativePath = canonicalPath.substring(JRUBY_SCHEME.length());
relativePath = path.substring(JRUBY_SCHEME.length());
} else {
throw new UnsupportedOperationException();
}

final InputStream stream = relativeClass.getResourceAsStream(relativePath);
final String canonicalPath = (new File(relativePath)).getCanonicalPath();
final InputStream stream = relativeClass.getResourceAsStream(canonicalPath);

if (stream == null) {
throw new FileNotFoundException(canonicalPath);
throw new FileNotFoundException(path);
}

return Source.fromReader(new InputStreamReader(stream, StandardCharsets.UTF_8), canonicalPath);
return Source.fromReader(new InputStreamReader(stream, StandardCharsets.UTF_8), path);
}

}