libxml-ruby 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +5 -0
- data/ext/libxml/ruby_xml_error.c +19 -1
- data/ext/libxml/ruby_xml_reader.c +1 -1
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/test/tc_error.rb +13 -1
- metadata +3 -3
data/HISTORY
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= Release History
|
2
2
|
|
3
|
+
== 2.3.3 / 2012-07-01 Charlie Savage
|
4
|
+
|
5
|
+
* Add LibXML::XML::Error.get_handler (Carsten Zimmermann)
|
6
|
+
* Fix variable name in example (Marcus)
|
7
|
+
|
3
8
|
== 2.3.2 / 2012-03-20 Charlie Savage
|
4
9
|
|
5
10
|
* Define various canonicalize constants to support libxml2 versions
|
data/ext/libxml/ruby_xml_error.c
CHANGED
@@ -22,6 +22,10 @@ static ID ERROR_HANDLER_ID;
|
|
22
22
|
*
|
23
23
|
* XML::Error.set_handler(&XML::Error::QUIET_HANDLER)
|
24
24
|
*
|
25
|
+
* Get the current handler:
|
26
|
+
*
|
27
|
+
* proc = XML::Error.get_handler
|
28
|
+
*
|
25
29
|
* Install your own handler:
|
26
30
|
*
|
27
31
|
* XML::Error.set_handler do |error|
|
@@ -42,6 +46,19 @@ static void rxml_set_handler(VALUE self, VALUE block)
|
|
42
46
|
#endif
|
43
47
|
}
|
44
48
|
|
49
|
+
/*
|
50
|
+
* call-seq:
|
51
|
+
* Error.get_error_handler
|
52
|
+
*
|
53
|
+
* Returns the proc that will be called when libxml generates
|
54
|
+
* warning, error or fatal error messages.
|
55
|
+
*/
|
56
|
+
static VALUE rxml_error_get_handler()
|
57
|
+
{
|
58
|
+
VALUE block = rb_cvar_get(eXMLError, ERROR_HANDLER_ID);
|
59
|
+
return block;
|
60
|
+
}
|
61
|
+
|
45
62
|
/*
|
46
63
|
* call-seq:
|
47
64
|
* Error.set_error_handler {|error| ... }
|
@@ -129,7 +146,7 @@ static void structuredErrorFunc(void *userData, xmlErrorPtr xerror)
|
|
129
146
|
VALUE error = rxml_error_wrap(xerror);
|
130
147
|
|
131
148
|
/* Wrap error up as Ruby object and send it off to ruby */
|
132
|
-
VALUE block =
|
149
|
+
VALUE block = rxml_error_get_handler();
|
133
150
|
|
134
151
|
/* Now call global handler */
|
135
152
|
if (block != Qnil)
|
@@ -155,6 +172,7 @@ void rxml_init_error()
|
|
155
172
|
|
156
173
|
/* Error class */
|
157
174
|
eXMLError = rb_define_class_under(mXML, "Error", rb_eStandardError);
|
175
|
+
rb_define_singleton_method(eXMLError, "get_handler", rxml_error_get_handler, 0);
|
158
176
|
rb_define_singleton_method(eXMLError, "set_handler", rxml_error_set_handler, 0);
|
159
177
|
rb_define_singleton_method(eXMLError, "reset_handler", rxml_error_reset_handler, 0);
|
160
178
|
|
@@ -20,7 +20,7 @@
|
|
20
20
|
*
|
21
21
|
* Example:
|
22
22
|
*
|
23
|
-
*
|
23
|
+
* reader = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
|
24
24
|
* reader.read
|
25
25
|
* assert_equal('foo', reader.name)
|
26
26
|
* assert_equal(nil, reader.value)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/* Don't nuke this block! It is used for automatically updating the
|
2
2
|
* versions below. VERSION = string formatting, VERNUM = numbered
|
3
3
|
* version for inline testing: increment both or none at all.*/
|
4
|
-
#define RUBY_LIBXML_VERSION "2.3.
|
5
|
-
#define RUBY_LIBXML_VERNUM
|
4
|
+
#define RUBY_LIBXML_VERSION "2.3.3"
|
5
|
+
#define RUBY_LIBXML_VERNUM 233
|
6
6
|
#define RUBY_LIBXML_VER_MAJ 2
|
7
7
|
#define RUBY_LIBXML_VER_MIN 3
|
8
|
-
#define RUBY_LIBXML_VER_MIC
|
8
|
+
#define RUBY_LIBXML_VER_MIC 3
|
9
9
|
#define RUBY_LIBXML_VER_PATCH 0
|
data/test/tc_error.rb
CHANGED
@@ -59,6 +59,18 @@ class TestError < Test::Unit::TestCase
|
|
59
59
|
assert_nil(exception)
|
60
60
|
end
|
61
61
|
|
62
|
+
def test_get_handler
|
63
|
+
assert_respond_to(XML::Error, :get_handler)
|
64
|
+
assert_equal(0, XML::Error.method(:get_handler).arity)
|
65
|
+
|
66
|
+
saved_handler = XML::Error.get_handler
|
67
|
+
XML::Error.set_handler{ puts "New handler" }
|
68
|
+
assert_not_equal(XML::Error.get_handler, saved_handler)
|
69
|
+
|
70
|
+
XML::Error.set_handler(&saved_handler)
|
71
|
+
assert_equal(XML::Error.get_handler, saved_handler)
|
72
|
+
end
|
73
|
+
|
62
74
|
def test_verbose_handler
|
63
75
|
XML::Error.set_handler(&XML::Error::VERBOSE_HANDLER)
|
64
76
|
output = StringIO.new
|
@@ -147,4 +159,4 @@ class TestError < Test::Unit::TestCase
|
|
147
159
|
end
|
148
160
|
assert_equal('Must specify a string with one or more characters', error.to_s)
|
149
161
|
end
|
150
|
-
end
|
162
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libxml-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-01 00:00:00.000000000 Z
|
19
19
|
dependencies: []
|
20
20
|
description: ! " The Libxml-Ruby project provides Ruby language bindings for the
|
21
21
|
GNOME\n Libxml2 XML toolkit. It is free software, released under the MIT License.\n
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
requirements: []
|
249
249
|
rubyforge_project:
|
250
|
-
rubygems_version: 1.8.
|
250
|
+
rubygems_version: 1.8.24
|
251
251
|
signing_key:
|
252
252
|
specification_version: 3
|
253
253
|
summary: Ruby Bindings for LibXML2
|