xpather 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -0
- data/Rakefile +1 -2
- data/ext/xpather/xpather.c +7 -3
- data/lib/xpather.rb +0 -2
- data/test/xpather_test.rb +11 -3
- metadata +3 -2
data/README.markdown
ADDED
data/Rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/extensiontask'
|
4
|
-
load 'lib/xpather.rb'
|
5
4
|
|
6
5
|
spec = Gem::Specification.new do |s|
|
7
6
|
s.name = "xpather"
|
8
|
-
s.version =
|
7
|
+
s.version = "0.0.2"
|
9
8
|
s.platform = Gem::Platform::RUBY
|
10
9
|
s.authors = ["Aaron Bedra"]
|
11
10
|
s.email = ["aaron@aaronbedra.com"]
|
data/ext/xpather/xpather.c
CHANGED
@@ -42,9 +42,13 @@ VALUE search(VALUE self, VALUE xpathExpr)
|
|
42
42
|
nodes = xpathObj->nodesetval;
|
43
43
|
size = (nodes) ? nodes->nodeNr : 0;
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
if (size == 1) {
|
46
|
+
results = rb_str_new2(xmlNodeGetContent(nodes->nodeTab[0]));
|
47
|
+
} else {
|
48
|
+
for (i = 0; i < size; ++i) {
|
49
|
+
cur = nodes->nodeTab[i];
|
50
|
+
rb_ary_push(results, rb_str_new2(xmlNodeGetContent(cur)));
|
51
|
+
}
|
48
52
|
}
|
49
53
|
|
50
54
|
xmlXPathFreeObject(xpathObj);
|
data/lib/xpather.rb
CHANGED
data/test/xpather_test.rb
CHANGED
@@ -2,8 +2,16 @@ require 'minitest/autorun'
|
|
2
2
|
require 'xpather/xpather'
|
3
3
|
|
4
4
|
class TestXPather < MiniTest::Unit::TestCase
|
5
|
-
def
|
6
|
-
document = XPather.new("test/books.xml")
|
7
|
-
assert_equal ["Giada De Laurentiis"], document.search("/bookstore/book[1]/author")
|
5
|
+
def setup
|
6
|
+
@document = XPather.new("test/books.xml")
|
8
7
|
end
|
8
|
+
|
9
|
+
def test_basic_search_one
|
10
|
+
assert_equal "Giada De Laurentiis", @document.search("/bookstore/book[1]/author")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_basic_search_collection
|
14
|
+
assert_equal ["James McGovern", "Per Bothner", "Kurt Cagle", "James Linn", "Vaidyanathan Nagarajan"],
|
15
|
+
@document.search("/bookstore/book[3]/author")
|
16
|
+
end
|
9
17
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: xpather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Aaron Bedra
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-06 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -36,6 +36,7 @@ extra_rdoc_files: []
|
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
38
|
- Gemfile
|
39
|
+
- README.markdown
|
39
40
|
- Rakefile
|
40
41
|
- ext/xpather/extconf.rb
|
41
42
|
- ext/xpather/xpather.c
|