Module: Makiri
- Defined in:
- lib/makiri.rb,
lib/makiri/css.rb,
lib/makiri/xml.rb,
lib/makiri/attr.rb,
lib/makiri/html.rb,
lib/makiri/node.rb,
lib/makiri/text.rb,
lib/makiri/xpath.rb,
lib/makiri/comment.rb,
lib/makiri/element.rb,
lib/makiri/version.rb,
lib/makiri/document.rb,
lib/makiri/node_set.rb,
lib/makiri/xml/builder.rb,
lib/makiri/xml/document.rb,
lib/makiri/cdata_section.rb,
lib/makiri/document_type.rb,
lib/makiri/html/document.rb,
lib/makiri/xpath_context.rb,
lib/makiri/compat_aliases.rb,
lib/makiri/xml/node_methods.rb,
lib/makiri/document_fragment.rb,
lib/makiri/html/node_methods.rb,
lib/makiri/processing_instruction.rb,
ext/makiri/makiri.c
Defined Under Namespace
Modules: CSS, HTML, Lexbor, XML, XPath Classes: Attr, CDATASection, Comment, Document, DocumentFragment, DocumentType, Element, Error, Node, NodeSet, ProcessingInstruction, Text, XPathContext
Constant Summary collapse
- VERSION =
"0.5.0"- CDATA =
Nokogiri-compatible class-name aliases.
Makiri’s canonical node-class names are the WHATWG DOM interface names (Element, Attr, Text, Comment, CDATASection, ProcessingInstruction, DocumentType, Document, DocumentFragment). Two of those differ from the libxml2/Nokogiri spelling; we expose the Nokogiri names as aliases so a snippet ported from Nokogiri (or an is_a?/case check) resolves unchanged:
CDATASection <- CDATA (Nokogiri::XML::CDATA) DocumentType <- DTD (Nokogiri::XML::DTD)An alias is the same class object, so #is_a? works under either name; only #class.name (and inspect) report the canonical DOM name. Defined at all three
- levels (the abstract base and the HTML::/XML
-
leaves).
CDATASection- DTD =
DocumentType
Class Method Summary collapse
- .__alloc_inject(nth) ⇒ Object
-
.__alloc_inject? ⇒ Boolean
Makiri.__alloc_inject(n) / __alloc_inject_calls / __alloc_inject? - the OOM sweep harness’s controls (script/check_alloc_failures.rb, ‘rake oom`): arm “the nth core allocation fails once”, and read how many core allocations a workload attempted.
- .__alloc_inject_calls ⇒ Object
-
.__c_selftest ⇒ Object
Makiri.__c_selftest -> true, or raises if the safe-core primitives (mkr_core.c) fail their internal edge-case checks.
-
.HTML(source) ⇒ Makiri::HTML::Document
Convenience constructor mirroring Nokogiri.
-
.parse(source) ⇒ Object
Alias for Makiri.HTML.
-
.XML(source, **opts) ⇒ Makiri::XML::Document
Convenience XML constructor mirroring Nokogiri::XML(source).
Class Method Details
.__alloc_inject(nth) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/makiri/makiri.c', line 101
static VALUE
mkr_s_alloc_inject(VALUE self, VALUE nth)
{
(void)self;
#ifdef MKR_ALLOC_INJECT
mkr_alloc_inject_arm((long long)NUM2LL(nth));
return Qnil;
#else
(void)nth;
rb_raise(rb_eNotImpError, "rebuild with MAKIRI_ALLOC_INJECT=1 (rake oom does this)");
#endif
}
|
.__alloc_inject? ⇒ Boolean
Makiri.__alloc_inject(n) / __alloc_inject_calls / __alloc_inject? - the OOM sweep harness’s controls (script/check_alloc_failures.rb, ‘rake oom`): arm “the nth core allocation fails once”, and read how many core allocations a workload attempted. Compiled to a real hook only under MKR_ALLOC_INJECT (extconf: MAKIRI_ALLOC_INJECT=1); in a normal build __alloc_inject? is false and the others raise, so the harness fails loudly on the wrong build instead of sweeping nothing. Test hooks only.
90 91 92 93 94 95 96 97 98 99 |
# File 'ext/makiri/makiri.c', line 90
static VALUE
mkr_s_alloc_inject_p(VALUE self)
{
(void)self;
#ifdef MKR_ALLOC_INJECT
return Qtrue;
#else
return Qfalse;
#endif
}
|
.__alloc_inject_calls ⇒ Object
114 115 116 117 118 119 120 121 122 123 |
# File 'ext/makiri/makiri.c', line 114
static VALUE
mkr_s_alloc_inject_calls(VALUE self)
{
(void)self;
#ifdef MKR_ALLOC_INJECT
return ULL2NUM(mkr_alloc_inject_calls());
#else
rb_raise(rb_eNotImpError, "rebuild with MAKIRI_ALLOC_INJECT=1 (rake oom does this)");
#endif
}
|
.__c_selftest ⇒ Object
Makiri.__c_selftest -> true, or raises if the safe-core primitives (mkr_core.c) fail their internal edge-case checks. Test hook only.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'ext/makiri/makiri.c', line 56
static VALUE
mkr_c_selftest(VALUE self)
{
(void)self;
int rc = mkr_core_selftest();
if (rc != 0) {
rb_raise(mkr_eError, "mkr_core_selftest failed at check %d", rc);
}
int xc = mkr_xml_node_selftest();
if (xc != 0) {
rb_raise(mkr_eError, "mkr_xml_node_selftest failed at check %d", xc);
}
int pc = mkr_xml_parse_selftest();
if (pc != 0) {
rb_raise(mkr_eError, "mkr_xml_parse_selftest failed at check %d", pc);
}
int qc = mkr_xml_xpath_selftest();
if (qc != 0) {
rb_raise(mkr_eError, "mkr_xml_xpath_selftest failed at check %d", qc);
}
int mc = mkr_xml_mutate_selftest();
if (mc != 0) {
rb_raise(mkr_eError, "mkr_xml_mutate_selftest failed at check %d", mc);
}
return Qtrue;
}
|
.HTML(source) ⇒ Makiri::HTML::Document
Convenience constructor mirroring Nokogiri.
47 48 49 |
# File 'lib/makiri.rb', line 47 def self.HTML(source) # rubocop:disable Naming/MethodName HTML::Document.parse(source) end |
.parse(source) ⇒ Object
Alias for HTML.
52 53 54 |
# File 'lib/makiri.rb', line 52 def self.parse(source) HTML::Document.parse(source) end |
.XML(source, **opts) ⇒ Makiri::XML::Document
Convenience XML constructor mirroring Nokogiri::XML(source). A method named XML on the Makiri module, coexisting with the Makiri::XML constant (the module), as Nokogiri::XML does. Delegates to Makiri::XML::Document.parse, exactly as HTML delegates to Makiri::HTML::Document.parse.
63 64 65 |
# File 'lib/makiri.rb', line 63 def self.XML(source, **opts) # rubocop:disable Naming/MethodName XML::Document.parse(source, **opts) end |