gb-agencies 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 295e4e8a482d54452d379a541c88f8ec24ef6f0a638cafee69a18465efd828b7
4
+ data.tar.gz: 2340458950721bc39afb60e2f1f86cbdd121107f8185a426f8cf2a756ce94eec
5
+ SHA512:
6
+ metadata.gz: f0c1d0f639520880870a4b6eedb30518385c54a0b3e8a48f721c65841ca90b3ed790c306f484eaf7508e53041136ef8067cd4b69bdad28813be5f329cf28e4d1
7
+ data.tar.gz: 000b19110f2716e1a47438566baec9bf5a5dbfc72cdafed89119cf8097804c8bf2cc65064c267fac5de1c3c98ac0669fd918da24521df72f2f286cc18ff73e75
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cnccs.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ # gb-agencies
2
+ Gem to look up agency names for GB standards
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gb_agencies/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gb-agencies"
8
+ spec.version = GbAgencies::VERSION
9
+ spec.authors = ["Ribose Inc."]
10
+ spec.email = ["open.source@ribose.com"]
11
+
12
+ spec.summary = %q{Gem to look up agency names for GB standards.}
13
+ spec.description = %q{Gem to look up agency names for GB standards.}
14
+ spec.homepage = "https://github.com/riboseinc/gb-agencies"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "pry-byebug"
29
+ end
@@ -0,0 +1,6 @@
1
+ require "gb_agencies/version"
2
+ require "gb_agencies/gb_agencies"
3
+
4
+ module GbAgencies
5
+ end
6
+
@@ -0,0 +1,355 @@
1
+ module GbAgencies
2
+ class Agencies
3
+ def initialize(lang, labels = nil, issuer = nil)
4
+ @lang = lang
5
+ @labels = labels || { "PRC" => "", "industry_standard" => "",
6
+ "local_standard" => "", "enterprise_standard" => "",
7
+ "social_standard" => "" }
8
+ @issuer = issuer || "(not supplied)"
9
+ end
10
+
11
+ SECTOR = { "zh" => {
12
+ AQ: { industry: "安全生产", admin: "国家安全生产管理局" },
13
+ BB: { industry: "包装", admin: "国家发改委" },
14
+ CB: { industry: "船舶", admin: "国防科学工业委员会" },
15
+ CH: { industry: "测绘", admin: "国家测绘局" },
16
+ CJ: { industry: "城镇建设", admin: "建设部" },
17
+ CY: { industry: "新闻出版", admin: "国家新闻出版总署" },
18
+ DA: { industry: "档案", admin: "国家档案局" },
19
+ DB: { industry: "地震", admin: "中国地震局" },
20
+ DL: { industry: "电力", admin: "国家发改委" },
21
+ DZ: { industry: "地质矿产", admin: "国土资源部" },
22
+ EJ: { industry: "核工业", admin: "国防科学工业委员会" },
23
+ FZ: { industry: "纺织", admin: "国家发改委" },
24
+ GA: { industry: "公共安全", admin: "公安部" },
25
+ GH: { industry: "供销", admin: "中华全国供销合作总社" },
26
+ GM: { industry: "密码", admin: "国家密码管理局" },
27
+ GY: { industry: "广播电影电视", admin: "国家广播电影电视总局" },
28
+ HB: { industry: "航空", admin: "国防科学工业委员会" },
29
+ HG: { industry: "化工", admin: "国家发改委" },
30
+ HJ: { industry: "环境保护", admin: "国家环境保护总局" },
31
+ HS: { industry: "海关", admin: "海关总署" },
32
+ HY: { industry: "海洋", admin: "国家海洋局" },
33
+ JB: { industry: "机械", admin: "国家发改委" },
34
+ JC: { industry: "建材", admin: "国家发改委" },
35
+ JG: { industry: "建筑工业", admin: "建设部" },
36
+ JR: { industry: "金融", admin: "中国人民银行" },
37
+ JT: { industry: "交通", admin: "交通部" },
38
+ JY: { industry: "教育", admin: "教育部" },
39
+ LB: { industry: "旅游", admin: "国家旅游局" },
40
+ LD: { industry: "劳动和劳动安全", admin: "劳动和社会保障部" },
41
+ LS: { industry: "粮食", admin: "国家粮食局" },
42
+ LY: { industry: "林业", admin: "国家林业局" },
43
+ MH: { industry: "民用航空", admin: "中国民航管理总局" },
44
+ MT: { industry: "煤炭", admin: "国家发改委" },
45
+ MZ: { industry: "民政", admin: "民政部" },
46
+ NY: { industry: "农业", admin: "农业部" },
47
+ QB: { industry: "轻工", admin: "国家发改委" },
48
+ QC: { industry: "汽车", admin: "国家发改委" },
49
+ QJ: { industry: "航天", admin: "国防科学工业委员会" },
50
+ QX: { industry: "气象", admin: "中国气象局" },
51
+ SB: { industry: "国内贸易", admin: "商务部" },
52
+ SC: { industry: "水产", admin: "农业部" },
53
+ SH: { industry: "石油化工", admin: "国家发改委" },
54
+ SJ: { industry: "电子", admin: "信息产业部" },
55
+ SL: { industry: "水利", admin: "水利部" },
56
+ SN: { industry: "商检", admin: "国家质量监督检验检疫总局" },
57
+ SY: { industry: "石油天然气", admin: "国家发改委" },
58
+ TB: { industry: "铁道", admin: "铁道部" },
59
+ TD: { industry: "土地管理", admin: "国土资源部" },
60
+ TJ: { industry: "铁道交通", admin: "铁道部标准所" },
61
+ TY: { industry: "体育", admin: "国家体育总局" },
62
+ WB: { industry: "物资管理", admin: "国家发改委" },
63
+ WH: { industry: "文化", admin: "文化部" },
64
+ WJ: { industry: "兵工民品", admin: "国防科学工业委员会" },
65
+ WM: { industry: "外经贸", admin: "外经贸部科技司" },
66
+ WS: { industry: "卫生", admin: "卫生部" },
67
+ WW: { industry: "文物保护", admin: "国家文物局" },
68
+ XB: { industry: "稀土", admin: "国家发改委稀土办公室" },
69
+ YB: { industry: "黑色冶金", admin: "国家发改委" },
70
+ YC: { industry: "烟草", admin: "国家烟草专卖局" },
71
+ YD: { industry: "通信", admin: "信息产业部" },
72
+ YS: { industry: "有色冶金", admin: "国家发改委" },
73
+ YY: { industry: "医药", admin: "国家食品药品监督管理局" },
74
+ YZ: { industry: "邮政", admin: "国家邮政局" },
75
+ ZY: { industry: "中医药", admin: "国家中医药管理局" },
76
+ },
77
+ "en" => {
78
+ AQ: { industry: "Production Safety", admin: "State Administration of Work Safety" },
79
+ BB: { industry: "Packaging", admin: "China National Packaging Industry Corporation" },
80
+ CB: { industry: "Ships", admin: "National Defense Commission" },
81
+ CH: { industry: "Surveying and Mapping", admin: "National Bureau of Surveying and Mapping" },
82
+ CJ: { industry: "Town Construction", admin: "Ministry of Construction" },
83
+ CY: { industry: "News Publishing", admin: "State Press and Publication Administration" },
84
+ DA: { industry: "Archiving", admin: "National Archival Bureau" },
85
+ DB: { industry: "Seismology", admin: "National Seismological Bureau" },
86
+ DL: { industry: "Electricity", admin: "State Economic and Trade Commission" },
87
+ DZ: { industry: "Geological and Mineral Products", admin: "Ministry of Land and Resources" },
88
+ EJ: { industry: "Nuclear Industry", admin: "National Defense Commission" },
89
+ FZ: { industry: "Textile", admin: "State Economic and Trade Commission" },
90
+ GA: { industry: "Public Safety", admin: "Ministry of Public Security" },
91
+ GH: { industry: "Supply and Marketing", admin: "China Federation of Supply and Marketing Cooperatives" },
92
+ GM: { industry: "Cryptography", admin: "State Administration Of Cryptography" },
93
+ GY: { industry: "Radio, Film and Television", admin: "State Administration of Radio, Film and Television" },
94
+ HB: { industry: "Aviation", admin: "National Defense Commission" },
95
+ HG: { industry: "Chemical Industry", admin: "State Economic and Trade Commission" },
96
+ HJ: { industry: "Environmental Protection", admin: "State Environmental Protection Administration" },
97
+ HS: { industry: "Customs", admin: "General Administration of Customs" },
98
+ HY: { industry: "Oceanography", admin: "State Oceanic Administration" },
99
+ JB: { industry: "Mechanical Engineering", admin: "State Economic and Trade Commission" },
100
+ JC: { industry: "Building Materials", admin: "State Economic and Trade Commission" },
101
+ JG: { industry: "Construction Industry", admin: "Ministry of Construction" },
102
+ JR: { industry: "Financial", admin: "People’s Bank of China" },
103
+ JT: { industry: "Traffic", admin: "Ministry of Communications" },
104
+ JY: { industry: "Education", admin: "Ministry of Education" },
105
+ LB: { industry: "Tourism", admin: "National Tourism Bureau" },
106
+ LD: { industry: "Labor and Work Safety", admin: "Ministry of Labor and Social Security" },
107
+ LS: { industry: "Food", admin: "National Food Administration" },
108
+ LY: { industry: "Forestry", admin: "State Forestry Administration" },
109
+ MH: { industry: "Civil Aviation", admin: "Civil Aviation Administration" },
110
+ MT: { industry: "Coal", admin: "State Economic and Trade Commission" },
111
+ MZ: { industry: "Civil Affairs", admin: "Ministry of Civil Affairs" },
112
+ NY: { industry: "Agriculture", admin: "Ministry of Agriculture" },
113
+ QB: { industry: "Light Industry", admin: "State Economic and Trade Commission" },
114
+ QC: { industry: "Automotive", admin: "State Economic and Trade Commission" },
115
+ QJ: { industry: "Aerospace", admin: "National Defense Commission" },
116
+ QX: { industry: "Meteorological", admin: "China Meteorological Administration" },
117
+ SB: { industry: "Domestic Business", admin: "Ministry of Commerce" },
118
+ SC: { industry: "Aquatic Products", admin: "Ministry of Agriculture" },
119
+ SH: { industry: "Petrochemical", admin: "State Economic and Trade Commission" },
120
+ SJ: { industry: "Electronics", admin: "Ministry of Information Industry" },
121
+ SL: { industry: "Water Resources", admin: "Ministry of Water Resources" },
122
+ SN: { industry: "Inspection", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
123
+ SY: { industry: "Natural Gas", admin: "State Economic and Trade Commission" },
124
+ TB: { industry: "Rail Transport", admin: "Ministry of Railways" },
125
+ TD: { industry: "Land Management", admin: "Ministry of Land and Resources" },
126
+ TJ: { industry: "Railway Traffic", admin: "Ministry of Railways Standards" },
127
+ TY: { industry: "Sports", admin: "National Department of Sport" },
128
+ WB: { industry: "Materials Management", admin: "State Economic and Trade Commission" },
129
+ WH: { industry: "Culture", admin: "Ministry of Culture" },
130
+ WJ: { industry: "Ordnance", admin: "National Defense Commission" },
131
+ WM: { industry: "Foreign Trade", admin: "Ministry of Foreign Trade and Economic Cooperation" },
132
+ WS: { industry: "Health", admin: "Ministry of Health" },
133
+ WW: { industry: "Cultural Relics Protection", admin: "National Heritage Board" },
134
+ XB: { industry: "Rare Earths", admin: "State Planning Commission Rare Earths Office" },
135
+ YB: { industry: "Ferrous Metallurgy", admin: "State Economic and Trade Commission" },
136
+ YC: { industry: "Tobacco", admin: "State Tobacco Monopoly Bureau" },
137
+ YD: { industry: "Communication", admin: "Ministry of Information Industry" },
138
+ YS: { industry: "Non-Ferrous Metallurgy", admin: "State Economic and Trade Commission" },
139
+ YY: { industry: "Medicine", admin: "State Food and Drug Administration" },
140
+ YZ: { industry: "Postal", admin: "State Post Office" },
141
+ ZY: { industry: "Chinese Medicine", admin: "State Administration of Traditional Chinese Medicine" },
142
+ }
143
+ }.freeze
144
+
145
+ NATIONAL = {
146
+ "zh" => {
147
+ GB: { name: "中华人民共和国国家标准",
148
+ admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
149
+ "GB/T": { name: "中华人民共和国国家标准",
150
+ admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
151
+ "GB/Z": { name: "中华人民共和国国家标准化指导性技术文件",
152
+ admin: ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"] },
153
+ GBZ: { name: "中华人民共和国国家职业卫生标准", admin: "中华人民共和国卫生部" },
154
+ GJB: { name: "中华人民共和国国家军用标准", admin: "中国人民解放军装备总部" },
155
+ GBn: { name: "中华人民共和国国家内部标准", admin: "" },
156
+ GHZB: { name: "中华人民共和国国家环境质量标准", admin: "" }, GWKB: { name: "中华人民共和国国家环境保护标准", admin: "环境保护部" },
157
+ GWPB: { name: "中华人民共和国国家污染物排放标准", admin: "" },
158
+ JJF: { name: "中华人民共和国国家计量技术规范", admin: "中华人民共和国国家质量监督检验检疫总局" },
159
+ JJG: { name: "中华人民共和国国家计量检定规程", admin: "中华人民共和国国家质量监督检验检疫总局" },
160
+ },
161
+ "en" => {
162
+ GB: { name: "National standard",
163
+ admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
164
+ "GB/T": { name: "National standard (Recommended)",
165
+ admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
166
+ "GB/Z": { name: "Standardized guidelines",
167
+ admin: "General Administration of Quality Supervision, Inspection and Quarantine; Standardization Administration of China" },
168
+ GBZ: { name: "National occupational health standards", admin: "Ministry of Health" },
169
+ GJB: { name: "National military standards", admin: "Chinese People’s Liberation Army Equipment Headquarters" },
170
+ GBn: { name: "National internal standards", admin: "" },
171
+ GHZB: { name: "National environmental quality standards", admin: "" }, GWKB: { name: "National Environmental Protection Standards", admin: "Ministry of Environmental Protection" },
172
+ GWPB: { name: "National pollutant discharge standards", admin: "" },
173
+ JJF: { name: "National calibration specifications", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
174
+ JJG: { name: "National calibration verification regulations", admin: "General Administration of Quality Supervision, Inspection and Quarantine" },
175
+ }
176
+ }.freeze
177
+
178
+ LOCAL = {
179
+ "zh" => {
180
+ "11": "北京市",
181
+ "12": "天津市",
182
+ "13": "河北省",
183
+ "14": "山西省",
184
+ "15": "内蒙古自治区",
185
+ "21": "辽宁省",
186
+ "22": "吉林省",
187
+ "23": "黑龙江省",
188
+ "31": "上海市",
189
+ "32": "江苏省",
190
+ "33": "浙江省",
191
+ "34": "安徽省",
192
+ "35": "福建省",
193
+ "36": "江西省",
194
+ "37": "山东省",
195
+ "41": "河南省",
196
+ "42": "湖北省",
197
+ "43": "湖南省",
198
+ "44": "广东省",
199
+ "45": "广西壮族自治区",
200
+ "46": "海南省",
201
+ "50": "重庆市",
202
+ "51": "四川省",
203
+ "52": "贵州省",
204
+ "53": "云南省",
205
+ "54": "西藏自治区",
206
+ "61": "陕西省",
207
+ "62": "甘肃省",
208
+ "63": "青海省",
209
+ "64": "宁夏回族自治区",
210
+ "65": "新疆维吾尔自治区",
211
+ "71": "台湾省",
212
+ "81": "香港特别行政区",
213
+ "82": "澳门特别行政区",
214
+ },
215
+ "en" => {
216
+ "11": "Beijing City",
217
+ "12": "Tianjin",
218
+ "13": "Hebei Province",
219
+ "14": "Shanxi Province",
220
+ "15": "Inner Mongolia Autonomous Region",
221
+ "21": "Liaoning Province",
222
+ "22": "Jilin Province",
223
+ "23": "Heilongjiang Province",
224
+ "31": "Shanghai",
225
+ "32": "Jiangsu Province",
226
+ "33": "Zhejiang Province",
227
+ "34": "Anhui Province",
228
+ "35": "Fujian Province",
229
+ "36": "Jiangxi Province",
230
+ "37": "Shandong Province",
231
+ "41": "Henan Province",
232
+ "42": "Hubei Province",
233
+ "43": "Hunan Province",
234
+ "44": "Guangdong Province",
235
+ "45": "Guangxi Zhuang Autonomous Region",
236
+ "46": "Hainan",
237
+ "50": "Chongqing",
238
+ "51": "Sichuan Province",
239
+ "52": "Guizhou Province",
240
+ "53": "Yunnan Province",
241
+ "54": "Tibet Autonomous Region",
242
+ "61": "Shaanxi Province",
243
+ "62": "Gansu Province",
244
+ "63": "Qinghai Province",
245
+ "64": "Ningxia Hui Autonomous Region",
246
+ "65": "Xinjiang Uygur Autonomous Region",
247
+ "71": "Taiwan Province",
248
+ "81": "Hong Kong Special Administrative Region",
249
+ "82": "Macao Special Administrative Region",
250
+ }
251
+ }.freeze
252
+
253
+ def gb_mandate_suffix(prefix, mandate)
254
+ if prefix == "GB"
255
+ prefix += "/T" if mandate == "recommended"
256
+ prefix += "/Z" if mandate == "guide"
257
+ end
258
+ prefix
259
+ end
260
+
261
+ def mandate_suffix(prefix, mandate)
262
+ prefix += "/T" if mandate == "recommended"
263
+ prefix += "/Z" if mandate == "guide"
264
+ prefix
265
+ end
266
+
267
+ def standard_class(scope, prefix, mandate)
268
+ spc = @lang == "zh" ? "" : " "
269
+ case scope
270
+ when "national"
271
+ NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
272
+ :name) || "XXXX"
273
+ when "sector"
274
+ "#{@labels["PRC"]}#{spc}#{SECTOR&.dig(@lang, prefix.to_sym,
275
+ :industry) || 'XXXX'}#{spc}#{@labels["industry_standard"]}"
276
+ when "local"
277
+ "#{LOCAL&.dig(@lang, prefix.to_sym) || 'XXXX'}#{spc}#{@labels["local_standard"]}"
278
+ when "enterprise"
279
+ #issuer = get_metadata[:issuer]
280
+ "#{@issuer}#{spc}#{@labels["enterprise_standard"]}"
281
+ when "social-group" then @labels["social_standard"]
282
+ when "professional" then "PROFESSIONAL STANDARD" # TODO
283
+ end
284
+ end
285
+
286
+ # return agency name as single string
287
+ def standard_agency1(scope, prefix, mandate)
288
+ case scope
289
+ when "national"
290
+ ret = NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
291
+ :admin) || nil
292
+ ret = ret.join(" ") if ret && ret.is_a?(Array)
293
+ ret
294
+ when "sector"
295
+ SECTOR&.dig(@lang, prefix.to_sym, :admin) || nil
296
+ when "local"
297
+ LOCAL&.dig(@lang, prefix.to_sym) || nil
298
+ when "enterprise", "social-group"
299
+ @issuer || nil
300
+ when "professional" then "PROFESSIONAL STANDARD" # TODO
301
+ end
302
+ end
303
+
304
+ # return agency name, allowing arrays in output
305
+ def standard_agency(scope, prefix, mandate)
306
+ case scope
307
+ when "national"
308
+ NATIONAL&.dig(@lang, gb_mandate_suffix(prefix, mandate).to_sym,
309
+ :admin) || nil
310
+ when "sector"
311
+ SECTOR&.dig(@lang, prefix.to_sym, :admin) || nil
312
+ when "local"
313
+ "#{LOCAL&.dig(@lang, prefix.to_sym) || 'XXXX'}#{@labels["local_issuer"]}"
314
+ when "enterprise", "social-group"
315
+ @issuer || nil
316
+ when "professional" then "PROFESSIONAL STANDARD" # TODO
317
+ end
318
+ end
319
+
320
+ SCOPEPFX = {
321
+ :local => "DB",
322
+ "social-group".to_sym => "T",
323
+ :enterprise => "Q",
324
+ }.freeze
325
+
326
+ def docidentifier(scope, prefix, mandate, docyear, docnum)
327
+ dn = case scope
328
+ when "local"
329
+ "#{SCOPEPFX[scope.to_sym]}#{mandate_suffix(prefix, mandate)}/"\
330
+ "#{docnum}".gsub(%r{/([TZ])/}, "/\\1 ")
331
+ when "social-group", "enterprise"
332
+ "#{mandate_suffix(SCOPEPFX[scope.to_sym], mandate)}/"\
333
+ "#{prefix} #{docnum}"
334
+ else
335
+ "#{mandate_suffix(prefix, mandate)} #{docnum}"
336
+ end
337
+ dn += "—#{docyear}" if docyear
338
+ dn
339
+ end
340
+
341
+ def gbtype_validate(scope, prefix)
342
+ case scope
343
+ when "national"
344
+ NATIONAL.dig(@lang, prefix.to_sym) ||
345
+ warn("GB: #{prefix} is not a recognised national prefix")
346
+ when "sector"
347
+ SECTOR.dig(@lang, prefix.to_sym) ||
348
+ warn("GB: #{prefix} is not a recognised sector prefix")
349
+ when "local"
350
+ LOCAL.dig(@lang, prefix.to_sym) ||
351
+ warn("GB: #{prefix} is not a recognised local prefix")
352
+ end
353
+ end
354
+ end
355
+ end
@@ -0,0 +1,4 @@
1
+ module GbAgencies
2
+ VERSION = "0.0.1"
3
+ end
4
+
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gb-agencies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Gem to look up agency names for GB standards.
84
+ email:
85
+ - open.source@ribose.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - gb-agencies.gemspec
95
+ - lib/gb_agencies.rb
96
+ - lib/gb_agencies/gb_agencies.rb
97
+ - lib/gb_agencies/version.rb
98
+ homepage: https://github.com/riboseinc/gb-agencies
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.7.6
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Gem to look up agency names for GB standards.
122
+ test_files: []