csv2dokuwiki_tab 0.1.1 → 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 +12 -14
- 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
@@ -1,35 +1,33 @@
|
|
1
1
|
# Csv2dokuwikiTab
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/csv2dokuwiki_tab`. To experiment with that code, run `bin/console` for an interactive prompt.
|
3
|
+
Read CSV and convert to DokuWiki table format.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
12
8
|
|
13
9
|
```bash
|
14
|
-
bundle add
|
10
|
+
bundle add csv2dokuwiki_tab
|
15
11
|
```
|
16
12
|
|
17
13
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
14
|
|
19
15
|
```bash
|
20
|
-
gem install
|
16
|
+
gem install csv2dokuwiki_tab
|
21
17
|
```
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
```bash
|
22
|
+
Usage: csv_to_dokuwiki_tab.rb [options]
|
23
|
+
-f, --file FILE CSV file to convert
|
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
|
26
|
+
-h, --help Prints this help
|
27
|
+
-v, --version Prints the version
|
28
|
+
```
|
30
29
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
30
|
|
33
31
|
## Contributing
|
34
32
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
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.
|