Adapt to converter related changes in Asciidoctor upstream
MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/converter/internal/ConverterProxy.java
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/converter/internal/ConverterProxy.java
@@ -45,6 +45,7 @@ public class ConverterProxy<T> extends RubyObject {
rubyRuntime.getObject(),
new ConverterProxy.Allocator(converterClass));
includeModule(clazz, "Asciidoctor", "Converter");
+ includeModule(clazz, "Asciidoctor", "Converter", "BackendTraits");
clazz.defineAnnotatedMethod(ConverterProxy.class, "initialize");
clazz.defineAnnotatedMethod(ConverterProxy.class, "convert");
@@ -186,7 +187,7 @@ public class ConverterProxy<T> extends RubyObject {
RubyModule module = clazz.getRuntime().getModule(moduleName);
if (moduleNames != null && moduleNames.length > 0) {
for (String submoduleName: moduleNames) {
- module = module.defineOrGetModuleUnder(submoduleName);
+ module = module.getModule(submoduleName);
}
}
clazz.includeModule(module);

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JavaConverterRegistryImpl.java
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/JavaConverterRegistryImpl.java
@@ -8,6 +8,7 @@ import org.asciidoctor.jruby.converter.internal.ConverterProxy;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
+import org.jruby.RubyModule;
import java.util.HashMap;
import java.util.Map;
@@ -30,28 +31,26 @@ public class JavaConverterRegistryImpl implements JavaConverterRegistry {
// Backend annotation present => Register with name given in annotation
String backend = !ConverterFor.UNDEFINED.equals(converterForAnnotation.format()) ? converterForAnnotation.format() : converterForAnnotation.value();
getConverterFactory()
- .callMethod("register", clazz, rubyRuntime.newArray(rubyRuntime.newString(backend)));
+ .callMethod("register", clazz, rubyRuntime.newString(backend));
} else if (backends.length == 0) {
// No backend annotation and no backend defined => register as default backend
getConverterFactory()
- .callMethod("register", clazz);
+ .callMethod("register", clazz, rubyRuntime.newString("*"));
}
if (backends.length > 0) {
// Always additionally register with names passed to this method
- final RubyArray rubyBackendNames = new RubyArray(rubyRuntime, backends.length);
for (String backend: backends) {
- rubyBackendNames.add(rubyRuntime.newString(backend));
- }
getConverterFactory()
- .callMethod("register", clazz, rubyBackendNames);
+ .callMethod("register", clazz, rubyRuntime.newString(backend));
+ }
}
}
@Override
public Class<?> resolve(String backend) {
RubyClass rubyClass = (RubyClass) getConverterFactory()
- .callMethod("resolve", rubyRuntime.newString(backend));
+ .callMethod("for", rubyRuntime.newString(backend));
Class<?> clazz = rubyClass.getReifiedClass();
if (clazz != null) {
@@ -69,10 +68,9 @@ public class JavaConverterRegistryImpl implements JavaConverterRegistry {
.callMethod("unregister_all");
}
- private RubyClass getConverterFactory() {
+ private RubyModule getConverterFactory() {
return rubyRuntime.getModule("Asciidoctor")
- .defineOrGetModuleUnder("Converter")
- .getClass("Factory");
+ .getModule("Converter");
}
@Override

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/converter/WhenConverterIsRegistered.java
asciidoctorj-core/src/test/java/org/asciidoctor/converter/WhenConverterIsRegistered.java
@@ -71,7 +71,7 @@ public class WhenConverterIsRegistered {
// Register as default converter
asciidoctor.javaConverterRegistry().register(DummyConverter.class);
- String result = asciidoctor.convert("== Hello\n\nWorld!\n\n- a\n- b", OptionsBuilder.options());
+ String result = asciidoctor.convert("== Hello\n\nWorld!\n\n- a\n- b", OptionsBuilder.options().backend("Undefined"));
assertThat(result, is("Dummy"));
}

Adapt to converter related changes in Asciidoctor upstream