xpath-simplify 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/xpath-simplify.rb +9 -9
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0fb11230ba82b901331044ca4172b5c63c114ce
4
- data.tar.gz: e0260fc8b86300a758aca9fd1376046a24731166
3
+ metadata.gz: 67abe80d401fbbbc3fc3f006f201794eeee87f29
4
+ data.tar.gz: 146b97a10dbb352357c0d478a8ffdb5bea18cde4
5
5
  SHA512:
6
- metadata.gz: 34f12f680148f64912f3b1f8792bbf354ef9efed74b8671d7e1584a6bab28a4fdc4dcc28414398c967471a51351e5282662eedeaaf241ff73600f493994b21da
7
- data.tar.gz: c5cb969ad10db3134c7058ef41a6ca1c745f26d2cf51b2458763a038a792ad938d992938293c55466e916fae613d6d811934108baec711c73244844ab7433d85
6
+ metadata.gz: f430170d909ddd3b817d829f23a1e3b0cd453c0519430bb0b0d211a17955356e605b2d3c98f5fb5db402203d98b9a06785234b4fe64a108f97ea296172254d76
7
+ data.tar.gz: 78f288e1d13e3c79f2133bce7e1cd0f8d866f46c66e1614f9160cdfd30311824682a06bacf2bfa0a3461133b88925bfed54f76634a881bdf09053d4e6c363f18
@@ -6,20 +6,20 @@ class XPathSimplify
6
6
  end
7
7
 
8
8
  def self.assemble(arr)
9
- return "//*[contains(normalize-space(),\"#{arr.join(' ')}\")]" if check_only_text(arr)
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=\"#{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]}\")]";
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
19
19
  arr = combine_words(arr)
20
20
  arr.each_with_index do |a,i|
21
21
  case a
22
- when 'li', 'ul', 'a', 'span', 'button', 'input', 'label', 'textarea', 'tr', 'td', 'th', 'div', 'p' then arr[i] = "//#{arr[i]}";
22
+ when 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'ul', 'a', 'span', 'button', 'input', 'label', 'textarea', 'tr', 'td', 'div' then arr[i] = "//#{arr[i]}";
23
23
  else next
24
24
  end
25
25
  end
@@ -36,7 +36,7 @@ class XPathSimplify
36
36
  end
37
37
  case arr[0]
38
38
  when '((', '))', '->', '>>', '&&', '||', '::', /^#.+/, /^\..+/ then return false
39
- when 'li', 'ul', 'a', 'span', 'button', 'input', 'label', 'textarea', 'tr', 'td', 'th', 'div', 'p' then return false
39
+ when 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'ul', 'a', 'span', 'button', 'input', 'label', 'textarea', 'tr', 'td', 'div' then return false
40
40
  when /\/[^\/].+/, /^http.*/, /^mailto.*/ then return false
41
41
  else return true
42
42
  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(normalize-space(),\""
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 + "\")]"; end;
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
 
metadata CHANGED
@@ -1,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xpath-simplify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Mackie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-02 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem helps streamline the creation of X-Paths!
14
- email: scottmackie@live.ca
14
+ email: scott@mackie.io
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/xpath-simplify.rb
20
- homepage: http://rubygems.org/gems/simple-path
20
+ homepage: https://github.com/MacroMackie/xpath-simplify
21
21
  licenses:
22
22
  - MIT
23
23
  metadata: {}