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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 162c65bdd20af8ec0f1e4dfe904d9f416172544866dad06fa5366339f65b44e7
4
- data.tar.gz: 0d7e416699f21eeed2bb03be4fb1f48b2bedf458e81024af3a177c5253c4025f
3
+ metadata.gz: e962c6fdfe8c27d055e0053ec0c8a6b21546d3566dc838f8c1e06f82c4de6c2e
4
+ data.tar.gz: b1f9d4038d1d8990584e2b67d03a32d520a2149cff85a708ee3409233e8ad371
5
5
  SHA512:
6
- metadata.gz: 0c3befdd8cb64fb89076dc87fc733b57a50ee549de4384c4fc9775e77d156a6ccaa1850721ce4026f790ef9a0a513221f1f32e8f2a53c6bfe6f89e1ea97baab6
7
- data.tar.gz: 32dcd95d4e6b9fb616e8fbdc15c39b34bb3ff8420fb0188a3030649497643b87ec82451c2767b1d42bc047aeffc730cf9f4aa3d1b2d12eb673a2a682b886a6e7
6
+ metadata.gz: 1ca7c866bee53d9c05a3086b0d19084f0aafb8966aec967eaffc1949891a7e1bcef54adde7b33d191f41a01f51660b44edcdb3073688e07b57eed67fdce374d5
7
+ data.tar.gz: f509be16242fd17a07abb08cb040b99efb0225ab9aa1423cfdfa71c56ad05d3e22bd2eac78bebb95067064b0e4859966c4101a0fe5a53dfdd8071349d281ea35
data/README.md CHANGED
@@ -1,35 +1,33 @@
1
1
  # Csv2dokuwikiTab
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
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 UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
16
+ gem install csv2dokuwiki_tab
21
17
  ```
22
18
 
23
19
  ## Usage
24
20
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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/[USERNAME]/csv2dokuwiki_tab.
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/shujishigenobu/csv2dokuwiki_tab
@@ -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
- file, header_type = parse_options
45
- converter = Csv2dokuwikiTab::Converter.new(file, header_type)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Csv2dokuwikiTab
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv2dokuwiki_tab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
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-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.