csv2dokuwiki_tab 0.3.1 → 0.4.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: de17f86eaa106c1f98f82b700f9f68a50bddda451fab7e19d67e56e0cd4c8831
4
- data.tar.gz: 6e7383e2e5da66889d15fc7fb80f9126499b0d93b5eca4830259e253b999a9fb
3
+ metadata.gz: '058ac7e8642fc05e6c32d6f7176155a42bba11768d216d7ac2ae346e24363068'
4
+ data.tar.gz: 0ca3b9cbb04c16fac008c8cec7fa502d78285373defd48c51b1d2300d184d685
5
5
  SHA512:
6
- metadata.gz: '08fce63576e05b879a26be92a9172d379f141c7c8617c078c43c4be115d8c7c7930bb8ddbc5902f301af7f6434968dbdaa91777902d0d923461c71e9911dc1c1'
7
- data.tar.gz: 1b795aa9e5ed420547b8e773c5ae6b7645ebdd2d30f8f976a9d66fbfb141a96baeedf1e16a57ee0381781420a9e7783269aa18b430dd5c110ca16d1ad135d424
6
+ metadata.gz: fa87dd40ca003455256e9ee76a9a5dc839aaad2b5fb44ead93a3b38728d42cdbe469caa84680d09cb5c1746265c2f181bba1ecfc848602bf64e0c2f6d71cd9e7
7
+ data.tar.gz: 37ffa816325d2c2cd46e2ef9c153f89a8667b1cc1cc0b33c93ad24a8d47935b9774a0c219df4a2cb8f4ba6e888b02e2cb5a32ba43d2928bfc739675c35887d53
@@ -0,0 +1,3 @@
1
+ example2.csv
2
+ deficition of GAF format of Gene Ontology annotations.
3
+ (https://geneontology.org/docs/go-annotation-file-gaf-format-2.1/)
@@ -0,0 +1,4 @@
1
+ ^ Name ^ Age ^ Country ^
2
+ | Alice | 30 | USA |
3
+ | Bob | 25 | Canada |
4
+ | Charlie | 35 | UK |
@@ -0,0 +1,18 @@
1
+ Column,Content,Required?,Cardinality,Example,
2
+ 1,DB,required,1,UniProtKB,
3
+ 2,DB Object ID,required,1,P12345,
4
+ 3,DB Object Symbol,required,1,PHO3,
5
+ 4,Relation,required,1 or 2,NOT,involved_in
6
+ 5,GO ID,required,1,GO:0003993,
7
+ 6,DB:Reference (|DB:Reference),required,1 or greater,PMID:2676709,
8
+ 7,Evidence Code,required,1,IMP,
9
+ 8,With (or) From,optional,0 or greater,GO:0000346,
10
+ 9,Aspect,required,1,F,
11
+ 10,DB Object Name,optional,0 or 1,Toll-like receptor 4,
12
+ 11,DB Object Synonym (|Synonym),optional,0 or greater,hToll,Tollbooth
13
+ 12,DB Object Type,required,1,protein,
14
+ 13,Taxon(|taxon),required,1 or 2,taxon:9606,
15
+ 14,Date,required,1,20090118,
16
+ 15,Assigned By,required,1,SGD,
17
+ 16,Annotation Extension,optional,0 or greater,part_of(CL:0000576),
18
+ 17,Gene Product Form ID,optional,0 or 1,UniProtKB:P12345-2,
@@ -52,7 +52,7 @@ end
52
52
  # Main CLI
53
53
 
54
54
  opt = parse_options
55
- p opt
55
+ #p opt
56
56
  sep = opt[:tab] ? "\t" : ","
57
57
  converter = Csv2dokuwikiTab::Converter.new(opt[:file], opt[:header_type], sep)
58
58
  converter.convert
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Csv2dokuwikiTab
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -11,8 +11,8 @@ require_relative "csv2dokuwiki_tab/version"
11
11
  ############################
12
12
 
13
13
  module Csv2dokuwikiTab
14
+
14
15
  class Error < StandardError; end
15
- # Your code goes here...
16
16
 
17
17
  require "csv"
18
18
 
@@ -22,6 +22,11 @@ module Csv2dokuwikiTab
22
22
  HEADER_BOTH = 3
23
23
 
24
24
  class Converter
25
+
26
+ def self.escape(text)
27
+ text.to_s.gsub('|', '%%|%%').gsub('^', '%%^%%')
28
+ end
29
+
25
30
  def initialize(file, header_type=1, sep=",")
26
31
  @header_type = header_type
27
32
  @sep = sep
@@ -57,18 +62,18 @@ module Csv2dokuwikiTab
57
62
  def print_header_row(row)
58
63
  case @header_type
59
64
  when HEADER_ROW, HEADER_BOTH
60
- puts "^" + row.map { |x| " #{x} " }.join("^") + "^"
65
+ puts "^" + row.map { |x| " #{Converter.escape(x)} " }.join("^") + "^"
61
66
  else
62
- puts "|" + row.map { |x| " #{x} " }.join("|") + "|"
67
+ puts "|" + row.map { |x| " #{Converter.escape(x)} " }.join("|") + "|"
63
68
  end
64
69
  end
65
70
 
66
71
  def print_data_row(row)
67
72
  case @header_type
68
73
  when HEADER_COL, HEADER_BOTH
69
- puts "^" + row[0].to_s + "^" + row[1..-1].map { |x| " #{x} " }.join("|") + "|"
74
+ puts "^" + row[0].to_s + "^" + row[1..-1].map { |x| " #{Converter.escape(x)} " }.join("|") + "|"
70
75
  else
71
- puts "|" + row.map { |x| " #{x} " }.join("|") + "|"
76
+ puts "|" + row.map { |x| " #{Converter.escape(x)} " }.join("|") + "|"
72
77
  end
73
78
  end
74
79
  end
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.3.1
4
+ version: 0.4.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-13 00:00:00.000000000 Z
11
+ date: 2025-09-23 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.
@@ -23,8 +23,11 @@ files:
23
23
  - LICENSE
24
24
  - README.md
25
25
  - Rakefile
26
+ - examples/README.md
26
27
  - examples/example.csv
28
+ - examples/example.csv.convert_def.txt
27
29
  - examples/example.tsv
30
+ - examples/example2.csv
28
31
  - exe/csv2dokuwiki_tab
29
32
  - exe/csv2dokuwiki_tab.rb
30
33
  - lib/csv2dokuwiki_tab.rb