Login  Register

Re: Is it worth refactoring asciidoctor-jruby integration into a shared library?

Posted by asotobu on Mar 14, 2013; 6:22pm
URL: https://discuss.asciidoctor.org/Is-it-worth-refactoring-asciidoctor-jruby-integration-into-a-shared-library-tp25p34.html

Ok,
 my first idea was using the same approach you are using in Maven plugin, that is copying all Asciidoctor stuff from project to another new and invoking as you do. So my main idea is about creating an Asciidoctor Java class which invokes:

  final ScriptEngineManager engineManager = new ScriptEngineManager();
        final ScriptEngine rubyEngine = engineManager.getEngineByName("jruby");
        final Bindings bindings = new SimpleBindings();

        bindings.put("srcDir", sourceDirectory.getAbsolutePath());
        bindings.put("outputDir", outputDirectory.getAbsolutePath());
        bindings.put("backend", backend);

        try {
            final InputStream script = getClass().getClassLoader().getResourceAsStream("execute_asciidoctor.rb");
            final InputStreamReader streamReader = new InputStreamReader(script);
            rubyEngine.eval(streamReader, bindings);
        } catch (ScriptException e) {
            getLog().error("Error running ruby script", e);
        }


Maybe you have another idea? Of course I am open to receive any other suggestion.

Thanks Jason for your attention.

Alex.