chop 0.22.1 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chop/unordered_list.rb +24 -0
- data/lib/chop/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925b1cafceddaff0b665cc7478d808ef08a04cfc
|
4
|
+
data.tar.gz: 7f9198af9e9d99946c8735ae2761a333d32aa219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b745708d9f7de22ac6ef9475b9d5d4b0732c1ebf80712e8b8052418a3b1a82b47419d026afc1219629280207f48852639fa709ab5c0340a97d9bfd0969a9b5b
|
7
|
+
data.tar.gz: 4a093d72ae1d391cff2bb48688c3b5513602a1c2e72a5886845e1fa57a4c6e4b4614fc46b229fb6dd6ed6e9eba90c757c7bf5211a07d194b09827fb88ba632a9
|
data/lib/chop/unordered_list.rb
CHANGED
@@ -5,6 +5,30 @@ module Chop
|
|
5
5
|
self.default_selector = "ul"
|
6
6
|
self.rows_finder = ->(root) { root.all("li") }
|
7
7
|
self.cells_finder = ->(row) { [row] }
|
8
|
+
|
9
|
+
def nested
|
10
|
+
self.rows_finder = ->(root) {
|
11
|
+
recurse_tree [], root
|
12
|
+
}
|
13
|
+
self.text_finder = ->(cell) {
|
14
|
+
cell.chop_prefix + cell.all(:xpath, "*[not(self::ul)]").map(&:text).join(" ").strip
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def recurse_tree structure, root, prefix: "- "
|
21
|
+
root.all(:xpath, "./li").each do |li|
|
22
|
+
li.define_singleton_method(:chop_prefix) { prefix }
|
23
|
+
structure << li
|
24
|
+
|
25
|
+
if li.has_xpath?("./ul")
|
26
|
+
root = li.find(:xpath, "./ul")
|
27
|
+
structure = recurse_tree(structure, root, prefix: prefix + " ")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
structure
|
31
|
+
end
|
8
32
|
end
|
9
33
|
|
10
34
|
Ul = UnorderedList
|
data/lib/chop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|