lhj-tools 0.2.81 → 0.2.82

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a419cd28646ee40f8a8705d14b93ef95795e54cd8aad658ed1f091a5bb32541c
4
- data.tar.gz: 2819685f8bc414cfa696094c1ffa1b5509761b3ae70caacbd218feb7818eded5
3
+ metadata.gz: e5cb532b2f91d92e8575f55aa8f46251351fe6cf8497732c9436344d41c3f10b
4
+ data.tar.gz: 9e90fce95487eb3185ffad60b9840cefa94e4defff4dab3355a809ad524acc45
5
5
  SHA512:
6
- metadata.gz: 6bc1dc881c997fab47da6556bc6b2bb54816ecfc22f6178cdb5b181abb836637c1e5fae66a296ba2564aff7066147a9d1afbbce7bc462e90fe348dab5d33593c
7
- data.tar.gz: e5f169d598fef4c355b7759608fd2be7e4cc04b0a54525390a21273aa95727f16c56916d2b065365dad9005b83d3f3eebda1cd9bf2693011adbb51816a2bebac
6
+ metadata.gz: 60613b6d94a186e14a6c06d62e46277658c90804b37d3d62185bc94edba554463ef426de55e687e74338c9617ebaaf09342a7ed21eecb14053ae4068f1d4539a
7
+ data.tar.gz: 96297521dbf1c255087ae94accee5f04de60ea533c6bb46c7ca537c0cc7ceee4ea0269c9b6f7df983821cf676006b071e49f044993ee48fb04395383b2934ff1
@@ -45,8 +45,11 @@ module Lhj
45
45
  en_col = @cli.ask('中英对应照csv<<英文>>所在的列, 默认为2: '.yellow, Integer) do |q|
46
46
  q.default = 2
47
47
  end
48
+ quote_char = @cli.ask('引号字符, 默认为": '.yellow, String) do |q|
49
+ q.default = '"'
50
+ end
48
51
  begin
49
- read_csv_file(csv_file, key_col, cn_col, en_col)
52
+ read_csv_file(csv_file, quote_char, key_col, cn_col, en_col)
50
53
  rescue ArgumentError => e
51
54
  puts e.message.red
52
55
  end
@@ -91,15 +94,17 @@ module Lhj
91
94
  File.exist?(dest_file) ? bak_file(dest_file) : dest_file
92
95
  end
93
96
 
94
- def read_csv_file(file, key_c, cn_c, en_c)
97
+ def read_csv_file(file, quote_char, key_c, cn_c, en_c)
95
98
  begin
96
99
  current_row = nil
97
- CSV.foreach(file, quote_char: ',') do |row|
100
+ CSV.foreach(file, quote_char: quote_char) do |row|
98
101
  current_row = row
99
102
  if row.length > 2
100
103
  key = row[key_c]
101
104
  cn_str = row[cn_c]
102
105
  hk_str = row[cn_c]
106
+ cn_str ||= ''
107
+ hk_str ||= ''
103
108
  # cn_str = Lhj::Trans::Helper.instance.trans_zh_cn_str(cn_str) if trans_cn
104
109
  hk_str = Lhj::Trans::Helper.instance.trans_zh_hk_str(hk_str) if hk_str&.length&.positive?
105
110
  @key_map[key] = { key: key, cn: cn_str, hk: hk_str, en: row[en_c] } unless key =~ /[\u4e00-\u9fa5]/
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.81'
4
+ VERSION = '0.2.82'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.81
4
+ version: 0.2.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-16 00:00:00.000000000 Z
11
+ date: 2024-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj