xpath-simplify 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/xpath-simplify.rb +7 -7
- 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: 24ecd2b20f8439fcf73364980383bc8b7429decc
|
4
|
+
data.tar.gz: a2709701a769a106f7df3697d05fa278a8d608f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f63e0ebd852e2873c11a7adf524b25ed28f592f318a143e4374f86f545a06267cb9222cdc5812995fe87550f1cb13fb1741304132111b2cd85d9994e3cabda8
|
7
|
+
data.tar.gz: 696a1289a1759f579c6311c70087e9650abd286f35d847acb192dd9a9415625181d48021c3d41c7f32592f6a2381834ba4fbfabfad856e8b77f8a1f8c7d1c568
|
data/lib/xpath-simplify.rb
CHANGED
@@ -6,13 +6,13 @@ class XPathSimplify
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.assemble(arr)
|
9
|
-
return "//*[contains(text()
|
9
|
+
return "//*[contains(text(),\"#{arr.join(' ')}\")]" if check_only_text(arr)
|
10
10
|
arr.each_with_index do |a,i|
|
11
11
|
case a
|
12
12
|
when '((', '))', '->', '>>', '&&', '||', '::' then next
|
13
|
-
when /^#.+/ then arr[i] = "//*[@id
|
14
|
-
when /^\..+/ then arr[i] = "//*[contains(@class
|
15
|
-
when /\/[^\/].+/, /^http.*/, /^mailto.*/ then arr[i] = "//*[contains(@href
|
13
|
+
when /^#.+/ then arr[i] = "//*[@id=\"#{arr[i][1..-1]}\"]";
|
14
|
+
when /^\..+/ then arr[i] = "//*[contains(@class,\"#{arr[i][1..-1]}\")]";
|
15
|
+
when /\/[^\/].+/, /^http.*/, /^mailto.*/ then arr[i] = "//*[contains(@href,\"#{arr[i]}\")]";
|
16
16
|
else next
|
17
17
|
end
|
18
18
|
end
|
@@ -50,12 +50,12 @@ class XPathSimplify
|
|
50
50
|
when /^\/\/\*.+/ then next
|
51
51
|
when '::'
|
52
52
|
if f_text != -1
|
53
|
-
arr[f_text] = arr[f_text][0..-2].to_s + "
|
53
|
+
arr[f_text] = arr[f_text][0..-2].to_s + "\")]"
|
54
54
|
f_text = -1
|
55
55
|
arr[i] = nil
|
56
56
|
else
|
57
57
|
f_text = i
|
58
|
-
arr[i] = "//*[contains(text()
|
58
|
+
arr[i] = "//*[contains(text(),\""
|
59
59
|
end
|
60
60
|
else
|
61
61
|
if f_text != -1
|
@@ -66,7 +66,7 @@ class XPathSimplify
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
if f_text != -1 then arr[f_text] = arr[f_text][0..-2].to_s + "
|
69
|
+
if f_text != -1 then arr[f_text] = arr[f_text][0..-2].to_s + "\")]"; end;
|
70
70
|
return arr.compact
|
71
71
|
end
|
72
72
|
|