@Override public void unregisterAll() { getConverterFactory() .callMethod("unregister_all"); }
@JRubyMethod public IRubyObject opendir(ThreadContext context, Block block) { return context.runtime.getDir().callMethod(context, "open", new IRubyObject[] { path }, block); }
@JRubyMethod public IRubyObject make_symlink(ThreadContext context, IRubyObject old) { IRubyObject[] args = new IRubyObject[] { old, path }; return context.runtime.getFile().callMethod(context, "symlink", args); }
private static void handleContentModelAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(ContentModel.class)) { ContentModel contentModel = processor.getAnnotation(ContentModel.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("content_model"), rubyRuntime.newSymbol(contentModel.value().substring(1)) }); } }
private static void handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Name.class)) { Name name = processor.getAnnotation(Name.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("name"), rubyRuntime.newString(name.value()) }); } }
@JRubyMethod(alias = "fnmatch?", required = 1, optional = 1) public IRubyObject fnmatch(ThreadContext context, IRubyObject[] args) { args = insertPath(args, 1); return context.runtime.getFile().callMethod(context, "fnmatch?", args); }
@JRubyMethod public IRubyObject make_symlink(ThreadContext context, IRubyObject old) { IRubyObject[] args = new IRubyObject[] { old, getPath()}; return context.runtime.getFile().callMethod(context, "symlink", args); }
private static void handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Name.class)) { Name name = processor.getAnnotation(Name.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("name"), rubyRuntime.newString(name.value()) }); } }
@JRubyMethod public IRubyObject make_link(ThreadContext context, IRubyObject old) { IRubyObject[] args = new IRubyObject[] { old, getPath()}; return context.runtime.getFile().callMethod(context, "link", args); }
@JRubyMethod public IRubyObject opendir(ThreadContext context, Block block) { return context.runtime.getDir().callMethod(context, "open", new IRubyObject[] { getPath()}, block); }
@JRubyMethod public IRubyObject make_symlink(ThreadContext context, IRubyObject old) { IRubyObject[] args = new IRubyObject[] { old, getPath()}; return context.runtime.getFile().callMethod(context, "symlink", args); }
private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Location.class)) { Location location = processor.getAnnotation(Location.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("location"), rubyRuntime.newSymbol(location.value().optionValue().substring(1)) }); } }
private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Location.class)) { Location location = processor.getAnnotation(Location.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("location"), rubyRuntime.newSymbol(location.value().optionValue().substring(1)) }); } }
private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(DefaultAttribute.class)) { DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class); RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime); defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value()); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("default_attrs"), defaultAttrs }); } }
private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(DefaultAttribute.class)) { DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class); RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime); defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value()); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("default_attrs"), defaultAttrs }); } }
static ReaderImpl createReader(Ruby runtime, List<String> lines) { RubyArray rubyLines = runtime.newArray(lines.size()); for (String line : lines) { rubyLines.add(runtime.newString(line)); } RubyClass readerClass = runtime.getModule("Asciidoctor").getClass("Reader"); return new ReaderImpl(readerClass.callMethod("new", rubyLines)); }
@JRubyMethod public IRubyObject each_entry(ThreadContext context, Block block) { if (block.isGiven()) { // TODO: yield block while iterating RubyArray entries = callMethod(context, "entries").convertToArray(); entries.each(context, block); return context.nil; } else { return context.runtime.getDir().callMethod(context, "foreach"); } }
@JRubyMethod public IRubyObject each_entry(ThreadContext context, Block block) { if (block.isGiven()) { // TODO: yield block while iterating RubyArray entries = callMethod(context, "entries").convertToArray(); entries.each(context, block); return context.nil; } else { return context.runtime.getDir().callMethod(context, "foreach"); } }
@JRubyMethod public IRubyObject sub_ext(ThreadContext context, IRubyObject newExt) { IRubyObject ext = context.runtime.getFile().callMethod(context, "extname", getPath()); IRubyObject newPath = getPath().chomp(context, ext).callMethod(context, "+", newExt); return newInstance(context, newPath); }
@JRubyMethod(name = "empty?") public IRubyObject empty_p(ThreadContext context) { RubyModule fileTest = context.runtime.getFileTest(); if (fileTest.callMethod(context, "directory?", getPath()).isTrue()) { return context.runtime.getDir().callMethod(context, "empty?", getPath()); } else { return fileTest.callMethod(context, "empty?", getPath()); } }