htot_conv 0.2.0 → 0.3.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/htot_conv/generator/xlsx_type4.rb +16 -16
- data/lib/htot_conv/parser/dir_tree.rb +18 -7
- data/lib/htot_conv/parser/html_list.rb +11 -1
- data/lib/htot_conv/parser/opml.rb +11 -1
- data/lib/htot_conv/parser/simple_text.rb +7 -2
- data/lib/htot_conv/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: 5d5f671f2c6eb3e7bc5c8ba10c10b7dfba0417a3
|
|
4
|
+
data.tar.gz: 051cd8132c24bb1e640171f747a25342f8b59d45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3b658635745828831f4fdb86a97e14eb3aaddca9a8fe606ad8ea3ce366f743de8e100350dc82e278fa3832d2464585dff1ffddc41c0ebb60984b3db8543ad6e9
|
|
7
|
+
data.tar.gz: 4521c421e386868aee477c20a6f7a33a78d225304be6e8f894560963f2862d9fde61f8c3cd915555f5c7964b7888b68f9c38dde662c91143e5771d2c2b8b6837
|
|
@@ -30,10 +30,9 @@ module HTOTConv
|
|
|
30
30
|
item = node.item
|
|
31
31
|
|
|
32
32
|
key_cell = Array.new(max_level, nil)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
break if ancestor.prev
|
|
33
|
+
[node].concat(node.ancestors.to_a).each do |c_node|
|
|
34
|
+
key_cell[c_node.item.level - 1] = c_node.item.key if c_node.item
|
|
35
|
+
break if c_node.prev
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
value_cell = HTOTConv::Util.pad_array(item.value, max_value_length)
|
|
@@ -41,14 +40,15 @@ module HTOTConv
|
|
|
41
40
|
ws.add_row(key_cell.concat(value_cell),
|
|
42
41
|
:style => Axlsx::STYLE_THIN_BORDER)
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
if (
|
|
43
|
+
node.ancestors.each_with_object([node]) do |c_node, descendants|
|
|
44
|
+
if (c_node.item && c_node.item.level)
|
|
46
45
|
edges = [:left, :right]
|
|
47
|
-
edges << :top unless
|
|
48
|
-
edges << :bottom unless
|
|
49
|
-
ws.rows.last.cells[
|
|
46
|
+
edges << :top unless (descendants.any? { |v| v.prev })
|
|
47
|
+
edges << :bottom unless (descendants.any? { |v| v.next })
|
|
48
|
+
ws.rows.last.cells[c_node.item.level - 1].style = ws.styles.add_style(
|
|
50
49
|
:border => { :style => :thin, :color => "00", :edges => edges })
|
|
51
50
|
end
|
|
51
|
+
descendants.unshift(c_node)
|
|
52
52
|
end
|
|
53
53
|
(item.level..max_level).each do |level|
|
|
54
54
|
edges = [:top, :bottom]
|
|
@@ -64,17 +64,17 @@ module HTOTConv
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
node.ancestors.
|
|
68
|
-
rowspan_cells[
|
|
69
|
-
unless
|
|
67
|
+
node.ancestors.each_with_object([node]) do |c_node, descendants|
|
|
68
|
+
rowspan_cells[c_node.item.level - 1] << ws.rows.last.cells[c_node.item.level - 1]
|
|
69
|
+
unless (descendants.any? { |v| v.next })
|
|
70
70
|
if [:rowspan, :both].include?(@option[:integrate_cells])
|
|
71
|
-
if rowspan_cells[
|
|
72
|
-
ws.merge_cells(rowspan_cells[
|
|
71
|
+
if rowspan_cells[c_node.item.level - 1].length > 1
|
|
72
|
+
ws.merge_cells(rowspan_cells[c_node.item.level - 1])
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
|
-
rowspan_cells[
|
|
75
|
+
rowspan_cells[c_node.item.level - 1].clear
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
descendants.unshift(c_node)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
end
|
|
@@ -6,17 +6,27 @@ module HTOTConv
|
|
|
6
6
|
class DirTree < Base
|
|
7
7
|
def self.option_help
|
|
8
8
|
{
|
|
9
|
+
:key_header => {
|
|
10
|
+
:default => [],
|
|
11
|
+
:pat => Array,
|
|
12
|
+
:desc => "key header",
|
|
13
|
+
},
|
|
9
14
|
:glob_pattern => {
|
|
10
15
|
:default => "**/*",
|
|
11
16
|
:pat => String,
|
|
12
17
|
:desc => "globbing pattern (default: \"**/*\")",
|
|
13
18
|
},
|
|
19
|
+
:dir_indicator => {
|
|
20
|
+
:default => "",
|
|
21
|
+
:pat => String,
|
|
22
|
+
:desc => "append directory indicator",
|
|
23
|
+
},
|
|
14
24
|
}
|
|
15
25
|
end
|
|
16
26
|
|
|
17
27
|
def parse(input=Dir.pwd)
|
|
18
28
|
outline = HTOTConv::Outline.new
|
|
19
|
-
outline.key_header = []
|
|
29
|
+
outline.key_header = @option[:key_header]
|
|
20
30
|
outline.value_header = []
|
|
21
31
|
|
|
22
32
|
outline_item = Set.new
|
|
@@ -28,14 +38,15 @@ module HTOTConv
|
|
|
28
38
|
file_path
|
|
29
39
|
end
|
|
30
40
|
end
|
|
31
|
-
end
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
outline_item.sort.each do |file_path|
|
|
43
|
+
key = File.basename(file_path)
|
|
44
|
+
key << "#{option[:dir_indicator]}" if FileTest.directory?(file_path)
|
|
45
|
+
level = file_path.split(File::SEPARATOR).length
|
|
46
|
+
outline.add_item(key, level, [])
|
|
47
|
+
end
|
|
37
48
|
end
|
|
38
|
-
|
|
49
|
+
|
|
39
50
|
outline
|
|
40
51
|
end
|
|
41
52
|
end
|
|
@@ -4,9 +4,19 @@ require 'htot_conv/parser/base'
|
|
|
4
4
|
module HTOTConv
|
|
5
5
|
module Parser
|
|
6
6
|
class HtmlList < Base
|
|
7
|
+
def self.option_help
|
|
8
|
+
{
|
|
9
|
+
:key_header => {
|
|
10
|
+
:default => [],
|
|
11
|
+
:pat => Array,
|
|
12
|
+
:desc => "key header",
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
7
17
|
def parse(input)
|
|
8
18
|
outline = HTOTConv::Outline.new
|
|
9
|
-
outline.key_header = []
|
|
19
|
+
outline.key_header = @option[:key_header]
|
|
10
20
|
outline.value_header = []
|
|
11
21
|
|
|
12
22
|
parser = Nokogiri::HTML::SAX::Parser.new(ListDoc.new(outline))
|
|
@@ -4,9 +4,19 @@ require 'htot_conv/parser/base'
|
|
|
4
4
|
module HTOTConv
|
|
5
5
|
module Parser
|
|
6
6
|
class Opml < Base
|
|
7
|
+
def self.option_help
|
|
8
|
+
{
|
|
9
|
+
:key_header => {
|
|
10
|
+
:default => [],
|
|
11
|
+
:pat => Array,
|
|
12
|
+
:desc => "key header",
|
|
13
|
+
},
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
7
17
|
def parse(input)
|
|
8
18
|
outline = HTOTConv::Outline.new
|
|
9
|
-
outline.key_header = []
|
|
19
|
+
outline.key_header = @option[:key_header]
|
|
10
20
|
outline.value_header = []
|
|
11
21
|
|
|
12
22
|
parser = Nokogiri::XML::SAX::Parser.new(ListDoc.new(outline))
|
|
@@ -17,10 +17,15 @@ module HTOTConv
|
|
|
17
17
|
:desc => "separator character of additional data",
|
|
18
18
|
},
|
|
19
19
|
:preserve_empty_line => {
|
|
20
|
-
:
|
|
20
|
+
:default => false,
|
|
21
21
|
:pat => FalseClass,
|
|
22
22
|
:desc => "preserve empty line as a level-1 item (default: no)",
|
|
23
23
|
},
|
|
24
|
+
:key_header => {
|
|
25
|
+
:default => [],
|
|
26
|
+
:pat => Array,
|
|
27
|
+
:desc => "key header",
|
|
28
|
+
},
|
|
24
29
|
:value_header => {
|
|
25
30
|
:default => [],
|
|
26
31
|
:pat => Array,
|
|
@@ -33,7 +38,7 @@ module HTOTConv
|
|
|
33
38
|
indent_regexp = Regexp.new("^(?<indents>(#{Regexp.escape(@option[:indent])})*)")
|
|
34
39
|
delimiter_regexp = (@option[:delimiter].kind_of?(String))? Regexp.new(Regexp.escape(@option[:delimiter])) : @option[:delimiter]
|
|
35
40
|
outline = HTOTConv::Outline.new
|
|
36
|
-
outline.key_header = []
|
|
41
|
+
outline.key_header = @option[:key_header]
|
|
37
42
|
outline.value_header = @option[:value_header]
|
|
38
43
|
|
|
39
44
|
input.each_line do |line|
|
data/lib/htot_conv/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: htot_conv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- "@cat_in_136"
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-10-
|
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: axlsx
|