tablestructured 0.3.0 → 0.4.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/tablestructured.rb +5 -5
- data/tablestructured.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12d89b2a0cfe64d0e225df5f48039f6eb3a57a7f9ff6fd930e996d0ff1165b50
|
4
|
+
data.tar.gz: ee0b66891ddfe222331030ef454485af24485098b7ad00e3babbcebe42348925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 632a6b7642ffa08a59a7b8930ff414dcb5c5760307d432eb8581a779f9889b2b52f869e5292e54119dbd829b329835f464413842b91ad750224fe938b63049ab
|
7
|
+
data.tar.gz: b9ab937ba3227e6972b45c978d62e62eb6d2ff9696beeb5d9967f675a49bfbaff15cc4de8395d4a66a1439c0615a009918bc27f2a43d3cfa8a283b12e2f87b27
|
data/lib/tablestructured.rb
CHANGED
@@ -11,7 +11,7 @@ module TableStructured
|
|
11
11
|
headers
|
12
12
|
else
|
13
13
|
fail "invalid type of headers"
|
14
|
-
end.css("th")[drop_first..-1-drop_last].map do |_|
|
14
|
+
end.css("thead th")[drop_first..-1-drop_last].map do |_|
|
15
15
|
_.text.sub(/\A[[[:space:]]]*/,"").sub(/[[[:space:]]]*\z/,"")
|
16
16
|
end
|
17
17
|
t = names.group_by(&:itself).map{ |k, g| [k, g.size.times.to_a] if 1 < g.size }.compact.to_h
|
@@ -22,17 +22,17 @@ module TableStructured
|
|
22
22
|
raise $!.exception "#{$!}: #{names.inspect}"
|
23
23
|
end
|
24
24
|
require "timeout"
|
25
|
-
object.css("tbody>tr").map do |
|
25
|
+
object.css("tbody > tr").map do |row|
|
26
26
|
tds = []
|
27
|
-
Timeout.timeout
|
28
|
-
tds =
|
27
|
+
Timeout.timeout 5 do
|
28
|
+
tds = [row.css("th"), *row.css("td")][drop_first..-1-drop_last]
|
29
29
|
if tds.empty?
|
30
30
|
STDERR.puts "empty row"
|
31
31
|
sleep 0.1
|
32
32
|
redo
|
33
33
|
end
|
34
34
|
end
|
35
|
-
raise Error, "size mismatch (#{names.size} headers, #{tds.size} row items)" if tds.size != names.size
|
35
|
+
raise Error, "size mismatch (#{names.size} headers (#{names}), #{tds.size} row items)" if tds.size != names.size
|
36
36
|
struct.new *tds
|
37
37
|
end
|
38
38
|
else
|
data/tablestructured.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "tablestructured"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.4.0"
|
4
4
|
spec.summary = "convert two-dimensional Array into an Array of Structs consuming the first row and/or column as attributes"
|
5
5
|
|
6
6
|
spec.author = "Victor Maslov aka Nakilon"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tablestructured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov aka Nakilon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: nakilon@gmail.com
|
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
|
-
rubygems_version: 3.3
|
42
|
+
rubygems_version: 3.2.3
|
43
43
|
signing_key:
|
44
44
|
specification_version: 4
|
45
45
|
summary: convert two-dimensional Array into an Array of Structs consuming the first
|