Skip to content

Commit

Permalink
Merge pull request jruby#130 from akiellor/bin-scripts
Browse files Browse the repository at this point in the history
Enable running binscripts from classpath.
  • Loading branch information
nicksieger committed Mar 24, 2012
2 parents e35a5cf + f0ed17b commit 248afa3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/org/jruby/util/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@
***** END LICENSE BLOCK *****/
package org.jruby.util.cli;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.exceptions.MainExitException;
import org.jruby.util.JRubyFile;
import org.jruby.util.KCode;
import org.jruby.util.SafePropertyAccessor;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* Encapsulated logic for processing JRuby's command-line arguments.
*
Expand Down Expand Up @@ -496,6 +498,9 @@ private String resolveScript(String scriptName) {
} catch (Exception e) {
// keep going, try PATH
}
if(Ruby.getClassLoader().getResourceAsStream("bin/" + scriptName) != null){
return "classpath:bin/" + scriptName;
}
try {
Object pathObj = config.getEnvironment().get("PATH");
String path = pathObj.toString();
Expand Down
Binary file modified test/dir with spaces/testgem.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_jar_complete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,10 @@ def test_script_with__FILE__constant_in_jar_with_spaces
output = jruby_complete(complete_jar, %{-e "require '_file_constant_'"}).chomp
assert output =~ /#{tmp}/, "'#{output}' does not match '#{tmp}'"
end

def test_binscripts_can_be_run_from_classpath
output = `java -cp \"#{COMPLETE_JAR}:test/dir with spaces/testgem.jar\" org.jruby.Main -S testgem`

assert output == "Testing... 1.. 2.. 3..\n"
end
end

0 comments on commit 248afa3

Please sign in to comment.