1 31 package org.jruby.runtime.load; 32 33 import java.io.BufferedReader ; 34 import java.io.IOException ; 35 import java.io.InputStreamReader ; 36 import java.io.Reader ; 37 import org.jruby.Ruby; 38 import org.jruby.runtime.load.LoadServiceResource; 39 import org.jruby.util.KCode; 40 41 public class ExternalScript implements Library { 42 private final LoadServiceResource resource; 43 44 public ExternalScript(LoadServiceResource resource, String name) { 45 this.resource = resource; 46 } 47 48 public void load(Ruby runtime) { 49 try { 50 Reader reader = new BufferedReader (new InputStreamReader (resource.getURL().openStream(), KCode.NONE.decoder())); 53 runtime.loadScript(resource.getName(), reader, false); 54 reader.close(); 55 } catch (IOException e) { 56 throw runtime.newIOErrorFromException(e); 57 } 58 } 59 } 60 | Popular Tags |