cbeta 3.6.3 → 3.6.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cbeta/p5a_checker.rb +43 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 644f49e37566f3f90599849baa5b31c2df1a0ca28c76c530ec42ec8e839c5da5
4
- data.tar.gz: 2293f8fcf48f5aceecf09e2731ef4c3825f6bc80ac97249105a8e435f1ad9100
3
+ metadata.gz: 49e62ac8c7805abccecdd47d26c301797f3b5262659f1aca46dd4d314dfd50ae
4
+ data.tar.gz: 72e3a47fd5fe23c0ecef82d9cbcbfd9d1c4079a41133c1325d1f5220b68f24a7
5
5
  SHA512:
6
- metadata.gz: cfdc23cf230a4e60a00085dade6a73f09352bc4ec0b24c29aaadb94c95e11fa692a3c4f1b7fb82c398b59238e36be365f65e0f0c8d67dcd52f24246318104d84
7
- data.tar.gz: 272b18af22f0a121ba9d94311588602b1e4435782227759e6ca49d09c39cd42eb7cac56895a92671d598b218949810a832e60b201fa86e54706311f3bbef8eea
6
+ metadata.gz: ab60c18e220fad95a78aac7700726a2e629759933cac1b489f05890141ffdaa770a650479e56f8316b65592979ba9241a9a8f1015070af8883e0f19744b526bd
7
+ data.tar.gz: e5cd339be96a043c1186e2968cf12f6c91f779039130024423859729d58c180fa262a6c5d3447b85ebecb0eaf81b5513f48f24a0d2f8275d21a2ac779f189055
@@ -1,13 +1,15 @@
1
1
  require_relative 'cbeta_share'
2
2
 
3
3
  # 檢查 CBETA XML P5a
4
- # 錯誤類型
5
- # [E01] 行號重複
6
- # [E02] 文字直接出現在 div 下
7
- # [E03] 星號校勘 app 沒有對應的 note
8
- # 警告類型
9
- # [W01] 夾注包夾注
4
+ #
5
+ # * 錯誤類型
6
+ # * [E01] 行號重複
7
+ # * [E02] 文字直接出現在 div
8
+ # * [E03] 星號校勘 app 沒有對應的 note
9
+ # * 警告類型
10
+ # * [W01] 夾注包夾注
10
11
  class CBETA::P5aChecker
12
+
11
13
  # @param xml_root [String] 來源 CBETA XML P5a 路徑
12
14
  # @param figures [String] 插圖 路徑 (可由 https://github.com/cbeta-git/CBR2X-figures 取得)
13
15
  # @param log [String] Log file path
@@ -20,6 +22,13 @@ class CBETA::P5aChecker
20
22
  @g_errors = {}
21
23
  end
22
24
 
25
+ # 檢查全部 CBETA XML P5a
26
+ # @example
27
+ # CBETA::P5aChecker.new(
28
+ # xml_root: '~/git-repos/cbeta-xml-p5a',
29
+ # figures: '~/git-repos/CBR2X-figures',
30
+ # log: '~/log/check-cbeta-xml.log'
31
+ # ).check
23
32
  def check
24
33
  puts "xml: #{@xml_root}"
25
34
  each_canon(@xml_root) do |c|
@@ -31,6 +40,31 @@ class CBETA::P5aChecker
31
40
  display_errors
32
41
  end
33
42
 
43
+ # 檢查某部藏經
44
+ # @param canon [String] 藏經 ID, example: "T"
45
+ def check_canon(canon)
46
+ @canon = canon
47
+ path = File.join(@xml_root, @canon)
48
+ handle_canon(path)
49
+ display_errors
50
+ end
51
+
52
+ # 檢查某一冊
53
+ # @param vol [String] 冊號, example: "T01"
54
+ def check_vol(vol)
55
+ @vol = vol
56
+ @canon = CBETA.get_canon_from_vol(vol)
57
+ path = File.join(@xml_root, @canon, vol)
58
+ handle_vol(path)
59
+ display_errors
60
+ end
61
+
62
+ # 檢查單一檔案
63
+ # @example
64
+ # CBETA::P5aChecker.new(
65
+ # figures: '~/git-repos/CBR2X-figures',
66
+ # log: '~/log/check-cbeta-xml.log'
67
+ # ).check_file('~/git-repos/cbeta-xml-p5a/A/A110/A110n1490.xml')
34
68
  def check_file(fn)
35
69
  handle_file(fn)
36
70
  display_errors
@@ -56,11 +90,11 @@ class CBETA::P5aChecker
56
90
  if @errors.empty?
57
91
  puts "檢查完成,未發現錯誤。"
58
92
  elsif @log.nil?
59
- puts "\n發現錯誤:"
93
+ puts "發現錯誤:"
60
94
  puts @errors
61
95
  else
62
96
  File.write(@log, @errors)
63
- puts "\n發現錯誤,請查看 #{@log}"
97
+ puts "發現錯誤,請查看 #{@log}"
64
98
  end
65
99
  end
66
100
 
@@ -143,7 +177,6 @@ class CBETA::P5aChecker
143
177
  Dir.entries(folder).sort.each do |f|
144
178
  next if f.start_with? '.'
145
179
  @vol = f
146
- $stderr.print "#{@vol} "
147
180
  path = File.join(folder, @vol)
148
181
  handle_vol(path)
149
182
  end
@@ -184,6 +217,7 @@ class CBETA::P5aChecker
184
217
  end
185
218
 
186
219
  def handle_vol(folder)
220
+ puts "check vol: #{File.basename(folder)}"
187
221
  Dir.entries(folder).sort.each do |f|
188
222
  next if f.start_with? '.'
189
223
  path = File.join(folder, f)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3
4
+ version: 3.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Chou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-21 00:00:00.000000000 Z
11
+ date: 2025-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unihan2