Skip to content

Commit

Permalink
resolves issue asciidoctor#258 by adding create method with classload…
Browse files Browse the repository at this point in the history
…er and gempath.
  • Loading branch information
lordofthejars committed Dec 29, 2014
1 parent 8a09838 commit 89dde90
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,11 @@ private static Asciidoctor createJRubyAsciidoctorInstance(Map<String, Object> en

private static Asciidoctor createJRubyAsciidoctorInstance(ClassLoader classloader, String gemPath) {

Map<String, Object> env = new HashMap<String, Object>();
env.put(GEM_PATH, gemPath);

ScriptingContainer container = new ScriptingContainer();
setsGemPath(gemPath, container);
injectEnvironmentVariables(container.getProvider().getRubyInstanceConfig(), env);
container.setClassLoader(classloader);
Ruby rubyRuntime = container.getProvider().getRuntime();

Expand All @@ -164,13 +167,6 @@ private static Asciidoctor createJRubyAsciidoctorInstance(ClassLoader classloade
return jRubyAsciidoctor;
}

private static void setsGemPath(String gemPath, ScriptingContainer container) {
Map environment = container.getEnvironment();
Map newEnvironment = new HashMap(environment);
newEnvironment.put(GEM_PATH, gemPath);
container.setEnvironment(newEnvironment);
}

private static void injectEnvironmentVariables(RubyInstanceConfig config, Map<String, Object> environmentVars) {
EnvironmentInjector environmentInjector = new EnvironmentInjector(config);
environmentInjector.inject(environmentVars);
Expand Down

0 comments on commit 89dde90

Please sign in to comment.