xpather 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/ext/xpather/xpather.c +6 -10
  2. data/lib/xpather.rb +0 -3
  3. metadata +2 -2
@@ -5,8 +5,6 @@
5
5
  #include <libxml/xpath.h>
6
6
  #include <libxml/xpathInternals.h>
7
7
 
8
- VALUE klass;
9
-
10
8
  static void xml_free(void *doc) {
11
9
  xmlFreeDoc(doc);
12
10
  }
@@ -26,17 +24,15 @@ VALUE search(VALUE self, VALUE xpathExpr)
26
24
 
27
25
  xpathCtx = xmlXPathNewContext(doc);
28
26
  if (xpathCtx == NULL) {
29
- fprintf(stderr, "Error: unable to create new XPath context\n");
30
- xmlFreeDoc(doc);
31
- return -1;
27
+ rb_raise(rb_eArgError, "Error: unable to create new XPath context\n");
28
+ return Qnil;
32
29
  }
33
30
 
34
31
  xpathObj = xmlXPathEvalExpression(StringValueCStr(xpathExpr), xpathCtx);
35
32
  if (xpathObj == NULL) {
36
- fprintf(stderr, "Error: unable to evaluate xpath expression \"%s\"\n", StringValueCStr(xpathExpr));
33
+ rb_raise(rb_eArgError, "Error: unable to evaluate xpath expression \"%s\"\n", StringValueCStr(xpathExpr));
37
34
  xmlXPathFreeContext(xpathCtx);
38
- xmlFreeDoc(doc);
39
- return -1;
35
+ return Qnil;
40
36
  }
41
37
 
42
38
  nodes = xpathObj->nodesetval;
@@ -86,9 +82,9 @@ VALUE constructor(VALUE self, VALUE filename)
86
82
  return t_data;
87
83
  }
88
84
 
89
- void Init_xpather()
85
+ void Init_xpather(void)
90
86
  {
91
- klass = rb_define_class("XPather", rb_cObject);
87
+ VALUE klass = rb_define_class("XPather", rb_cObject);
92
88
  rb_define_singleton_method(klass, "new", constructor, 1);
93
89
  rb_define_method(klass, "initialize", initialize, 1);
94
90
  rb_define_method(klass, "filename", filename, 0);
data/lib/xpather.rb CHANGED
@@ -1,7 +1,4 @@
1
1
  require 'xpather/xpather'
2
2
 
3
3
  class XPather
4
- def to_s
5
- "#<XPather:#{filename}>"
6
- end
7
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xpather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-22 00:00:00.000000000 Z
12
+ date: 2012-03-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Quick and painless XPath searching for Ruby using libxml2
15
15
  email: