csv2dokuwiki_tab 0.2.2 → 0.3.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: fa1ffdd9ae8b0d17a3509b48c17ff9f54e68857d079d911d68d49dffce80a8b2
4
- data.tar.gz: b211541723f839624c8ab1b1e8da82c87c1f8afcb9435e96127c966d9498a3a8
3
+ metadata.gz: cd1c67669591afc52a78975221128be1d2a8a480aa80039e40faf7e83112a018
4
+ data.tar.gz: a9834019908a5ac50d556dd3c918f41169f862d90a444b8b7276cacd64c4f6bb
5
5
  SHA512:
6
- metadata.gz: 9a467f0424fc7bbaccc7ea3f54ccc6f35bbd0f63947eace5fdec53312b62873c4f478843c73aa51f3b9a2d04117439e918dcf8d4a62a6061cfa2d77c88dd5bf8
7
- data.tar.gz: cb835f5eb4564cfe20d45204471b85ef147d8d244f747f1677d081cd61ffda9c9c70355734d55e8a7e3e2c982be8a8a4661b12279e5e4405bba0394a047ed296
6
+ metadata.gz: 5fe8bcb0cbe9e7df4bf83981ddde8b410f3e64226fd08a545ef57afbdf749f8520291b490146f2917022fb364f5a93c09235b3d89daa9edef6943da54cbdcdff
7
+ data.tar.gz: 1eef971ba167188ec852651446d9c89278bf28104cc7e037de813ba6c97cbe68930ce4e988ddefe018d646e644fe9ada529c551bfdd5cda9756de715cd3853b7
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 shujishigenobu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,17 +1,11 @@
1
1
  # Csv2dokuwikiTab
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/csv2dokuwiki_tab.svg)](https://badge.fury.io/rb/csv2dokuwiki_tab)
4
+
3
5
  Read CSV and convert to DokuWiki table format.
4
6
 
5
7
  ## Installation
6
8
 
7
- Install the gem and add to the application's Gemfile by executing:
8
-
9
- ```bash
10
- bundle add csv2dokuwiki_tab
11
- ```
12
-
13
- If bundler is not being used to manage dependencies, install the gem by executing:
14
-
15
9
  ```bash
16
10
  gem install csv2dokuwiki_tab
17
11
  ```
@@ -31,3 +25,7 @@ Usage: csv_to_dokuwiki_tab.rb [options]
31
25
  ## Contributing
32
26
 
33
27
  Bug reports and pull requests are welcome on GitHub at https://github.com/shujishigenobu/csv2dokuwiki_tab
28
+
29
+ ## License
30
+
31
+ This repository is licensed under the [MIT License](./LICENSE). See the LICENSE file for details.
@@ -7,7 +7,7 @@ def parse_options
7
7
  options = {}
8
8
  header_type = Csv2dokuwikiTab::HEADER_ROW
9
9
  OptionParser.new do |opts|
10
- opts.banner = "Usage: csv_to_dokuwiki_tab.rb [options]"
10
+ opts.banner = "Usage: csv_to_dokuwiki_tab.rb [options]\n (use -f - for STDIN)"
11
11
 
12
12
  opts.on("-f FILE", "--file FILE", "CSV file to convert") do |f|
13
13
  options[:file] = f
@@ -40,7 +40,7 @@ def parse_options
40
40
  end
41
41
  end.parse!
42
42
  unless options[:file]
43
- warn "Error: CSV file must be specified with -f"
43
+ warn "Error: CSV file must be specified with -f (use -f - for STDIN)"
44
44
  exit 1
45
45
  end
46
46
  # [options[:file], header_type, options[:tab]]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Csv2dokuwikiTab
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -23,14 +23,19 @@ module Csv2dokuwikiTab
23
23
 
24
24
  class Converter
25
25
  def initialize(file, header_type=1, sep=",")
26
- @file = file
27
26
  @header_type = header_type
28
27
  @sep = sep
28
+ @io =
29
+ if file.nil? || file == "-"
30
+ $stdin
31
+ else
32
+ File.open(file, "r")
33
+ end
29
34
  end
30
35
 
31
36
  def convert
32
37
  begin
33
- CSV.foreach(@file, col_sep: @sep).with_index do |row, idx|
38
+ CSV.new(@io, col_sep: @sep).each_with_index do |row, idx|
34
39
  next if row.all? { |x| x.nil? }
35
40
  if idx == 0
36
41
  print_header_row(row)
@@ -39,7 +44,7 @@ module Csv2dokuwikiTab
39
44
  end
40
45
  end
41
46
  rescue Errno::ENOENT
42
- warn "Error: File not found: #{@file}"
47
+ warn "Error: File not found"
43
48
  exit 1
44
49
  rescue CSV::MalformedCSVError => e
45
50
  warn "Error: Malformed CSV - #{e.message}"
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.2.2
4
+ version: 0.3.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-08 00:00:00.000000000 Z
11
+ date: 2025-09-09 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.
@@ -20,6 +20,7 @@ executables:
20
20
  extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
+ - LICENSE
23
24
  - README.md
24
25
  - Rakefile
25
26
  - examples/example.csv