csv2dokuwiki_tab 0.1.2 → 0.2.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/README.md +2 -1
- data/exe/csv2dokuwiki_tab.rb +13 -3
- data/lib/csv2dokuwiki_tab/version.rb +1 -1
- data/lib/csv2dokuwiki_tab.rb +3 -2
- 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: e962c6fdfe8c27d055e0053ec0c8a6b21546d3566dc838f8c1e06f82c4de6c2e
|
4
|
+
data.tar.gz: b1f9d4038d1d8990584e2b67d03a32d520a2149cff85a708ee3409233e8ad371
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ca7c866bee53d9c05a3086b0d19084f0aafb8966aec967eaffc1949891a7e1bcef54adde7b33d191f41a01f51660b44edcdb3073688e07b57eed67fdce374d5
|
7
|
+
data.tar.gz: f509be16242fd17a07abb08cb040b99efb0225ab9aa1423cfdfa71c56ad05d3e22bd2eac78bebb95067064b0e4859966c4101a0fe5a53dfdd8071349d281ea35
|
data/README.md
CHANGED
@@ -22,11 +22,12 @@ gem install csv2dokuwiki_tab
|
|
22
22
|
Usage: csv_to_dokuwiki_tab.rb [options]
|
23
23
|
-f, --file FILE CSV file to convert
|
24
24
|
-d, --header TYPE Heading type. 1=1st row, 2=1st column, 3=both 1&2, 0=none, default: 1
|
25
|
+
-t, --tab Tab-delimited text format (TSV) instead of CSV
|
25
26
|
-h, --help Prints this help
|
27
|
+
-v, --version Prints the version
|
26
28
|
```
|
27
29
|
|
28
30
|
|
29
|
-
|
30
31
|
## Contributing
|
31
32
|
|
32
33
|
Bug reports and pull requests are welcome on GitHub at https://github.com/shujishigenobu/csv2dokuwiki_tab
|
data/exe/csv2dokuwiki_tab.rb
CHANGED
@@ -25,23 +25,33 @@ def parse_options
|
|
25
25
|
header_type = Csv2dokuwikiTab::HEADER_ROW
|
26
26
|
end
|
27
27
|
end
|
28
|
+
opts.on("-t", "--tab", "Tab-delimited text format (TSV) instead of CSV") do |t|
|
29
|
+
options[:tab] = t
|
30
|
+
end
|
28
31
|
opts.on("-h", "--help", "Prints this help") do
|
29
32
|
puts opts
|
30
33
|
exit
|
31
34
|
end
|
35
|
+
opts.on("-v", "--version", "Prints the version") do
|
36
|
+
puts Csv2dokuwikiTab::VERSION
|
37
|
+
exit
|
38
|
+
end
|
32
39
|
end.parse!
|
33
40
|
unless options[:file]
|
34
41
|
warn "Error: CSV file must be specified with -f"
|
35
42
|
exit 1
|
36
43
|
end
|
37
|
-
[options[:file], header_type]
|
44
|
+
# [options[:file], header_type, options[:tab]]
|
45
|
+
return { file: options[:file], header_type: header_type, tab: options[:tab] }
|
38
46
|
end
|
39
47
|
|
40
48
|
|
41
49
|
#===
|
42
50
|
# Main CLI
|
43
51
|
|
44
|
-
|
45
|
-
|
52
|
+
opt = parse_options
|
53
|
+
p opt
|
54
|
+
sep = opt[:tab] ? "\t" : ","
|
55
|
+
converter = Csv2dokuwikiTab::Converter.new(opt[:file], opt[:header_type], sep)
|
46
56
|
converter.convert
|
47
57
|
|
data/lib/csv2dokuwiki_tab.rb
CHANGED
@@ -22,14 +22,15 @@ module Csv2dokuwikiTab
|
|
22
22
|
HEADER_BOTH = 3
|
23
23
|
|
24
24
|
class Converter
|
25
|
-
def initialize(file, header_type=1)
|
25
|
+
def initialize(file, header_type=1, sep=",")
|
26
26
|
@file = file
|
27
27
|
@header_type = header_type
|
28
|
+
@sep = sep
|
28
29
|
end
|
29
30
|
|
30
31
|
def convert
|
31
32
|
begin
|
32
|
-
CSV.foreach(@file).with_index do |row, idx|
|
33
|
+
CSV.foreach(@file, col_sep: @sep).with_index do |row, idx|
|
33
34
|
next if row.all? { |x| x.nil? }
|
34
35
|
if idx == 0
|
35
36
|
print_header_row(row)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv2dokuwiki_tab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shuji Shigenobu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-09-
|
11
|
+
date: 2025-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem provides a command-line tool to convert CSV files into DokuWiki
|
14
14
|
table format.
|