cbeta 1.1.14 → 1.1.15

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. metadata +3 -4
  3. data/lib/cbeta.rb +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ec3bdb33f9f33db7a3c77e89814aa3e520be5e4
4
- data.tar.gz: 8db2ee530be297d1c936421ece9020f043f752aa
3
+ metadata.gz: 84a0dbdb1f5f2be42922c7b7141d33549583599b
4
+ data.tar.gz: 55fbf7454a4da8b90e4f8776033e37101c938c64
5
5
  SHA512:
6
- metadata.gz: 24aea2d0cf538aa66e564be5bd857031fcc3b87415bc34954b8681cc21ef989385a0786bb9feefa4a70c2b322cba7c322f4a03a269457444992d4f5e2e089685
7
- data.tar.gz: f2a8b7ec59b1b440f341d9ac1ec91831c981dc90a17d110edce930da83647fb5c78382ebf7692b059d5ed02bd68b883301965c6d718a7d36bcf12b7b12c43593
6
+ metadata.gz: 59057ac310723e0217751c0c57a010c269ec09b7c1c1be02ea478ab2f2b890db6455e1a84c49bfbf9517d51a160618aae60b4b54f1570b6f76052ed9eb3a114f
7
+ data.tar.gz: a4aecb1d46a3068f689500b293b5ca7e0014c0ee281d98dc6d4f6552344dc5a11fc9684043d78e81921c601ab7075828ba31a102335a83b09afe3a40dad7356b
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: 1.1.14
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Chou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-24 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby gem for use Chinese Buddhist Text resources made by CBETA (http://www.cbeta.org).
14
14
  email: zhoubx@gmail.com
@@ -16,7 +16,6 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/cbeta.rb
20
19
  - lib/cbeta/bm_to_text.rb
21
20
  - lib/cbeta/gaiji.rb
22
21
  - lib/cbeta/html_to_text.rb
@@ -34,7 +33,7 @@ files:
34
33
  - lib/data/unicode-1.1.json
35
34
  homepage: https://github.com/RayCHOU/ruby-cbeta
36
35
  licenses:
37
- - MIT
36
+ - Apache-2.0
38
37
  metadata: {}
39
38
  post_install_message:
40
39
  rdoc_options: []
data/lib/cbeta.rb DELETED
@@ -1,111 +0,0 @@
1
- # Ruby bools for access resources produced by CBETA
2
- # (Chinese Buddhist Electronic Text Association, http://www.cbeta.org)
3
- #
4
- # 存取 CBETA 資源的 Ruby 工具
5
-
6
- require 'csv'
7
-
8
- class CBETA
9
- # 將行首資訊轉為引用格式
10
- #
11
- # @param linehead [String] 行首資訊, 例如:T85n2838_p1291a03
12
- # @return [String] 引用格式的出處資訊,例如:T85, no. 2838, p. 1291, a03
13
- #
14
- # @example
15
- # CBETA.linehead_to_s('T85n2838_p1291a03')
16
- # # return "T85, no. 2838, p. 1291, a03"
17
- def self.linehead_to_s(linehead)
18
- linehead.match(/^([A-Z]\d+)n(.*)_p(\d+)([a-z]\d+)$/) {
19
- return "#{$1}, no. #{$2}, p. #{$3}, #{$4}"
20
- }
21
- nil
22
- end
23
-
24
- # 傳入 蘭札體 缺字碼,傳回 Unicode PUA 字元
25
- def self.ranjana_pua(gid)
26
- i = 0x10000 + gid[-4..-1].hex
27
- [i].pack("U")
28
- end
29
-
30
- # 傳入 悉曇字 缺字碼,傳回 Unicode PUA 字元
31
- def self.siddham_pua(gid)
32
- i = 0xFA000 + gid[-4..-1].hex
33
- [i].pack("U")
34
- end
35
-
36
- # 載入藏經資料
37
- def initialize()
38
- fn = File.join(File.dirname(__FILE__), 'data/canons.csv')
39
- text = File.read(fn)
40
- @canon_abbr = {}
41
- @canon_nickname = {}
42
- CSV.parse(text, :headers => true) do |row|
43
- id = row['id']
44
- unless row['nickname'].nil?
45
- @canon_nickname[id] = row['nickname']
46
- end
47
- next if row['abbreviation'].nil?
48
- next if row['abbreviation'].empty?
49
- @canon_abbr[id] = row['abbreviation']
50
- end
51
-
52
- fn = File.join(File.dirname(__FILE__), 'data/categories.json')
53
- s = File.read(fn)
54
- @categories = JSON.parse(s)
55
- end
56
-
57
- # @param id [String] 藏經 ID, 例如大正藏的 ID 是 "T"
58
- # @return [String] 藏經短名,例如 "大正藏"
59
- def get_canon_nickname(id)
60
- return nil unless @canon_nickname.key? id
61
- @canon_nickname[id]
62
- end
63
-
64
- # 取得藏經略符
65
- #
66
- # @param id [String] 藏經 ID, 例如大正藏的 ID 是 "T"
67
- # @return [String] 藏經略符,例如 "【大】"
68
- #
69
- # @example
70
- # cbeta = CBETA.new
71
- # cbeta.get_canon_symbol('T') # return "【大】"
72
- def get_canon_symbol(id)
73
- return nil unless @canon_abbr.key? id
74
- @canon_abbr[id]
75
- end
76
-
77
- # 取得藏經略名
78
- #
79
- # @param id [String] 藏經 ID, 例如大正藏的 ID 是 "T"
80
- # @return [String] 藏經短名,例如 "大"
81
- #
82
- # @example
83
- # cbeta = CBETA.new
84
- # cbeta.get_canon_abbr('T') # return "大"
85
- def get_canon_abbr(id)
86
- r = get_canon_symbol(id)
87
- return nil if r.nil?
88
- r.sub(/^【(.*?)】$/, '\1')
89
- end
90
-
91
- # 傳入經號,取得部類
92
- # @param book_id [String] Book ID (經號), ex. "T0220"
93
- # @return [String] 部類名稱,例如 "阿含部類"
94
- #
95
- # @example
96
- # cbeta = CBETA.new
97
- # cbeta.get_category('T0220') # return '般若部類'
98
- def get_category(book_id)
99
- @categories[book_id]
100
- end
101
- end
102
-
103
- require 'cbeta/gaiji'
104
- require 'cbeta/bm_to_text'
105
- require 'cbeta/p5a_to_epub'
106
- require 'cbeta/p5a_to_html'
107
- require 'cbeta/p5a_to_html_for_every_edition'
108
- require 'cbeta/p5a_to_simple_html'
109
- require 'cbeta/p5a_to_text'
110
- require 'cbeta/p5a_validator'
111
- require 'cbeta/html_to_text'