use of org.jruby.RubyClass in project gocd by gocd.
the class NokogiriService method createXsltModule.
private void createXsltModule(Ruby ruby, RubyModule xsltModule) {
RubyClass stylesheet = xsltModule.defineClassUnder("Stylesheet", ruby.getObject(), XSLT_STYLESHEET_ALLOCATOR);
stylesheet.defineAnnotatedMethods(XsltStylesheet.class);
xsltModule.defineAnnotatedMethod(XsltStylesheet.class, "register");
}
use of org.jruby.RubyClass in project gocd by gocd.
the class NokogiriService method createHtmlModule.
private void createHtmlModule(Ruby ruby, RubyModule htmlModule) {
RubyClass htmlElemDesc = htmlModule.defineClassUnder("ElementDescription", ruby.getObject(), HTML_ELEMENT_DESCRIPTION_ALLOCATOR);
htmlElemDesc.defineAnnotatedMethods(HtmlElementDescription.class);
RubyClass htmlEntityLookup = htmlModule.defineClassUnder("EntityLookup", ruby.getObject(), HTML_ENTITY_LOOKUP_ALLOCATOR);
htmlEntityLookup.defineAnnotatedMethods(HtmlEntityLookup.class);
}
use of org.jruby.RubyClass in project gocd by gocd.
the class NokogiriService method createSaxModule.
private void createSaxModule(Ruby ruby, RubyModule xmlSaxModule, RubyModule htmlSaxModule) {
RubyClass xmlSaxParserContext = xmlSaxModule.defineClassUnder("ParserContext", ruby.getObject(), XML_SAXPARSER_CONTEXT_ALLOCATOR);
xmlSaxParserContext.defineAnnotatedMethods(XmlSaxParserContext.class);
RubyClass xmlSaxPushParser = xmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), XML_SAXPUSHPARSER_ALLOCATOR);
xmlSaxPushParser.defineAnnotatedMethods(XmlSaxPushParser.class);
RubyClass htmlSaxPushParser = htmlSaxModule.defineClassUnder("PushParser", ruby.getObject(), HTML_SAXPUSHPARSER_ALLOCATOR);
htmlSaxPushParser.defineAnnotatedMethods(HtmlSaxPushParser.class);
RubyClass htmlSaxParserContext = htmlSaxModule.defineClassUnder("ParserContext", xmlSaxParserContext, HTML_SAXPARSER_CONTEXT_ALLOCATOR);
htmlSaxParserContext.defineAnnotatedMethods(HtmlSaxParserContext.class);
}
use of org.jruby.RubyClass in project gocd by gocd.
the class HtmlSaxParserContext method parse_io.
@JRubyMethod(name = "io", meta = true)
public static IRubyObject parse_io(ThreadContext context, IRubyObject klazz, IRubyObject data, IRubyObject encoding) {
HtmlSaxParserContext ctx = (HtmlSaxParserContext) NokogiriService.HTML_SAXPARSER_CONTEXT_ALLOCATOR.allocate(context.getRuntime(), (RubyClass) klazz);
ctx.initialize(context.getRuntime());
ctx.setInputSource(context, data, context.getRuntime().getNil());
String javaEncoding = findEncoding(context, encoding);
if (javaEncoding != null) {
ctx.getInputSource().setEncoding(javaEncoding);
}
return ctx;
}
use of org.jruby.RubyClass in project gocd by gocd.
the class XmlDomParserContext method parse.
/**
* Must call setInputSource() before this method.
*/
public XmlDocument parse(ThreadContext context, IRubyObject klazz, IRubyObject url) {
XmlDocument xmlDoc;
try {
Document doc = do_parse();
xmlDoc = wrapDocument(context, (RubyClass) klazz, doc);
xmlDoc.setUrl(url);
addErrorsIfNecessary(context, xmlDoc);
return xmlDoc;
} catch (SAXException e) {
return getDocumentWithErrorsOrRaiseException(context, (RubyClass) klazz, e);
} catch (IOException e) {
return getDocumentWithErrorsOrRaiseException(context, (RubyClass) klazz, e);
}
}
Aggregations