I was trying to get 'require "erb"' to work within a ruby script
loaded from a Servlet.  I came to the realization that because
the system property jruby.home was not set, we were not defining
any of our usual path directories for finding modules.

  This patch just makes jruby.home a '.' if it is not set.  This
makes all the paths get set up so that require erb works etc...
Is this a good idea though?  Anyone have thoughts?  One reason
I ran into this is BSF does not require that jruby.home be set.
Of course I could manually set it to '.', but then anyone using
BSF would have to basically do this everytime.  People who try
and embed directly will have to do something like this too.

  My other thought is perhaps we should treat jarPaths as only
a special concept?  Actually perhaps that "jar:" processing in
findFile is meant for this purpose?

-Tom

-- 
+ http://www.tc.umn.edu/~enebo +---- mailto:[EMAIL PROTECTED] ----+
| Thomas E Enebo, Protagonist  | "Luck favors the prepared    |
|                              |  mind." -Louis Pasteur       |
Index: LoadService.java

===================================================================

RCS file: /cvsroot/jruby/jruby/src/org/jruby/runtime/load/LoadService.java,v

retrieving revision 1.6

diff -u -r1.6 LoadService.java

--- LoadService.java    23 Dec 2005 16:23:19 -0000      1.6

+++ LoadService.java    22 Jan 2006 20:11:46 -0000

@@ -82,21 +82,25 @@

         }

       }

       

+      // Get home directory or assume a home directory.  By providing '.', all 
paths added will

+      // find ruby files in jar files.  BSF is one area that benefits from 
this behavior.

       String jrubyHome = System.getProperty("jruby.home");

-      if (jrubyHome != null) {

-        char sep = File.separatorChar;

-        String rubyDir = jrubyHome + sep + "lib" + sep + "ruby" + sep;

+      if (jrubyHome == null) {

+          jrubyHome = ".";

+      } 

+          

+      char sep = File.separatorChar;

+      String rubyDir = jrubyHome + sep + "lib" + sep + "ruby" + sep;

         

-        addPath(rubyDir + "site_ruby" + sep + Constants.RUBY_MAJOR_VERSION);

-        addPath(rubyDir + "site_ruby" + sep + Constants.RUBY_MAJOR_VERSION + 
sep + "java");

-        addPath(rubyDir + "site_ruby");

-        addPath(rubyDir + Constants.RUBY_MAJOR_VERSION);

-        addPath(rubyDir + Constants.RUBY_MAJOR_VERSION + sep + "java");

+      addPath(rubyDir + "site_ruby" + sep + Constants.RUBY_MAJOR_VERSION);

+      addPath(rubyDir + "site_ruby" + sep + Constants.RUBY_MAJOR_VERSION + sep 
+ "java");

+      addPath(rubyDir + "site_ruby");

+      addPath(rubyDir + Constants.RUBY_MAJOR_VERSION);

+      addPath(rubyDir + Constants.RUBY_MAJOR_VERSION + sep + "java");

         

-        // Added to make sure we find default distribution files within jar 
file.

-        // TODO: Either make jrubyHome become the jar file or allow 
"classpath-only" paths

-        addPath("lib" + sep + "ruby" + sep + Constants.RUBY_MAJOR_VERSION);

-      }

+      // Added to make sure we find default distribution files within jar file.

+      // TODO: Either make jrubyHome become the jar file or allow 
"classpath-only" paths

+      addPath("lib" + sep + "ruby" + sep + Constants.RUBY_MAJOR_VERSION);

       

       if (runtime.getSafeLevel() == 0) {

         addPath(".");

@@ -219,7 +223,7 @@

                 if (isRequireable(loc)) {

                        return new LoadServiceResource(loc, loc.getPath());

                 }

-            }

+                }

             

             for (Iterator pathIter = loadPath.iterator(); pathIter.hasNext();) 
{

                 String entry = pathIter.next().toString();

Reply via email to