table_analysis 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/demo.rb +1 -1
- data/file/demo1.html +106 -80
- data/lib/table_analysis.rb +22 -7
- data/lib/table_analysis/header.rb +5 -5
- data/lib/table_analysis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3584faed5004ee91393970a6d932ec933312e176d92de3cfbda29dd3670e599c
|
4
|
+
data.tar.gz: db925f8adbe507bef505b0f8161d5e1c3d9dc120ad13b8ee739d4affa587fdec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb859f85fd1a6872d7c45b011c85ccf122671bb92b9d94465e5aa568267d4381e4f555b91ae1c4074f9f8330a05b7a7f3ec1658dba2e0650a845c4e4e50b32a
|
7
|
+
data.tar.gz: 968ae71920bbc66a23c3b01e8e315ea6d6246f3495f74a1935c438ad01fe31a6d935ba6c482fbcc3ff79ac1b726d95086000decb694816fc50575bb8a3b4d348
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
table_analysis (0.
|
4
|
+
table_analysis (0.2.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.3)
|
10
|
+
mini_portile2 (2.4.0)
|
11
|
+
nokogiri (1.10.3)
|
12
|
+
mini_portile2 (~> 2.4.0)
|
13
|
+
nokogirl (1.0)
|
14
|
+
nokogiri
|
10
15
|
rake (10.5.0)
|
11
16
|
rspec (3.8.0)
|
12
17
|
rspec-core (~> 3.8.0)
|
@@ -27,6 +32,7 @@ PLATFORMS
|
|
27
32
|
|
28
33
|
DEPENDENCIES
|
29
34
|
bundler (~> 2.0)
|
35
|
+
nokogirl (~> 1.0)
|
30
36
|
rake (~> 10.0)
|
31
37
|
rspec (~> 3.0)
|
32
38
|
table_analysis!
|
data/demo.rb
CHANGED
data/file/demo1.html
CHANGED
@@ -1,80 +1,106 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
<
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<
|
21
|
-
<
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
<
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
<
|
38
|
-
|
39
|
-
|
40
|
-
<
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
<
|
45
|
-
<
|
46
|
-
|
47
|
-
<
|
48
|
-
|
49
|
-
|
50
|
-
<
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<
|
55
|
-
<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<
|
60
|
-
<
|
61
|
-
<
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
<
|
66
|
-
<
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
<
|
72
|
-
<
|
73
|
-
<
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
1
|
+
<table style="table-layout: fixed; width: 648px" cellpadding="0" cellspacing="0">
|
2
|
+
<colgroup>
|
3
|
+
<col style="width: 101px">
|
4
|
+
<col style="width: 101px">
|
5
|
+
<col style="width: 101px">
|
6
|
+
<col style="width: 101px">
|
7
|
+
<col style="width: 127px">
|
8
|
+
<col style="width: 117px">
|
9
|
+
</colgroup>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<td style="width: 100px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
13
|
+
<td style="width: 100px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
14
|
+
<td style="width: 100px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
15
|
+
<td style="width: 100px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
16
|
+
<td style="width: 126px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
17
|
+
<td style="border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
18
|
+
</tr>
|
19
|
+
<tr style="min-height: 27px">
|
20
|
+
<td rowspan="2" style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
21
|
+
<p style="line-height: 13.3299999237061px; text-align: center">当期首残高(A)</p>
|
22
|
+
<p style="line-height: 13.3299999237061px; text-align: center">(千円)</p>
|
23
|
+
</td>
|
24
|
+
<td rowspan="2" style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
25
|
+
<p style="line-height: 13.3299999237061px; text-align: center">当期発生高(B)</p>
|
26
|
+
<p style="line-height: 13.3299999237061px; text-align: center">(千円)</p>
|
27
|
+
</td>
|
28
|
+
<td rowspan="2" style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
29
|
+
<p style="line-height: 13.3299999237061px; text-align: center">当期回収高(C)</p>
|
30
|
+
<p style="line-height: 13.3299999237061px; text-align: center">(千円)</p>
|
31
|
+
</td>
|
32
|
+
<td rowspan="2" style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px none #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
33
|
+
<p style="line-height: 13.3299999237061px; text-align: center">当期末残高</p>
|
34
|
+
<p style="line-height: 13.3299999237061px; text-align: center">(千円)</p>
|
35
|
+
</td>
|
36
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; vertical-align: middle">
|
37
|
+
<p style="line-height: 13.3299999237061px; text-align: center">回収率(%)</p>
|
38
|
+
</td>
|
39
|
+
<td rowspan="2" style="border-left: 1px none #000000; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
40
|
+
<p style="line-height: 13.3299999237061px; text-align: center">滞留日数(日)</p>
|
41
|
+
</td>
|
42
|
+
</tr>
|
43
|
+
<tr style="min-height: 40px">
|
44
|
+
<td style="border-left: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
45
|
+
<p style="margin-left: 6px; line-height: 1.33000004291534px; text-align: center"> </p>
|
46
|
+
<div style="text-align: center">
|
47
|
+
<table style="table-layout: fixed; margin-left: auto; margin-right: auto; width: 100px" cellpadding="0"
|
48
|
+
cellspacing="0">
|
49
|
+
<colgroup>
|
50
|
+
<col style="width: 60px">
|
51
|
+
<col style="width: 40px">
|
52
|
+
</colgroup>
|
53
|
+
<tbody>
|
54
|
+
<tr>
|
55
|
+
<td style="width: 59px; border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
56
|
+
<td style="border-left: 1px solid transparent; border-right: 1px solid transparent"></td>
|
57
|
+
</tr>
|
58
|
+
<tr style="min-height: 1.33333337306976px">
|
59
|
+
<td style="border-left: 0px none #000000; border-top: 0px none #000000; border-right: 0px none #000000; border-bottom: 1px solid #000000; vertical-align: top">
|
60
|
+
<p style="line-height: 13.3299999237061px; margin-bottom: 1.33000004291534px; text-align: center">
|
61
|
+
<span style="font-size: 12px">C</span>
|
62
|
+
</p>
|
63
|
+
</td>
|
64
|
+
<td rowspan="2" style="border-top: 0px none #000000; border-right: 0px none #000000; border-bottom: 0px none #000000; vertical-align: middle">
|
65
|
+
<p style="margin-left: 4px; line-height: 13.3299999237061px; text-align: center">
|
66
|
+
<span style="font-size: 12px">×100</span>
|
67
|
+
</p>
|
68
|
+
</td>
|
69
|
+
</tr>
|
70
|
+
<tr style="min-height: 1.33333337306976px">
|
71
|
+
<td style="border-left: 0px none #000000; border-top: 1px solid #000000; border-right: 0px none #000000; border-bottom: 0px none #000000; vertical-align: top">
|
72
|
+
<p style="line-height: 13.3299999237061px; margin-top: 1.33000004291534px; text-align: center">
|
73
|
+
<span style="font-size: 12px">A+B</span>
|
74
|
+
</p>
|
75
|
+
</td>
|
76
|
+
</tr>
|
77
|
+
</tbody>
|
78
|
+
</table>
|
79
|
+
</div>
|
80
|
+
<p style="margin-left: 6px; line-height: 1.33000004291534px; text-align: center"> </p>
|
81
|
+
</td>
|
82
|
+
</tr>
|
83
|
+
</thead>
|
84
|
+
<tbody>
|
85
|
+
<tr style="min-height: 27px">
|
86
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
87
|
+
<p style="margin-right: 12px; text-align: right">5,398,815</p>
|
88
|
+
</td>
|
89
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
90
|
+
<p style="margin-right: 12px; text-align: right">31,968,312</p>
|
91
|
+
</td>
|
92
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
93
|
+
<p style="margin-right: 12px; text-align: right">31,817,515</p>
|
94
|
+
</td>
|
95
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
96
|
+
<p style="margin-right: 12px; text-align: right">5,549,613</p>
|
97
|
+
</td>
|
98
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
99
|
+
<p style="margin-right: 18px; text-align: right">85.15</p>
|
100
|
+
</td>
|
101
|
+
<td style="border-left: 1px solid #000000; border-top: 1px solid #000000; border-right: 1px solid#000000; border-bottom: 1px solid #000000; vertical-align: middle">
|
102
|
+
<p style="margin-right: 18px; text-align: right">62.50</p>
|
103
|
+
</td>
|
104
|
+
</tr>
|
105
|
+
</tbody>
|
106
|
+
</table>
|
data/lib/table_analysis.rb
CHANGED
@@ -11,15 +11,25 @@ module TableAnalysis
|
|
11
11
|
return false if table.nil?
|
12
12
|
header_content_tds = []
|
13
13
|
body_content_tds = []
|
14
|
+
header_body_content_tds = []
|
14
15
|
body_tr_size = 0
|
15
|
-
|
16
|
+
tr_rows = 1
|
17
|
+
table.xpath('./thead/tr|./tbody/tr').each_with_index do |tr, tr_index|
|
16
18
|
if tr_index == selected_row.to_i - 1
|
17
19
|
tr.xpath('./td').each do |td|
|
18
|
-
header_name = td.content
|
19
20
|
colspan = td.attribute('colspan')&.value
|
20
|
-
|
21
|
+
rowspan = td.attribute('rowspan')&.value
|
22
|
+
header_content_tds << [rowspan, colspan]
|
23
|
+
header_body_content_tds << [rowspan, colspan]
|
24
|
+
tr_rows = rowspan.to_i.dup if !rowspan.nil? && rowspan.to_i > 1 && tr_rows < rowspan.to_i
|
21
25
|
end
|
22
|
-
elsif tr_index
|
26
|
+
elsif tr_index > selected_row.to_i - 1 && tr_index < selected_row.to_i - 1 + tr_rows
|
27
|
+
tr.xpath('./td').each do |td|
|
28
|
+
rowspan = td.attribute('rowspan')&.value
|
29
|
+
colspan = td.attribute('colspan')&.value
|
30
|
+
header_body_content_tds << [rowspan, colspan]
|
31
|
+
end
|
32
|
+
elsif tr_index >= selected_row.to_i - 1 + tr_rows
|
23
33
|
body_tr_size += 1
|
24
34
|
tr.xpath('./td').each_with_index do |td, td_index|
|
25
35
|
rowspan = td.attribute('rowspan')&.value
|
@@ -34,17 +44,22 @@ module TableAnalysis
|
|
34
44
|
end
|
35
45
|
|
36
46
|
header = TableAnalysis::Header.config(selected_cols, header_tds)
|
37
|
-
table = TableAnalysis::Table.config(body_tr_size, header)
|
38
47
|
|
48
|
+
table = TableAnalysis::Table.config(body_tr_size, header)
|
39
49
|
body_tds = body_content_tds.map do |body_td|
|
40
50
|
TableAnalysis::BodyTd.config(body_td[0], body_td[1])
|
41
51
|
end
|
42
52
|
|
43
53
|
content_maps = TableAnalysis::Core.new(header, table, body_tds).entrance
|
44
54
|
|
45
|
-
|
55
|
+
header_table = TableAnalysis::Table.config(tr_rows, header)
|
56
|
+
header_body_tds = header_body_content_tds.map do |body_td|
|
57
|
+
TableAnalysis::BodyTd.config(body_td[0], body_td[1])
|
58
|
+
end
|
59
|
+
|
60
|
+
header_maps = TableAnalysis::Core.new(header, header_table, header_body_tds).entrance
|
46
61
|
|
47
|
-
table_maps =
|
62
|
+
table_maps = header_maps + content_maps
|
48
63
|
|
49
64
|
table_maps
|
50
65
|
end
|
@@ -14,15 +14,15 @@ module TableAnalysis
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class HeaderTd
|
17
|
-
attr_accessor :
|
17
|
+
attr_accessor :rowspan, :length
|
18
18
|
|
19
|
-
def initialize(
|
20
|
-
@
|
19
|
+
def initialize(rowspan, length)
|
20
|
+
@rowspan = rowspan.nil? ? 1 : rowspan.to_i
|
21
21
|
@length = length.nil? ? 1 : length.to_i
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.config(
|
25
|
-
new(
|
24
|
+
def self.config(rowspan, length)
|
25
|
+
new(rowspan, length)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mico_xiaozhen@sina.com
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|