backtrack-xpath 0.1.7 → 0.2.2

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
- SHA1:
3
- metadata.gz: 54c15de823bf909834521b9197f4bea862593e6a
4
- data.tar.gz: 26cf5c798886c964423b4bb9a30af6e7e37f367d
2
+ SHA256:
3
+ metadata.gz: 4b228b2f1143eeaa3a03d27a4f3859f9e02d397613b1d7e67dae95652750f973
4
+ data.tar.gz: a773a87839802fc7d8d6ee294f0b84d1469346eb639a883f85a65f66557f1160
5
5
  SHA512:
6
- metadata.gz: aaae0e7c4d29d83b7ef9b0edf17653b6d8cefd775dfdddc02205ece6ef09db0aaa356fb2db2c9d85facc7dcf302503d36feee10a9b88a3110dd54c1d944d8d23
7
- data.tar.gz: d248afed848e0a8a61ab3631f956d8779cd814559b9db346f863333dabb2e6cf12b57b682f52fd12cee1cb457a690ae2376a12cce1e726adea9b79c4c9403304
6
+ metadata.gz: '081fc519ec340b3ccd0f5484a0549c753bf0c79f21b5ff871c5a1c6923158db1eb6b232a18f95f763f4205de5895311bd35bda989dc394888826fb5ec3399e1f'
7
+ data.tar.gz: 0b4eb65aa929dcc9a6f74777c4d951d37f9862d3f995eff1a8853a24a2c40bcf4081d6887ba695e2b5e49b32da299421be03bfb277c0372237bb4f4477f11fa9
checksums.yaml.gz.sig CHANGED
Binary file
@@ -6,8 +6,11 @@
6
6
 
7
7
  class BacktrackXPath
8
8
 
9
- def initialize(node)
9
+ def initialize(node, use_attributes: true, ignore_id: false)
10
+
11
+ @use_attributes, @ignore_id = use_attributes, ignore_id
10
12
  @xpath = doc_scan(node).flatten.compact.join('/')
13
+
11
14
  end
12
15
 
13
16
  def to_s
@@ -21,23 +24,32 @@ class BacktrackXPath
21
24
  def attribute_scan(node)
22
25
 
23
26
  result = ''
24
- attr = %i(id class).detect {|x| node.attributes.has_key? x}
25
-
27
+
28
+ list = @ignore_id ? [:class,'class'] : [:id, :class, 'id', 'class']
29
+ attr = list.detect {|x| node.attributes.has_key? x}
30
+
26
31
  if attr then
27
32
  node.attribute(attr)
28
- value = attr == :id ? node.attributes[attr] : \
29
- 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[-1] if attrval.is_a? Array
39
+ end
40
+
30
41
  result = "[@%s='%s']" % [attr, value]
31
42
  end
32
43
  result
33
44
  end
34
45
 
35
46
  def doc_scan(node)
36
-
47
+
37
48
  return unless node.parent
38
49
 
39
50
  name = node.name
40
- attribute = node.attributes ? attribute_scan(node) : ''
51
+
52
+ attribute = (@use_attributes and node.attributes) ? attribute_scan(node) : ''
41
53
  result = doc_scan(node.parent)
42
54
 
43
55
  [result, name + attribute]
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.1.7
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,31 +10,35 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE1MDQzMDIxNDAxMVoXDTE2MDQyOTIxNDAxMVowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAM8PN7VICemdhhCQzJA2jivDLpDvG9ZRglO7WfGlZuhVYvw5t+ZuauDgNduV
19
- oE2TU/HItCU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+Tl4h
31
+ Owb13ebVFuehxCVBh415nzSYnYDRhVMdiWYmbbIKQf9GCCGYFk5u83C795plJiJg
32
+ qnYEYiqdGRPYA/C6Pu7VNVgFpzDgfh0yA5Fgs8qEcv1sYfqDuLAPHoM/SHCach/j
33
+ VQ6cnUM8389cUCrEK3yk6DuAzivi5bNQTZOi+b1GrQSavVDyupRDdxe1s+yc7EmF
34
+ k47aFQDjEdgil327V8d7CHpZyGun3JJbYWOuSu4Q9v0DzARh8ObNrPmpALNuj3mC
35
+ 5MjLlGBVVCgY+fcP9/LOMd6fIN4FqphZXBGDCU4yiYRkly9ypopXqKp18RHhmwYG
36
+ 18S2R4wYTVQb7BF+vRvuy3rQ
33
37
  -----END CERTIFICATE-----
34
- date: 2015-10-11 00:00:00.000000000 Z
38
+ date: 2022-01-23 00:00:00.000000000 Z
35
39
  dependencies: []
36
40
  description:
37
- email: james@r0bertson.co.uk
41
+ email: digital.robertson@gmail.com
38
42
  executables: []
39
43
  extensions: []
40
44
  extra_rdoc_files: []
@@ -60,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
64
  version: '0'
61
65
  requirements: []
62
66
  rubyforge_project:
63
- rubygems_version: 2.4.8
67
+ rubygems_version: 2.7.10
64
68
  signing_key:
65
69
  specification_version: 4
66
70
  summary: backtrack-xpath accepts a REXML::Element and returns the full XPath back
metadata.gz.sig CHANGED
Binary file