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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d13f44b89daed33ea1f5225bb756ee791e25776
4
- data.tar.gz: fa87b4c56484867037eb1d5fdf47f60cf2af938b
3
+ metadata.gz: 857813ae8a91cc4121a2e43830fa1d06bbf3b238
4
+ data.tar.gz: 778bacb3ab0f926336e95dd130db8c86e51216c8
5
5
  SHA512:
6
- metadata.gz: 6ff45d3322febcd673bb205f8689ad8136a04676e64734ff9736ff848f50f0b89980495d57241c0e224f721918b948bd57de1b87a48f5a534eea34c2735c0829
7
- data.tar.gz: b0c88f349598911c36247d229363c1adba7095417988b38e81d9f46bbf60e91823bd5188b4c926eb28b76e51171a7d4f252abf77434452975f04fd6d9855e1b6
6
+ metadata.gz: db1fb2161b21a585e7584ef8f0d2df96592137737879ece4f2693b1710b29e4dfbafc6aea74d38f5b7dff72018cae57d966f664d4b16c39e0210e68ac3f7fee8
7
+ data.tar.gz: 9ef59bcf3b8d56b38e367785574ef6bcbff7b06ab8926370cc4a1ada49f428e9c6dcbfe08653c7e60f15397efc480833b55635bcf1712d7b5926712407feb299
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  MethodLength:
2
- Max: 30
2
+ Max: 50
3
3
  Style/ClassLength:
4
4
  Max: 150
5
5
  Style/CyclomaticComplexity:
@@ -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
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2016 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Xembly
28
- VERSION = '0.4'
28
+ VERSION = '0.4.1'
29
29
  end
data/lib/xembly/xpath.rb CHANGED
@@ -31,10 +31,14 @@ module Xembly
31
31
  @path = path
32
32
  end
33
33
 
34
- def exec(_, cursor)
35
- after = []
36
- cursor.each do |node|
37
- node.xpath(@path).each { |n| after.push(n) }
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; ADD "title"; SET "hi;you";'
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"]'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xembly
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko