lhj-tools 0.2.81 → 0.2.83

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: e5d002932699d20e17f85d6c37b38bb6450b3ddbc1cbf7611d8e01fb28035465
4
+ data.tar.gz: 04c53c4bdd4d245538c1e0f347153aa15a20d5a0497248c89acfc9040d550c56
5
5
  SHA512:
6
- metadata.gz: 6bc1dc881c997fab47da6556bc6b2bb54816ecfc22f6178cdb5b181abb836637c1e5fae66a296ba2564aff7066147a9d1afbbce7bc462e90fe348dab5d33593c
7
- data.tar.gz: e5f169d598fef4c355b7759608fd2be7e4cc04b0a54525390a21273aa95727f16c56916d2b065365dad9005b83d3f3eebda1cd9bf2693011adbb51816a2bebac
6
+ metadata.gz: e31cccdb1e468653c14cd2e4fc370a6c445fbb22ed6f1c79c610821f8d04c5c2b7368ea0c2ebcefa0f049fff9c9480515ff303799637881a223076b64fb08443
7
+ data.tar.gz: b72cae20a8095402304f1b3b62edfd042a6b330a7903986c52634671dc17285dedd9c221feaa5e96f66bffde9de7e25ac06023b7373ae77ef926a5561d4f9905
@@ -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]/
@@ -40,6 +40,7 @@ module Lhj
40
40
  block_lines = []
41
41
  File.open(file, 'r') do |f|
42
42
  multi_comment = false
43
+ strong_key = false
43
44
  available_idx = 0
44
45
  block_idx = 0
45
46
  f.readlines.each_with_index do |line, idx|
@@ -60,10 +61,13 @@ module Lhj
60
61
  # 此行包含^符号,且不是方法声明,且不是主线程方法
61
62
  if (line =~ BLOCK_KEY_BEGIN_REGEX && line !~ /^\s*[+-]/ && line !~ /dispatch_get_main_queue/) || block_idx.positive?
62
63
  line_position = block_idx.zero? ? :start : :process
64
+ strong_key = false if block_idx.zero?
65
+ strong_key = true if line =~ /@strongify/
63
66
  block_idx += 1 if line =~ /\{/
64
67
  block_idx -= 1 if line =~ /\}/
65
68
  line_position = :end if block_idx.zero?
66
- block_lines << { idx: idx, line: line, position: line_position }
69
+ strong_key = false if block_idx.zero?
70
+ block_lines << { idx: idx, line: line, position: line_position, strong: strong_key }
67
71
  end
68
72
  end
69
73
  end
@@ -73,6 +77,7 @@ module Lhj
73
77
  def self.handle_block_notify(file_name, wrapper_lines)
74
78
  arr = wrapper_lines.filter { |l| l[:position] != :start }
75
79
  arr.filter! { |l| l[:position] != :end }
80
+ arr.filter! { |l| !l[:strong] }
76
81
  arr.filter! { |l| l[:line] =~ /\W+self\W+/ || l[:line] =~ /\W+_/ }
77
82
  arr.filter! { |l| l[:line] !~ /\^/ }
78
83
  arr.filter! { |l| l[:line] !~ /__weak/ }
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.83'
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.83
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-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj