@Deprecated protected Library findBuiltinLibrary(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = baseName + suffix; debugLogTry( "builtinLib", namePlusSuffix ); if (builtinLibraries.containsKey(namePlusSuffix)) { state.setLoadName(namePlusSuffix); Library lib = builtinLibraries.get(namePlusSuffix); debugLogFound( "builtinLib", namePlusSuffix ); return lib; } } return null; }
@Deprecated protected Library findBuiltinLibrary(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = baseName + suffix; debugLogTry( "builtinLib", namePlusSuffix ); if (builtinLibraries.containsKey(namePlusSuffix)) { state.setLoadName(namePlusSuffix); Library lib = builtinLibraries.get(namePlusSuffix); debugLogFound( "builtinLib", namePlusSuffix ); return lib; } } return null; }
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; // end suffix iteration } catch(Exception e) {} if (foundResource != null) { state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; // end suffix iteration
state.setLoadName(resolveLoadName(foundResource, foundResource.getName())); state.setLoadName(resolveLoadName(foundResource, foundResource.getName())); state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); return foundResource; ss = ss.substring(2); state.setLoadName(resolveLoadName(foundResource, ss)); break Outer; ss = ss.substring(2); state.setLoadName(resolveLoadName(foundResource, ss)); break Outer; // end suffix iteration
state.setLoadName(resolveLoadName(foundResource, foundResource.getName())); state.setLoadName(resolveLoadName(foundResource, foundResource.getName())); state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); return foundResource; ss = ss.substring(2); state.setLoadName(resolveLoadName(foundResource, ss)); break Outer; ss = ss.substring(2); state.setLoadName(resolveLoadName(foundResource, ss)); break Outer; // end suffix iteration
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; // end suffix iteration } catch(Exception e) {} if (foundResource != null) { state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; // end suffix iteration
@Deprecated protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException { LoadServiceResource foundResource = null; RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV"); RubyString env_home = runtime.newString("HOME"); if (env.has_key_p(env_home).isFalse()) { return null; } String home = env.op_aref(runtime.getCurrentContext(), env_home).toString(); String path = baseName.substring(2); for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = path + suffix; // check home directory; if file exists, retrieve URL and return resource try { JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix)); debugLogTry("resourceFromHome", file.toString()); if (file.isFile() && file.isAbsolute() && file.canRead()) { boolean absolute = true; state.setLoadName(file.getPath()); foundResource = new LoadServiceResource(file, state.loadName, absolute); debugLogFound(foundResource); break; } } catch (IllegalArgumentException illArgEx) { } catch (SecurityException secEx) { } } return foundResource; }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); int currentLine = runtime.getCurrentLine(); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { debugLoadException(runtime, e); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { runtime.setCurrentLine(currentLine); loadTimer.endLoad("classloader:" + file, startTime); } }
@Deprecated protected LoadServiceResource tryResourceFromHome(SearchState state, String baseName, SuffixType suffixType) throws RaiseException { LoadServiceResource foundResource = null; RubyHash env = (RubyHash) runtime.getObject().getConstant("ENV"); RubyString env_home = runtime.newString("HOME"); if (env.has_key_p(env_home).isFalse()) { return null; } String home = env.op_aref(runtime.getCurrentContext(), env_home).toString(); String path = baseName.substring(2); for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = path + suffix; // check home directory; if file exists, retrieve URL and return resource try { JRubyFile file = JRubyFile.create(home, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix)); debugLogTry("resourceFromHome", file.toString()); if (file.isFile() && file.isAbsolute() && file.canRead()) { boolean absolute = true; state.setLoadName(file.getPath()); foundResource = new LoadServiceResource(file, state.loadName, absolute); debugLogFound(foundResource); break; } } catch (IllegalArgumentException illArgEx) { } catch (SecurityException secEx) { } } return foundResource; }
public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wrap) { long startTime = loadTimer.startLoad("classloader:" + file); int currentLine = runtime.getCurrentLine(); try { SearchState state = new SearchState(file); state.prepareLoadSearch(file); Library library = null; LoadServiceResource resource = getClassPathResource(classLoader, file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); library = createLibrary(state, resource); } if (library == null) { throw runtime.newLoadError("no such file to load -- " + file); } try { library.load(runtime, wrap); } catch (IOException e) { debugLoadException(runtime, e); throw newLoadErrorFromThrowable(runtime, file, e); } } finally { runtime.setCurrentLine(currentLine); loadTimer.endLoad("classloader:" + file, startTime); } }
@Deprecated protected LoadServiceResource tryResourceFromCWD(SearchState state, String baseName,SuffixType suffixType) throws RaiseException { LoadServiceResource foundResource = null; for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = baseName + suffix; // check current directory; if file exists, retrieve URL and return resource try { JRubyFile file = JRubyFile.create(runtime.getCurrentDirectory(), RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix)); debugLogTry("resourceFromCWD", file.toString()); if (file.isFile() && file.isAbsolute() && file.canRead()) { boolean absolute = true; foundResource = new LoadServiceResource(file, getFileName(file, namePlusSuffix), absolute); debugLogFound(foundResource); state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; } } catch (IllegalArgumentException illArgEx) { } catch (SecurityException secEx) { } } return foundResource; }
@Deprecated protected LoadServiceResource tryResourceFromCWD(SearchState state, String baseName,SuffixType suffixType) throws RaiseException { LoadServiceResource foundResource = null; for (String suffix : suffixType.getSuffixes()) { String namePlusSuffix = baseName + suffix; // check current directory; if file exists, retrieve URL and return resource try { JRubyFile file = JRubyFile.create(runtime.getCurrentDirectory(), RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix)); debugLogTry("resourceFromCWD", file.toString()); if (file.isFile() && file.isAbsolute() && file.canRead()) { boolean absolute = true; foundResource = new LoadServiceResource(file, getFileName(file, namePlusSuffix), absolute); debugLogFound(foundResource); state.setLoadName(resolveLoadName(foundResource, namePlusSuffix)); break; } } catch (IllegalArgumentException illArgEx) { } catch (SecurityException secEx) { } } return foundResource; }
public FoundLibrary findBySearchState(LoadService.SearchState state) { FoundLibrary lib = findLibrary(state.searchFile, state.suffixType); if (lib != null) { state.library = lib; state.setLoadName(lib.getLoadName()); } return lib; }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); return createLibrary(state, resource); } } return null; }
protected Library findLibraryWithClassloaders(SearchState state, String baseName, SuffixType suffixType) { for (String suffix : suffixType.getSuffixes()) { String file = baseName + suffix; LoadServiceResource resource = findFileInClasspath(file); if (resource != null) { state.setLoadName(resolveLoadName(resource, file)); return createLibrary(state, resource); } } return null; }
public FoundLibrary findBySearchState(LoadService.SearchState state) { FoundLibrary lib = findLibrary(state.searchFile, state.suffixType); if (lib != null) { state.library = lib; state.setLoadName(lib.getLoadName()); } return lib; }