htot_conv 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +135 -135
- data/.travis.yml +12 -12
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +138 -138
- data/Rakefile +10 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/exe/htot_conv +8 -8
- data/htot_conv.gemspec +37 -37
- data/lib/htot_conv/cli.rb +174 -160
- data/lib/htot_conv/generator/base.rb +35 -35
- data/lib/htot_conv/generator/xlsx_type0.rb +24 -24
- data/lib/htot_conv/generator/xlsx_type1.rb +69 -69
- data/lib/htot_conv/generator/xlsx_type2.rb +104 -104
- data/lib/htot_conv/generator/xlsx_type3.rb +85 -85
- data/lib/htot_conv/generator/xlsx_type4.rb +84 -84
- data/lib/htot_conv/generator/xlsx_type5.rb +62 -62
- data/lib/htot_conv/generator.rb +30 -30
- data/lib/htot_conv/outline.rb +176 -176
- data/lib/htot_conv/parser/base.rb +15 -15
- data/lib/htot_conv/parser/dir_tree.rb +54 -54
- data/lib/htot_conv/parser/html_list.rb +71 -71
- data/lib/htot_conv/parser/opml.rb +70 -70
- data/lib/htot_conv/parser/simple_text.rb +70 -70
- data/lib/htot_conv/parser.rb +27 -27
- data/lib/htot_conv/util.rb +13 -13
- data/lib/htot_conv/version.rb +4 -4
- data/lib/htot_conv.rb +20 -20
- metadata +3 -3
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "htot_conv"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "htot_conv"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/exe/htot_conv
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
#
|
4
|
-
require 'rubygems'
|
5
|
-
require 'htot_conv'
|
6
|
-
require 'htot_conv/cli'
|
7
|
-
|
8
|
-
HTOTConv::CLI.main(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
require 'rubygems'
|
5
|
+
require 'htot_conv'
|
6
|
+
require 'htot_conv/cli'
|
7
|
+
|
8
|
+
HTOTConv::CLI.main(ARGV)
|
data/htot_conv.gemspec
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'htot_conv/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "htot_conv"
|
8
|
-
spec.version = HTOTConv::VERSION
|
9
|
-
spec.authors = ["@cat_in_136"]
|
10
|
-
spec.email = ["cat.in.136+github@gmail.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Hierarchical-Tree Outline Text Converter}
|
13
|
-
spec.description = %q{Convert from a simple hierarchical-tree outline text into ugly xlsx file}
|
14
|
-
spec.homepage = "https://github.com/cat-in-136/htot_conv"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
if spec.respond_to?(:metadata)
|
20
|
-
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
else
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
end
|
24
|
-
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
spec.bindir = "exe"
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.add_dependency "axlsx", "~> 2.0.1"
|
31
|
-
spec.add_dependency "rinne", "~> 0.0.3"
|
32
|
-
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
34
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
-
spec.add_development_dependency "fakefs", "~> 0.11.3"
|
37
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'htot_conv/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "htot_conv"
|
8
|
+
spec.version = HTOTConv::VERSION
|
9
|
+
spec.authors = ["@cat_in_136"]
|
10
|
+
spec.email = ["cat.in.136+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Hierarchical-Tree Outline Text Converter}
|
13
|
+
spec.description = %q{Convert from a simple hierarchical-tree outline text into ugly xlsx file}
|
14
|
+
spec.homepage = "https://github.com/cat-in-136/htot_conv"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "axlsx", "~> 2.0.1"
|
31
|
+
spec.add_dependency "rinne", "~> 0.0.3"
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
spec.add_development_dependency "fakefs", "~> 0.11.3"
|
37
|
+
end
|
data/lib/htot_conv/cli.rb
CHANGED
@@ -1,160 +1,174 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'optparse'
|
3
|
-
|
4
|
-
require 'rinne'
|
5
|
-
|
6
|
-
module HTOTConv
|
7
|
-
module CLI
|
8
|
-
class ScriptOptions
|
9
|
-
def initialize
|
10
|
-
@options = {
|
11
|
-
:from_type => :simple_text,
|
12
|
-
:to_type => :xlsx_type2,
|
13
|
-
}
|
14
|
-
@from_options = {}
|
15
|
-
@to_options = {}
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
opts.
|
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
|
-
@from_options[key] = v
|
66
|
-
end
|
67
|
-
|
68
|
-
@to_options[key] = v
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require 'rinne'
|
5
|
+
|
6
|
+
module HTOTConv
|
7
|
+
module CLI
|
8
|
+
class ScriptOptions
|
9
|
+
def initialize
|
10
|
+
@options = {
|
11
|
+
:from_type => :simple_text,
|
12
|
+
:to_type => :xlsx_type2,
|
13
|
+
}
|
14
|
+
@from_options = {}
|
15
|
+
@to_options = {}
|
16
|
+
end
|
17
|
+
attr_reader :options, :from_options, :to_options
|
18
|
+
|
19
|
+
def freeze
|
20
|
+
@options.freeze
|
21
|
+
@from_options.freeze
|
22
|
+
@to_options.freeze
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def define_options(opts, io_filter=false)
|
27
|
+
opts.banner = %q{Hierarchical-Tree Outline Text Converter}
|
28
|
+
opts.define_head %q{Usage: htot_conv [options] [input] [output]}
|
29
|
+
opts.separator %q{}
|
30
|
+
opts.separator %q{Options:}
|
31
|
+
|
32
|
+
from_types = HTOTConv::Parser.types.map { |v| [v, v.to_s.tr("_", "-")] }.flatten
|
33
|
+
to_types = HTOTConv::Generator.types.map { |v| [v, v.to_s.tr("_", "-")] }.flatten
|
34
|
+
|
35
|
+
opts.on("-f", "--from-type=TYPE", from_types, "type of input (default: #{options[:from_type]})") do |v|
|
36
|
+
@options[:from_type] = v.to_s.tr("-", "_")
|
37
|
+
end
|
38
|
+
opts.on("-t", "--to-type=TYPE", to_types, "type of output (default: #{options[:to_type]})") do |v|
|
39
|
+
@options[:to_type] = v.to_s.tr("-", "_")
|
40
|
+
end
|
41
|
+
opts.on("-l", "--list-type", "list input/output type") do
|
42
|
+
$stdout << "type of input:\n"
|
43
|
+
$stdout << HTOTConv::Parser.types.join(" ") << "\n"
|
44
|
+
$stdout << "\n"
|
45
|
+
$stdout << "type of output:\n"
|
46
|
+
$stdout << HTOTConv::Generator.types.join(" ") << "\n"
|
47
|
+
$stdout << "\n"
|
48
|
+
exit
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.separator ""
|
52
|
+
opts.on("-h", "-?", "--help", "Show this message") do
|
53
|
+
puts opts
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
opts.on("--version", "Show version") do
|
57
|
+
$stdout << "htot_conv #{HTOTConv::VERSION}\n"
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.separator ""
|
62
|
+
opts.separator "I/O Options:"
|
63
|
+
if io_filter
|
64
|
+
define_sub_options_of(opts, HTOTConv::Parser, @options[:from_type], "from") do |key, v|
|
65
|
+
@from_options[key] = v
|
66
|
+
end
|
67
|
+
define_sub_options_of(opts, HTOTConv::Generator, @options[:to_type], "to") do |key, v|
|
68
|
+
@to_options[key] = v
|
69
|
+
end
|
70
|
+
else
|
71
|
+
define_sub_options(opts, HTOTConv::Parser, "from") do |key, v|
|
72
|
+
@from_options[key] = v
|
73
|
+
end
|
74
|
+
define_sub_options(opts, HTOTConv::Generator, "to") do |key, v|
|
75
|
+
@to_options[key] = v
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
def add_sub_options_of_a_type_to!(cli_options, opts, klass, type, prefix)
|
82
|
+
type_klass = klass.const_get(Rinne.camelize(type.to_s))
|
83
|
+
type_klass.option_help.each do |key,v|
|
84
|
+
long_option = "--#{prefix}-#{key.to_s.tr('_','-')}"
|
85
|
+
|
86
|
+
if cli_options.include?(long_option)
|
87
|
+
cli_options[long_option][:desc] << "For #{type}, #{v[:desc]}"
|
88
|
+
unless cli_options[long_option][:pattern] == v[:pat]
|
89
|
+
if (cli_options[long_option][:pattern].kind_of?(Array) && v[:pat].kind_of?(Array))
|
90
|
+
cli_options[long_option][:pattern] = cli_options[long_option][:pattern].concat(v[:pat]).uniq
|
91
|
+
else
|
92
|
+
raise "pattern registration mismatch around #{long_option}"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
else
|
96
|
+
cli_options[long_option] = {
|
97
|
+
:key => key,
|
98
|
+
:pattern => v[:pat],
|
99
|
+
:desc => ["For #{type}, #{v[:desc]}"],
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
def define_sub_options_of(opts, klass, type, prefix) # :yields: key, v
|
107
|
+
cli_options = {}
|
108
|
+
|
109
|
+
add_sub_options_of_a_type_to!(cli_options, opts, klass, type, prefix)
|
110
|
+
|
111
|
+
cli_options.each do |long_option, value|
|
112
|
+
opts.on("#{long_option}=VAL", value[:pattern], *value[:desc]) do |v|
|
113
|
+
yield value[:key], v
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
def define_sub_options(opts, klass, prefix) # :yields: key, v
|
120
|
+
cli_options = {}
|
121
|
+
|
122
|
+
klass.types.each do |type|
|
123
|
+
add_sub_options_of_a_type_to!(cli_options, opts, klass, type, prefix)
|
124
|
+
end
|
125
|
+
|
126
|
+
cli_options.each do |long_option, value|
|
127
|
+
opts.on("#{long_option}=VAL", value[:pattern], *value[:desc]) do |v|
|
128
|
+
yield value[:key], v
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def optparse!(args)
|
135
|
+
script_opts = ScriptOptions.new
|
136
|
+
OptionParser.new do |opts|
|
137
|
+
script_opts.define_options(opts)
|
138
|
+
|
139
|
+
begin
|
140
|
+
opts.parse!(args.dup)
|
141
|
+
rescue OptionParser::ParseError => ex
|
142
|
+
$stderr << ex.message << "\n"
|
143
|
+
exit 1
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
OptionParser.new do |opts|
|
148
|
+
script_opts.define_options(opts, true)
|
149
|
+
|
150
|
+
begin
|
151
|
+
opts.parse!(args)
|
152
|
+
rescue OptionParser::ParseError => ex
|
153
|
+
$stderr << ex.message << "\n"
|
154
|
+
exit 1
|
155
|
+
end
|
156
|
+
end
|
157
|
+
script_opts.freeze
|
158
|
+
end
|
159
|
+
module_function :optparse!
|
160
|
+
|
161
|
+
def main(args=ARGV)
|
162
|
+
script_opts = HTOTConv::CLI.optparse!(args)
|
163
|
+
options = script_opts.options
|
164
|
+
from_options = script_opts.from_options
|
165
|
+
to_options = script_opts.to_options
|
166
|
+
|
167
|
+
inio = ((args.length > 0) && (args[0] != "-"))? File.open(args[0], "rb") : $stdin
|
168
|
+
outio = ((args.length > 1) && (args[1] != "-"))? File.open(args[1], "wb") : $stdout
|
169
|
+
|
170
|
+
HTOTConv.convert(inio, options[:from_type], outio, options[:to_type], from_options, to_options)
|
171
|
+
end
|
172
|
+
module_function :main
|
173
|
+
end
|
174
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module HTOTConv
|
3
|
-
module Generator
|
4
|
-
class Base
|
5
|
-
def initialize(data, option={})
|
6
|
-
data.validate
|
7
|
-
@data = data
|
8
|
-
@option = self.class.option_help.inject({}) { |h, pair| h[pair[0]] = pair[1][:default]; h}.merge(option)
|
9
|
-
end
|
10
|
-
def self.option_help
|
11
|
-
{}
|
12
|
-
end
|
13
|
-
|
14
|
-
def output(outputfile)
|
15
|
-
raise NotImplementedError.new("#{self.class.name}.#{__method__} is an abstract method.")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class XlsxBase < Base
|
20
|
-
def output_to_worksheet(ws)
|
21
|
-
raise NotImplementedError.new("#{self.class.name}.#{__method__} is an abstract method.")
|
22
|
-
end
|
23
|
-
|
24
|
-
def output(outputfile)
|
25
|
-
p = Axlsx::Package.new
|
26
|
-
p.workbook do |wb|
|
27
|
-
wb.add_worksheet do |ws|
|
28
|
-
output_to_worksheet(ws)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
p.serialize(outputfile)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module HTOTConv
|
3
|
+
module Generator
|
4
|
+
class Base
|
5
|
+
def initialize(data, option={})
|
6
|
+
data.validate
|
7
|
+
@data = data
|
8
|
+
@option = self.class.option_help.inject({}) { |h, pair| h[pair[0]] = pair[1][:default]; h}.merge(option)
|
9
|
+
end
|
10
|
+
def self.option_help
|
11
|
+
{}
|
12
|
+
end
|
13
|
+
|
14
|
+
def output(outputfile)
|
15
|
+
raise NotImplementedError.new("#{self.class.name}.#{__method__} is an abstract method.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class XlsxBase < Base
|
20
|
+
def output_to_worksheet(ws)
|
21
|
+
raise NotImplementedError.new("#{self.class.name}.#{__method__} is an abstract method.")
|
22
|
+
end
|
23
|
+
|
24
|
+
def output(outputfile)
|
25
|
+
p = Axlsx::Package.new
|
26
|
+
p.workbook do |wb|
|
27
|
+
wb.add_worksheet do |ws|
|
28
|
+
output_to_worksheet(ws)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
p.serialize(outputfile)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'axlsx'
|
3
|
-
|
4
|
-
require 'htot_conv/generator/base'
|
5
|
-
|
6
|
-
module HTOTConv
|
7
|
-
module Generator
|
8
|
-
class XlsxType0 < XlsxBase
|
9
|
-
def output_to_worksheet(ws)
|
10
|
-
max_value_length = @data.max_value_length
|
11
|
-
|
12
|
-
ws.add_row([@data.key_header[0], 'Outline Level'].concat(
|
13
|
-
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
14
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
15
|
-
|
16
|
-
@data.item.each do |item|
|
17
|
-
ws.add_row([item.key, item.level.to_i].concat(
|
18
|
-
HTOTConv::Util.pad_array(item.value, max_value_length)),
|
19
|
-
:style => Axlsx::STYLE_THIN_BORDER)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'axlsx'
|
3
|
+
|
4
|
+
require 'htot_conv/generator/base'
|
5
|
+
|
6
|
+
module HTOTConv
|
7
|
+
module Generator
|
8
|
+
class XlsxType0 < XlsxBase
|
9
|
+
def output_to_worksheet(ws)
|
10
|
+
max_value_length = @data.max_value_length
|
11
|
+
|
12
|
+
ws.add_row([@data.key_header[0], 'Outline Level'].concat(
|
13
|
+
HTOTConv::Util.pad_array(@data.value_header, max_value_length)),
|
14
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
15
|
+
|
16
|
+
@data.item.each do |item|
|
17
|
+
ws.add_row([item.key, item.level.to_i].concat(
|
18
|
+
HTOTConv::Util.pad_array(item.value, max_value_length)),
|
19
|
+
:style => Axlsx::STYLE_THIN_BORDER)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|