forked from sparklemotion/nokogiri
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
260363f
commit a325202
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <xml_document_fragment.h> | ||
|
||
/* | ||
* call-seq: | ||
* new(document) | ||
* | ||
* Create a new DocumentFragment element on the +document+ | ||
*/ | ||
static VALUE new(VALUE klass, VALUE doc) | ||
{ | ||
xmlDocPtr xml_doc; | ||
Data_Get_Struct(doc, xmlDoc, xml_doc); | ||
|
||
xmlNodePtr node = xmlNewDocFragment(xml_doc); | ||
|
||
VALUE rb_node = Nokogiri_wrap_xml_node(node); | ||
|
||
if(rb_block_given_p()) rb_yield(rb_node); | ||
|
||
return rb_node; | ||
} | ||
|
||
VALUE cNokogiriXmlDocumentFragment; | ||
void init_xml_document_fragment() | ||
{ | ||
VALUE nokogiri = rb_define_module("Nokogiri"); | ||
VALUE xml = rb_define_module_under(nokogiri, "XML"); | ||
VALUE node = rb_define_class_under(xml, "Node", rb_cObject); | ||
|
||
/* | ||
* DocumentFragment represents a DocumentFragment node in an xml document. | ||
*/ | ||
VALUE klass = rb_define_class_under(xml, "DocumentFragment", node); | ||
|
||
cNokogiriXmlDocumentFragment = klass; | ||
|
||
rb_define_singleton_method(klass, "new", new, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef NOKOGIRI_XML_DOCUMENT_FRAGMENT | ||
#define NOKOGIRI_XML_DOCUMENT_FRAGMENT | ||
|
||
#include <native.h> | ||
|
||
void init_xml_document_fragment(); | ||
|
||
extern VALUE cNokogiriXmlDocumentFragment; | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper")) | ||
|
||
module Nokogiri | ||
module XML | ||
class TestDocumentFragment < Nokogiri::TestCase | ||
def test_new | ||
@xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) | ||
fragment = Nokogiri::XML::DocumentFragment.new(@xml) | ||
end | ||
end | ||
end | ||
end |