pubid-iso 0.1.3 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/pubid/iso/identifier/french.rb +1 -1
- data/lib/pubid/iso/identifier/russian.rb +1 -1
- data/lib/pubid/iso/identifier.rb +38 -5
- data/lib/pubid/iso/parser.rb +62 -23
- data/lib/pubid/iso/urn.rb +28 -9
- data/lib/pubid/iso/version.rb +1 -1
- data/lib/pubid/iso.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a5dae3e19189666e2259f498813de7aa502ee7d68e1ec4567d493be74e3acb
|
4
|
+
data.tar.gz: f7834ffc05c7eaeec131aaef54804512d2e6d9e5494da8fe286e9730493dd7be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3319d163496c073813d052ecc873fb6f2f90e2351f1c8ac891c2c093c56a59d8405bc942f44b3f57e013f1f7149a7b3a35fc7b73ca3c58a0116ebce5e85b63
|
7
|
+
data.tar.gz: 3c72a547b1abaa06142caa496e8ce6d3769499954bfeaf3f9b01a470017bd3f38a1682be9e793f7eaab019ce202367feeda9d771f13ad14cf11b9cd901dafd42
|
@@ -3,7 +3,7 @@ module Pubid::Iso
|
|
3
3
|
def identifier(with_date, with_language_code)
|
4
4
|
if @type == "Guide"
|
5
5
|
"Guide #{originator}#{stage} #{number}#{part}#{iteration}"\
|
6
|
-
"#{with_date &&
|
6
|
+
"#{with_date && rendered_year || ''}#{edition}#{supplements}#{language(with_language_code)}"
|
7
7
|
else
|
8
8
|
super
|
9
9
|
end
|
@@ -20,7 +20,7 @@ module Pubid::Iso
|
|
20
20
|
def identifier(with_date, with_language_code)
|
21
21
|
if @type == "Guide"
|
22
22
|
"Руководство #{originator}#{stage} #{number}#{part}#{iteration}"\
|
23
|
-
"#{with_date &&
|
23
|
+
"#{with_date && rendered_year || ''}#{edition}#{supplements}#{language(with_language_code)}"
|
24
24
|
else
|
25
25
|
super
|
26
26
|
end
|
data/lib/pubid/iso/identifier.rb
CHANGED
@@ -4,7 +4,8 @@ module Pubid::Iso
|
|
4
4
|
:type, :year, :edition, :iteration, :supplements, :language,
|
5
5
|
:amendment, :amendment_version, :amendment_number,
|
6
6
|
:corrigendum, :corrigendum_version, :corrigendum_number,
|
7
|
-
:amendment_stage, :corrigendum_stage, :joint_document
|
7
|
+
:amendment_stage, :corrigendum_stage, :joint_document,
|
8
|
+
:tctype, :sctype, :wgtype, :tcnumber, :scnumber, :wgnumber
|
8
9
|
|
9
10
|
LANGUAGES = {
|
10
11
|
"ru" => "R",
|
@@ -67,8 +68,40 @@ module Pubid::Iso
|
|
67
68
|
end
|
68
69
|
|
69
70
|
def identifier(with_date, with_language_code)
|
70
|
-
|
71
|
-
"#{
|
71
|
+
if @tctype
|
72
|
+
"#{originator} #{tctype} #{tcnumber}#{sctype}#{wgtype} N#{number}"
|
73
|
+
else
|
74
|
+
"#{originator}#{type}#{stage} #{number}#{part}#{iteration}"\
|
75
|
+
"#{with_date && rendered_year || ''}#{edition}#{supplements}#{language(with_language_code)}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def tctype
|
80
|
+
return @tctype.join("/") if @tctype.is_a?(Array)
|
81
|
+
|
82
|
+
@tctype
|
83
|
+
end
|
84
|
+
|
85
|
+
# TC 184/SC/WG 4 - no wg number
|
86
|
+
# TC 184/SC 4/WG 12 - separate sc and wg number
|
87
|
+
def sctype
|
88
|
+
return unless @sctype
|
89
|
+
|
90
|
+
if @wgnumber || !@wgtype
|
91
|
+
"/#{@sctype} #{@scnumber}"
|
92
|
+
else
|
93
|
+
"/#{@sctype}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def wgtype
|
98
|
+
return unless @wgtype
|
99
|
+
|
100
|
+
if @wgnumber
|
101
|
+
"/#{@wgtype} #{@wgnumber}"
|
102
|
+
else
|
103
|
+
"/#{@wgtype} #{@scnumber}"
|
104
|
+
end
|
72
105
|
end
|
73
106
|
|
74
107
|
def copublisher
|
@@ -97,8 +130,8 @@ module Pubid::Iso
|
|
97
130
|
"-#{@part}" if @part
|
98
131
|
end
|
99
132
|
|
100
|
-
def
|
101
|
-
":#{@year}"
|
133
|
+
def rendered_year
|
134
|
+
@year && ":#{@year}"
|
102
135
|
end
|
103
136
|
|
104
137
|
def type
|
data/lib/pubid/iso/parser.rb
CHANGED
@@ -17,6 +17,9 @@ module Pubid::Iso
|
|
17
17
|
# Stage 50.60: PRF ("proof") (non-public)
|
18
18
|
# Stage 60: IS
|
19
19
|
class Parser < Parslet::Parser
|
20
|
+
rule(:space) { str(" ") }
|
21
|
+
rule(:space?) { space.maybe }
|
22
|
+
|
20
23
|
rule(:digits) do
|
21
24
|
match('\d').repeat(1)
|
22
25
|
end
|
@@ -51,18 +54,40 @@ module Pubid::Iso
|
|
51
54
|
).as(:type)
|
52
55
|
end
|
53
56
|
|
57
|
+
rule(:tctype) do
|
58
|
+
# tc-types
|
59
|
+
str("TC") | str("JTC") | str("PC") | str("IT") | str("CAB") | str("CASCO") | str("COPOLCO") |
|
60
|
+
str("COUNCIL") | str("CPSG") | str("CS") | str("DEVCO") | str("GA") | str("GAAB") | str("INFCO") |
|
61
|
+
str("ISOlutions") | str("ITN") | str("REMCO") | str("TMB") | str("TMBG") | str("WMO") |
|
62
|
+
str("DMT") | str("JCG") | str("SGPM") | str("ATMG") | str("CCCC") | str("CCCC-TG") | str("JDMT") |
|
63
|
+
str("JSAG") | str("JSCTF-TF") | str("JTCG") | str("JTCG-TF") | str("SAG_Acc") | str("SAG_CRMI") |
|
64
|
+
str("SAG_CRMI_CG") | str("SAG_ESG") | str("SAG_ESG_CG") | str("SAG_MRS") | str("SAG SF") | str("SAG SF_CG") |
|
65
|
+
str("SMCC") | str("STMG") | str("MENA STAR")
|
66
|
+
end
|
67
|
+
|
68
|
+
rule(:sctype) do
|
69
|
+
str("SC")
|
70
|
+
end
|
71
|
+
|
72
|
+
rule(:wgtype) do
|
73
|
+
str("AG") | str("AHG") | str("AhG") | str("WG") | str("JWG") | str("QC") | str("TF") |
|
74
|
+
str("PPC") | str("CAG") | str("WG SGDG") | str("WG SR") | str("STAR") | str("STTF") | str("TIG") |
|
75
|
+
str("CPAG") | str("CSC") | str("ITSAG") | str("CSC/FIN") | str("CSC/NOM") | str("CSC/OVE") |
|
76
|
+
str("CSC/SP") | str("CSC/FIN") | str("JAG")
|
77
|
+
end
|
78
|
+
|
54
79
|
rule(:year) do
|
55
80
|
match('\d').repeat(4, 4).as(:year)
|
56
81
|
end
|
57
82
|
|
58
83
|
rule(:part) do
|
59
|
-
(str("-") | str("/")) >>
|
60
|
-
(match['[\dA-Z]'] | str("-")).repeat(1).as(:part)
|
84
|
+
(str("-") | str("/")) >> space? >>
|
85
|
+
(str("Amd") | str("Cor")).absent? >> (match['[\dA-Z]'] | str("-")).repeat(1).as(:part)
|
61
86
|
end
|
62
87
|
|
63
88
|
rule(:originator) do
|
64
89
|
organization.as(:publisher) >>
|
65
|
-
(
|
90
|
+
(space? >> str("/") >> organization.as(:copublisher)).repeat
|
66
91
|
end
|
67
92
|
|
68
93
|
rule(:organization) do
|
@@ -75,7 +100,7 @@ module Pubid::Iso
|
|
75
100
|
end
|
76
101
|
|
77
102
|
rule(:edition) do
|
78
|
-
|
103
|
+
space >> ((str("ED") | str("Ed ") | str("Ed.")) >>
|
79
104
|
digits.as(:edition) | str("Ed").as(:edition))
|
80
105
|
end
|
81
106
|
|
@@ -85,18 +110,18 @@ module Pubid::Iso
|
|
85
110
|
|
86
111
|
rule(:amendment) do
|
87
112
|
(str("/") >> stage.as(:amendment_stage)).maybe >>
|
88
|
-
(str("/") |
|
113
|
+
(str("/") | space).maybe >>
|
89
114
|
(str("Amd") | str("AMD") | str("AM")).as(:amendment) >>
|
90
|
-
(
|
115
|
+
(space | str(".")) >>
|
91
116
|
digits.as(:amendment_version) >>
|
92
117
|
(str(":") >> digits.as(:amendment_number)).maybe
|
93
118
|
end
|
94
119
|
|
95
120
|
rule(:corrigendum) do
|
96
121
|
(str("/") >> stage.as(:corrigendum_stage)).maybe >>
|
97
|
-
(str("/") |
|
122
|
+
(str("/") | space).maybe >>
|
98
123
|
(str("Cor") | str("COR")).as(:corrigendum) >>
|
99
|
-
(
|
124
|
+
(space | str(".")) >>
|
100
125
|
digits.as(:corrigendum_version) >>
|
101
126
|
(str(":") >> digits.as(:corrigendum_number)).maybe
|
102
127
|
end
|
@@ -115,31 +140,45 @@ module Pubid::Iso
|
|
115
140
|
str("Guide") | str("GUIDE") | str("Руководство") | str("Руководства")
|
116
141
|
end
|
117
142
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
str("
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
143
|
+
# Parse technical committee documents
|
144
|
+
rule(:tc_document_body) do
|
145
|
+
(tctype.as(:tctype) >> str("/").maybe).repeat >> space >> digits.as(:tcnumber) >>
|
146
|
+
(str("/") >> (
|
147
|
+
((sctype.as(:sctype) >> space >> digits.as(:scnumber) >> str("/")).maybe >>
|
148
|
+
wgtype.as(:wgtype) >> space >> digits.as(:wgnumber)) |
|
149
|
+
(sctype.as(:sctype) >> (space | str("/") >> wgtype.as(:wgtype) >> space) >> digits.as(:scnumber))
|
150
|
+
)).maybe >>
|
151
|
+
str(" N") >> space? >> digits.as(:number)
|
152
|
+
end
|
153
|
+
|
154
|
+
rule(:std_document_body) do
|
155
|
+
(type | stage.as(:stage)).maybe >>
|
128
156
|
# for ISO/IEC WD TS 25025
|
129
|
-
|
157
|
+
space? >> ((stage.as(:stage) | type) >> space).maybe >>
|
130
158
|
digits.as(:number) >>
|
131
159
|
# for identifiers like ISO 5537/IDF 26
|
132
|
-
(str("|") >> (str("IDF") >>
|
160
|
+
(str("|") >> (str("IDF") >> space >> digits).as(:joint_document)).maybe >>
|
133
161
|
part.maybe >> iteration.maybe >>
|
134
|
-
(
|
162
|
+
(space? >> str(":") >> year).maybe >>
|
135
163
|
# stage before amendment
|
136
164
|
(
|
137
|
-
|
138
|
-
|
165
|
+
# stage before corrigendum
|
166
|
+
((amendment >> corrigendum.maybe) | corrigendum).maybe) >>
|
139
167
|
edition.maybe >>
|
140
168
|
language.maybe
|
141
169
|
end
|
142
170
|
|
171
|
+
rule(:identifier) do
|
172
|
+
str("Fpr").as(:stage).maybe >>
|
173
|
+
# Withdrawn e.g: WD/ISO 10360-5:2000
|
174
|
+
str("WD/").maybe >>
|
175
|
+
# for French and Russian PubIDs starting with Guide type
|
176
|
+
(guide_prefix.as(:type) >> space).maybe >>
|
177
|
+
(stage.as(:stage) >> space).maybe >>
|
178
|
+
originator >> (space | str("/")) >>
|
179
|
+
(tc_document_body | std_document_body)
|
180
|
+
end
|
181
|
+
|
143
182
|
rule(:root) { identifier }
|
144
183
|
end
|
145
184
|
end
|
data/lib/pubid/iso/urn.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
module Pubid::Iso
|
2
|
-
class Urn
|
3
|
-
attr_accessor :number, :publisher, :copublisher, :stage, :substage, :part,
|
4
|
-
:type, :year, :edition, :iteration, :supplements, :language,
|
5
|
-
:amendment, :amendment_version, :amendment_number,
|
6
|
-
:corrigendum, :corrigendum_version, :corrigendum_number,
|
7
|
-
:amendment_stage, :corrigendum_stage, :joint_document
|
8
|
-
|
2
|
+
class Urn < Identifier
|
9
3
|
|
10
4
|
STAGES = { PWI: 0,
|
11
5
|
NP: 10,
|
@@ -26,7 +20,33 @@ module Pubid::Iso
|
|
26
20
|
# [[":" status] ":" edition]
|
27
21
|
# [":" docversion] [":" language]
|
28
22
|
|
29
|
-
|
23
|
+
if tctype
|
24
|
+
"urn:iso:doc:#{originator}:#{tctype.downcase}:#{tcnumber}#{sctype}#{wgtype}:#{number}"
|
25
|
+
else
|
26
|
+
"urn:iso:std:#{originator}#{type}:#{number}#{part}#{stage}#{edition}#{supplement}#{language}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def tctype
|
31
|
+
return @tctype.join(":") if @tctype.is_a?(Array)
|
32
|
+
|
33
|
+
@tctype
|
34
|
+
end
|
35
|
+
|
36
|
+
def sctype
|
37
|
+
return unless @sctype
|
38
|
+
|
39
|
+
":#{@sctype.downcase}:#{@scnumber}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def wgtype
|
43
|
+
return unless @wgtype
|
44
|
+
|
45
|
+
if @wgnumber
|
46
|
+
":#{@wgtype.downcase}:#{@wgnumber}"
|
47
|
+
else
|
48
|
+
":#{@wgtype.downcase}"
|
49
|
+
end
|
30
50
|
end
|
31
51
|
|
32
52
|
def part
|
@@ -70,7 +90,6 @@ module Pubid::Iso
|
|
70
90
|
def type
|
71
91
|
# type = "data" / "guide" / "isp" / "iwa" /
|
72
92
|
# "pas" / "r" / "tr" / "ts" / "tta"
|
73
|
-
|
74
93
|
if @type
|
75
94
|
":#{@type.downcase}"
|
76
95
|
end
|
data/lib/pubid/iso/version.rb
CHANGED
data/lib/pubid/iso.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
require_relative "iso/errors"
|
12
12
|
require_relative "iso/parser"
|
13
13
|
require_relative "iso/transformer"
|
14
|
-
require_relative "iso/urn"
|
15
14
|
require_relative "iso/identifier"
|
16
15
|
require_relative "iso/identifier/french"
|
17
16
|
require_relative "iso/identifier/russian"
|
17
|
+
require_relative "iso/urn"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubid-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|