nokolexbor 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/nokolexbor/nl_attribute.c +15 -0
- data/ext/nokolexbor/nl_node.c +29 -1
- data/lib/nokolexbor/node_set.rb +4 -0
- data/lib/nokolexbor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25a206e02eaf74545bf1e7abe7e43a53e38fd8626b337e8de7d6c207e352a686
|
4
|
+
data.tar.gz: 2b9f7c8a339b2618dbb2de5824b249f0a8fa690713028a9e22b8627a8bb0163a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e579aa1e64ae9cfcf71dd2d0bf3b77b634b69764d43c04aaa02b6db0c5b26cb992d0094ad4b2b9177ca2be46c6b32df38381224bd579bfb722c538075b436e
|
7
|
+
data.tar.gz: c89997e12178393f171bb5e3735346d99ee67047fb985ec02b08e9433aadc6f18d68278a5256c99ab7174ddd436f9bb49fb97a97808923205803097b083f7ed3
|
@@ -178,6 +178,20 @@ nl_attribute_next(VALUE self)
|
|
178
178
|
return nl_rb_node_create(attr->next, nl_rb_document_get(self));
|
179
179
|
}
|
180
180
|
|
181
|
+
static VALUE
|
182
|
+
nl_attribute_inspect(VALUE self)
|
183
|
+
{
|
184
|
+
VALUE c = rb_class_name(CLASS_OF(self));
|
185
|
+
lxb_dom_node_t *node = nl_rb_node_unwrap(self);
|
186
|
+
lxb_dom_attr_t *attr = lxb_dom_interface_attr(node);
|
187
|
+
size_t len;
|
188
|
+
lxb_char_t *attr_value = lxb_dom_attr_value(attr, &len);
|
189
|
+
|
190
|
+
return rb_sprintf("#<%" PRIsVALUE " %s=\"%s\">", c,
|
191
|
+
lxb_dom_attr_qualified_name(attr, &len),
|
192
|
+
attr_value == NULL ? "" : attr_value);
|
193
|
+
}
|
194
|
+
|
181
195
|
void Init_nl_attribute(void)
|
182
196
|
{
|
183
197
|
cNokolexborAttribute = rb_define_class_under(mNokolexbor, "Attribute", cNokolexborNode);
|
@@ -191,6 +205,7 @@ void Init_nl_attribute(void)
|
|
191
205
|
rb_define_method(cNokolexborAttribute, "parent", nl_attribute_parent, 0);
|
192
206
|
rb_define_method(cNokolexborAttribute, "previous", nl_attribute_previous, 0);
|
193
207
|
rb_define_method(cNokolexborAttribute, "next", nl_attribute_next, 0);
|
208
|
+
rb_define_method(cNokolexborAttribute, "inspect", nl_attribute_inspect, 0);
|
194
209
|
|
195
210
|
rb_define_alias(cNokolexborAttribute, "node_name", "name");
|
196
211
|
rb_define_alias(cNokolexborAttribute, "node_name=", "name=");
|
data/ext/nokolexbor/nl_node.c
CHANGED
@@ -9,6 +9,7 @@ extern VALUE mNokolexbor;
|
|
9
9
|
extern VALUE cNokolexborDocument;
|
10
10
|
extern VALUE cNokolexborText;
|
11
11
|
extern VALUE cNokolexborComment;
|
12
|
+
extern VALUE cNokolexborCData;
|
12
13
|
extern VALUE cNokolexborProcessingInstruction;
|
13
14
|
extern VALUE cNokolexborNodeSet;
|
14
15
|
extern VALUE cNokolexborDocumentFragment;
|
@@ -39,7 +40,7 @@ nl_rb_node_create(lxb_dom_node_t *node, VALUE rb_document)
|
|
39
40
|
rb_class = cNokolexborText;
|
40
41
|
break;
|
41
42
|
case LXB_DOM_NODE_TYPE_CDATA_SECTION:
|
42
|
-
rb_class =
|
43
|
+
rb_class = cNokolexborCData;
|
43
44
|
break;
|
44
45
|
// case LXB_DOM_NODE_TYPE_ENTITY_REFERENCE:
|
45
46
|
// break;
|
@@ -1106,6 +1107,32 @@ nl_node_clone(VALUE self)
|
|
1106
1107
|
return nl_rb_node_create(clone, nl_rb_document_get(self));
|
1107
1108
|
}
|
1108
1109
|
|
1110
|
+
static VALUE
|
1111
|
+
nl_node_inspect(int argc, VALUE *argv, VALUE self)
|
1112
|
+
{
|
1113
|
+
lxb_dom_node_t *node = nl_rb_node_unwrap(self);
|
1114
|
+
if (node->type == LXB_DOM_NODE_TYPE_DOCUMENT) {
|
1115
|
+
return rb_call_super(argc, argv);
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
VALUE c = rb_class_name(CLASS_OF(self));
|
1119
|
+
lexbor_str_t str = {0};
|
1120
|
+
lxb_status_t status = lxb_html_serialize_str(node, &str);
|
1121
|
+
if (status != LXB_STATUS_OK) {
|
1122
|
+
if (str.data != NULL) {
|
1123
|
+
lexbor_str_destroy(&str, node->owner_document->text, false);
|
1124
|
+
}
|
1125
|
+
return rb_call_super(argc, argv);
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
if (str.data != NULL) {
|
1129
|
+
VALUE ret = rb_sprintf("#<%" PRIsVALUE " %s>", c, str.data);
|
1130
|
+
lexbor_str_destroy(&str, node->owner_document->text, false);
|
1131
|
+
return ret;
|
1132
|
+
}
|
1133
|
+
return rb_call_super(argc, argv);
|
1134
|
+
}
|
1135
|
+
|
1109
1136
|
void Init_nl_node(void)
|
1110
1137
|
{
|
1111
1138
|
cNokolexborNode = rb_define_class_under(mNokolexbor, "Node", rb_cObject);
|
@@ -1148,6 +1175,7 @@ void Init_nl_node(void)
|
|
1148
1175
|
rb_define_method(cNokolexborNode, "first_element_child", nl_node_first_element_child, 0);
|
1149
1176
|
rb_define_method(cNokolexborNode, "last_element_child", nl_node_last_element_child, 0);
|
1150
1177
|
rb_define_method(cNokolexborNode, "clone", nl_node_clone, 0);
|
1178
|
+
rb_define_method(cNokolexborNode, "inspect", nl_node_inspect, -1);
|
1151
1179
|
|
1152
1180
|
rb_define_alias(cNokolexborNode, "attr", "[]");
|
1153
1181
|
rb_define_alias(cNokolexborNode, "get_attribute", "[]");
|
data/lib/nokolexbor/node_set.rb
CHANGED
data/lib/nokolexbor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokolexbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yicheng Zhou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|