-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv2test-result.rb
More file actions
82 lines (75 loc) · 2.11 KB
/
csv2test-result.rb
File metadata and controls
82 lines (75 loc) · 2.11 KB
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
81
82
#!/usr/bin/env ruby
# encoding: utf-8
require 'set'
require 'csv'
require 'tempfile'
def toTagString(arg)
str = "未実施"
cls = "warning"
case arg.encode("UTF-8")
when "OK" then
str = "OK"
cls = "success"
when "NG" then
str = "NG"
cls = "danger"
when "保留" then
str = "保留"
cls = "default"
when "未実施" then
str = "未実施"
cls = "warning"
end
"<span class=\"label label-#{cls}\">#{str}</span>"
end
#temp = File.new("temp.md", "w+")
temp = Tempfile.new("temp", "./")
index = 1
count = 0
ARGV.map do |sourcepath|
funcs = Hash.new
open(sourcepath, "rb:Shift_JIS:UTF-8", undef: :replace) do |f|
CSV.new(f, headers: :first_row).each do |row|
mkdRow = { :index => index,
:subject => row[1],
:content => row[2],
:result => row[3].to_s(),
:remarks => row[4] }
if !(funcs.key? row[0]) then
funcs.store(row[0], [mkdRow])
else
funcs[row[0]].push(mkdRow)
end
index = index + 1
if mkdRow[:result] == "OK" then
count = count + 1
end
end
end
temp.puts "# " + File.basename(sourcepath, ".*").encode("UTF-8") + "\n"
funcs.each do |k, v|
temp.puts "## " + k.to_s() + "\n"
temp.puts "\n"
temp.puts "|番号|機能|確認内容|結果|備考|\n"
temp.puts "|---:|----|--------|:--:|----|\n"
v.each do |s|
temp.puts "|#{s[:index]}|#{s[:subject]}|#{s[:content]}|#{toTagString(s[:result])}|#{s[:remarks]}|\n"
end
temp.puts "\n"
end
end
temp.fsync()
system("pandoc",
"--table-of-contents",
"--output=" + File.basename(ARGV[0], ".*") + ".html",
"--to=html5",
"--from=markdown",
"--highlight-style=tango",
"--smart",
"--standalone",
"--self-contained",
"--css=http://jasonm23.github.com/markdown-css-themes/markdown7.css",
"--css=https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css", temp.path)
p "処理行数:#{index}レコード".encode("cp932")
r = Rational(count, index)
p "進捗: #{r} #{(r.to_f * 100).floor}%完了".encode("cp932")