backtrack-xpath 0.2.0 → 0.2.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
  SHA256:
3
- metadata.gz: 64b44c4ffb4faa746a713bbd3a82835d0a09f3e5e1b7870e35a610cc0823965c
4
- data.tar.gz: 22e93bf796cc167532a437ce6fd799a31ba9e07dae09652f709be45e6c5f2414
3
+ metadata.gz: 68a37abfa337e4dc950626618d32b92cb3f9d9926382a42c9568a09038124b38
4
+ data.tar.gz: 627535a1133530d6f989a1c665d85d06dc55dc8afc9164c841b1a2770ea8649b
5
5
  SHA512:
6
- metadata.gz: 5cf31265c9c151d9863708f9cecc4750e4e08de53b0581b14b95cedab53fc5a222a04a5056f2a3452d0268f338fd939ed48daa43add20e4d147b614c089cafd7
7
- data.tar.gz: 46523b268e5d0e796878c1fac63b21cd6719753cfda6102e47ca93714acfb115a435ba68937f0912645d18ac59a992127784a96618311c9fc69e276f48d1e2e4
6
+ metadata.gz: 1b496a620931154556171eec1814f452862524ce56891ac91a39ad759f054385e1ce0bcb27e46c22bbc508b18cab59efce65c77e64c7d26e411696247d828736
7
+ data.tar.gz: ffd7781ded84b5f8b220f192a542c6ada759bbc74ec0c1663d0313b02c9e1bca1869f0ec249d500b1f21b3d2bb63472975ba614a8858117384eca07d9b5783e9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -6,9 +6,9 @@
6
6
 
7
7
  class BacktrackXPath
8
8
 
9
- def initialize(node, use_attributes: true)
9
+ def initialize(node, use_attributes: true, ignore_id: false)
10
10
 
11
- @use_attributes = use_attributes
11
+ @use_attributes, @ignore_id = use_attributes, ignore_id
12
12
  @xpath = doc_scan(node).flatten.compact.join('/')
13
13
 
14
14
  end
@@ -24,12 +24,20 @@ class BacktrackXPath
24
24
  def attribute_scan(node)
25
25
 
26
26
  result = ''
27
- attr = [:id, :class, 'id', 'class'].detect {|x| node.attributes.has_key? x}
27
+
28
+ list = @ignore_id ? [:class,'class'] : [:id, :class, 'id', 'class']
29
+ attr = list.detect {|x| node.attributes.has_key? x}
28
30
 
29
31
  if attr then
30
32
  node.attribute(attr)
31
- value = attr.to_sym == :id ? node.attributes[attr] : \
32
- node.attributes[attr][0]
33
+
34
+ value = if attr.to_sym == :id then
35
+ node.attributes[attr]
36
+ else
37
+ attrval = node.attributes[attr]
38
+ attrval[0] if attrval.is_a? Array
39
+ end
40
+
33
41
  result = "[@%s='%s']" % [attr, value]
34
42
  end
35
43
  result
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backtrack-xpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  5MjLlGBVVCgY+fcP9/LOMd6fIN4FqphZXBGDCU4yiYRkly9ypopXqKp18RHhmwYG
36
36
  18S2R4wYTVQb7BF+vRvuy3rQ
37
37
  -----END CERTIFICATE-----
38
- date: 2022-01-21 00:00:00.000000000 Z
38
+ date: 2022-01-22 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description:
41
41
  email: digital.robertson@gmail.com
metadata.gz.sig CHANGED
Binary file