xembly 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/xembly/directives.rb +12 -0
- data/lib/xembly/version.rb +1 -1
- data/lib/xembly/xpath.rb +8 -4
- data/test/test_xembler.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 857813ae8a91cc4121a2e43830fa1d06bbf3b238
|
4
|
+
data.tar.gz: 778bacb3ab0f926336e95dd130db8c86e51216c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1fb2161b21a585e7584ef8f0d2df96592137737879ece4f2693b1710b29e4dfbafc6aea74d38f5b7dff72018cae57d966f664d4b16c39e0210e68ac3f7fee8
|
7
|
+
data.tar.gz: 9ef59bcf3b8d56b38e367785574ef6bcbff7b06ab8926370cc4a1ada49f428e9c6dcbfe08653c7e60f15397efc480833b55635bcf1712d7b5926712407feb299
|
data/.rubocop.yml
CHANGED
data/lib/xembly/directives.rb
CHANGED
@@ -59,6 +59,16 @@ module Xembly
|
|
59
59
|
AddIf.new(args[0])
|
60
60
|
when 'ATTR'
|
61
61
|
Attr.new(args[0], args[1])
|
62
|
+
when 'CDATA'
|
63
|
+
fail 'CDATA command is not supported yet, please contribute'
|
64
|
+
when 'NS'
|
65
|
+
fail 'NS command is not supported yet, please contribute'
|
66
|
+
when 'PI'
|
67
|
+
fail 'PI command is not supported yet, please contribute'
|
68
|
+
when 'POP'
|
69
|
+
fail 'POP command is not supported yet, please contribute'
|
70
|
+
when 'PUSH'
|
71
|
+
fail 'PUSH command is not supported yet, please contribute'
|
62
72
|
when 'REMOVE'
|
63
73
|
Remove.new
|
64
74
|
when 'SET'
|
@@ -69,6 +79,8 @@ module Xembly
|
|
69
79
|
Up.new
|
70
80
|
when 'XPATH'
|
71
81
|
Xpath.new(args[0])
|
82
|
+
when 'XSET'
|
83
|
+
fail 'XSET command is not supported yet, please contribute'
|
72
84
|
else
|
73
85
|
fail "Unknown command \"#{cmd}\""
|
74
86
|
end
|
data/lib/xembly/version.rb
CHANGED
data/lib/xembly/xpath.rb
CHANGED
@@ -31,10 +31,14 @@ module Xembly
|
|
31
31
|
@path = path
|
32
32
|
end
|
33
33
|
|
34
|
-
def exec(
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def exec(dom, cursor)
|
35
|
+
if @path.start_with?('/')
|
36
|
+
after = dom.xpath(@path)
|
37
|
+
else
|
38
|
+
after = []
|
39
|
+
cursor.each do |node|
|
40
|
+
node.xpath(@path).each { |n| after.push(n) }
|
41
|
+
end
|
38
42
|
end
|
39
43
|
after
|
40
44
|
end
|
data/test/test_xembler.rb
CHANGED
@@ -34,13 +34,17 @@ class TestXembler < XeTest
|
|
34
34
|
def test_modifies_xml
|
35
35
|
xembler = Xembly::Xembler.new(
|
36
36
|
Xembly::Directives.new(
|
37
|
-
'XPATH "/books"; ADD "book"; ADD "test"; UP;
|
37
|
+
'XPATH "/books"; ADD "book"; ADD "test"; UP;' \
|
38
|
+
'ADD "title"; SET "hi;you";' \
|
39
|
+
'XPATH "none"; XPATH "/none-again";' \
|
40
|
+
'XPATH "/books"; ATTR "amp", "test";'
|
38
41
|
)
|
39
42
|
)
|
40
43
|
matches(
|
41
44
|
xembler.apply('<books/>').to_xml,
|
42
45
|
[
|
43
46
|
'/*',
|
47
|
+
'/books[@amp]',
|
44
48
|
'/books[count(book)=1]',
|
45
49
|
'/books/book[test and title]',
|
46
50
|
'/books/book/title[.="hi;you"]'
|