csv2dokuwiki_tab 0.1.2 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b0034ff1f3933fab295c38eed4cf5dfe23aeacdbdcf1fffb3acd3100d9158f5
4
- data.tar.gz: 82048563039d971215dcdba08136b55b81de1a1ca9d5ab80830fa2a1f9d4242f
3
+ metadata.gz: ab4ab60245f11546dc0be5e3bd1c9a6bbb3cdf02e9e5b4c582ae6f799f96a944
4
+ data.tar.gz: 75d52ecd04fe0018d0be9f5a497242babbb85b59d0c07b6933f6ec3c2b5d236f
5
5
  SHA512:
6
- metadata.gz: f30c388b66d5e90e9116f23350881b94b336ab6231bee86aa5cf2ce7f5d5ed89a0411ac36b7413a9d788ff96c266e9a13d3649adf27e9cef9151c031006cd2bd
7
- data.tar.gz: 1a88f9bcc45db3dac0c9e7fe8c9fe60076c48cc0eac70f3295e1c2b15567fcbc2fe3de0a6f80857001b8ae1c694aff3b51aabbf1493e465d084693530e7ea83f
6
+ metadata.gz: 359ed7ce02a4e787ff529d33a0182e6097c52c40a275bc5c685b0a5113ecf4a29e879160ad53628c1f0f1b3e3b4d4a9fdd881f11d5232ffe6c5cc36ec46ca1b8
7
+ data.tar.gz: 7ec79f457a9dd675c518d372fe6dfa733844b10d03ee07ebdd9a2f4c071edbfdb27300c4535ec3b3648b56e85836cb80e46f0b5a7e483335d556ed32c6ba476e
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
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ruby ./csv2dokuwiki_tab.rb "$@"
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  require_relative "../lib/csv2dokuwiki_tab"
2
4
  require "optparse"
3
5
 
@@ -25,23 +27,33 @@ def parse_options
25
27
  header_type = Csv2dokuwikiTab::HEADER_ROW
26
28
  end
27
29
  end
30
+ opts.on("-t", "--tab", "Tab-delimited text format (TSV) instead of CSV") do |t|
31
+ options[:tab] = t
32
+ end
28
33
  opts.on("-h", "--help", "Prints this help") do
29
34
  puts opts
30
35
  exit
31
36
  end
37
+ opts.on("-v", "--version", "Prints the version") do
38
+ puts Csv2dokuwikiTab::VERSION
39
+ exit
40
+ end
32
41
  end.parse!
33
42
  unless options[:file]
34
43
  warn "Error: CSV file must be specified with -f"
35
44
  exit 1
36
45
  end
37
- [options[:file], header_type]
46
+ # [options[:file], header_type, options[:tab]]
47
+ return { file: options[:file], header_type: header_type, tab: options[:tab] }
38
48
  end
39
49
 
40
50
 
41
51
  #===
42
52
  # Main CLI
43
53
 
44
- file, header_type = parse_options
45
- converter = Csv2dokuwikiTab::Converter.new(file, header_type)
54
+ opt = parse_options
55
+ p opt
56
+ sep = opt[:tab] ? "\t" : ","
57
+ converter = Csv2dokuwikiTab::Converter.new(opt[:file], opt[:header_type], sep)
46
58
  converter.convert
47
59
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Csv2dokuwikiTab
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -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,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv2dokuwiki_tab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.1
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-07 00:00:00.000000000 Z
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.
15
15
  email:
16
16
  - sshigenobu@gmail.com
17
17
  executables:
18
+ - csv2dokuwiki_tab
18
19
  - csv2dokuwiki_tab.rb
19
20
  extensions: []
20
21
  extra_rdoc_files: []
@@ -23,6 +24,7 @@ files:
23
24
  - Rakefile
24
25
  - examples/example.csv
25
26
  - examples/example.tsv
27
+ - exe/csv2dokuwiki_tab
26
28
  - exe/csv2dokuwiki_tab.rb
27
29
  - lib/csv2dokuwiki_tab.rb
28
30
  - lib/csv2dokuwiki_tab/version.rb