pubid-iso 1.15.6 → 1.15.9
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/README.adoc +24 -0
- data/lib/pubid/iso/identifier/base.rb +4 -2
- data/lib/pubid/iso/identifier/supplement.rb +4 -1
- data/lib/pubid/iso/parser.rb +1 -1
- data/lib/pubid/iso/renderer/base.rb +7 -2
- data/lib/pubid/iso/renderer/supplement.rb +16 -8
- data/lib/pubid/iso/transformer.rb +28 -13
- data/lib/pubid/iso/version.rb +1 -1
- data/update_codes.yaml +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f281981e42f4fe123fb11766a42a161efe7ea7ca67177217cb7b0e25abf605f
|
|
4
|
+
data.tar.gz: db7553520345a7860be01d909404dd208355f62bd6c3ea89debf80c259c7ca24
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a892b598fb4be0cb9e2e59bff00f51a55138db6071db1e8d17a9bafc4acdef9afdb16cc48a8cc9be4fe2afa4f5293034e3b26ab4bdf994bc85915721ef8747ce
|
|
7
|
+
data.tar.gz: f434672ef4e38510f2d8af2c40104e859b7d9e9a2c885063c3555e2c3d4cf349fc89f6f1c7da42b915993c18e76f374212e20f1765a250b85a60a14fd5bf2e95
|
data/README.adoc
CHANGED
|
@@ -162,6 +162,30 @@ to see all available options.
|
|
|
162
162
|
=> "ISO 8601-1:2019/DAM 1"
|
|
163
163
|
----
|
|
164
164
|
|
|
165
|
+
=== Annotated rendering
|
|
166
|
+
|
|
167
|
+
Use `to_s(annotated: true)` to wrap each semantic component of the identifier in
|
|
168
|
+
an HTML `<span>` tag with a CSS class, useful for styling in web applications.
|
|
169
|
+
|
|
170
|
+
[source,ruby]
|
|
171
|
+
----
|
|
172
|
+
> pubid = Pubid::Iso::Identifier.parse("ISO 1234-1:2013")
|
|
173
|
+
> pubid.to_s(annotated: true)
|
|
174
|
+
=> '<span class="publisher">ISO</span> <span class="docnumber">1234</span>-<span class="part">1</span>:<span class="year">2013</span>'
|
|
175
|
+
----
|
|
176
|
+
|
|
177
|
+
With copublisher and document type:
|
|
178
|
+
|
|
179
|
+
[source,ruby]
|
|
180
|
+
----
|
|
181
|
+
> pubid = Pubid::Iso::Identifier.parse("ISO/IEC TR 2131-1:2013")
|
|
182
|
+
> pubid.to_s(annotated: true)
|
|
183
|
+
=> '<span class="publisher">ISO/IEC</span> <span class="doctype">TR</span> <span class="docnumber">2131</span>-<span class="part">1</span>:<span class="year">2013</span>'
|
|
184
|
+
----
|
|
185
|
+
|
|
186
|
+
The `annotated:` option can be combined with other `to_s` options like `format:`,
|
|
187
|
+
`lang:`, etc.
|
|
188
|
+
|
|
165
189
|
=== Using language specific rendering
|
|
166
190
|
[source,ruby]
|
|
167
191
|
----
|
|
@@ -143,7 +143,8 @@ module Pubid::Iso
|
|
|
143
143
|
month: supplement[:month],
|
|
144
144
|
stage: supplement[:typed_stage], edition: supplement[:edition],
|
|
145
145
|
iteration: supplement[:iteration], type: supplement[:type] || !supplement[:typed_stage] && :sup,
|
|
146
|
-
publisher: supplement[:publisher]&.to_s, base: Identifier.create(**base_params)
|
|
146
|
+
publisher: supplement[:publisher]&.to_s, base: Identifier.create(**base_params),
|
|
147
|
+
separator: ([" + ", ", "].include?(supplement[:separator]&.to_s) ? supplement[:separator].to_s : nil)
|
|
147
148
|
)
|
|
148
149
|
end
|
|
149
150
|
end
|
|
@@ -265,11 +266,12 @@ module Pubid::Iso
|
|
|
265
266
|
# :ref_undated -- reference undated: no language code + short form (DAM) + undated
|
|
266
267
|
# :ref_undated_long -- reference undated long: 1 letter language code + long form (DAmd) + undated
|
|
267
268
|
# @return [String] pubid identifier
|
|
268
|
-
def to_s(lang: nil, with_edition: false, with_prf: false, format: :ref_dated_long)
|
|
269
|
+
def to_s(lang: nil, with_edition: false, with_prf: false, format: :ref_dated_long, annotated: false)
|
|
269
270
|
options = resolve_format(format)
|
|
270
271
|
options[:with_edition] = with_edition
|
|
271
272
|
options[:with_prf] = with_prf
|
|
272
273
|
options[:language] = lang
|
|
274
|
+
options[:annotated] = annotated
|
|
273
275
|
|
|
274
276
|
self.class.get_renderer_class.new(to_h(deep: false)).render(**options) +
|
|
275
277
|
render_joint_document(@joint_document) + render_all_parts
|
data/lib/pubid/iso/parser.rb
CHANGED
|
@@ -119,7 +119,7 @@ module Pubid::Iso
|
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
rule(:supplement) do
|
|
122
|
-
((str("/") | space).maybe >>
|
|
122
|
+
((str(" + ") | str(", ") | str("/") | space).as(:separator).maybe >>
|
|
123
123
|
(((stage.as(:typed_stage) >> space).maybe >> supplements.as(:type)) |
|
|
124
124
|
staged_supplement.as(:typed_stage)) >>
|
|
125
125
|
(space | str(".")).repeat(1).maybe >>
|
|
@@ -32,10 +32,11 @@ module Pubid::Iso::Renderer
|
|
|
32
32
|
# Render identifier
|
|
33
33
|
# @param with_edition [Boolean] include edition in output
|
|
34
34
|
# @see Pubid::Core::Renderer::Base for another options
|
|
35
|
-
def render(with_edition: true, with_language_code: :iso, with_date: true, **args)
|
|
35
|
+
def render(with_edition: true, with_language_code: :iso, with_date: true, annotated: false, **args)
|
|
36
36
|
render_base_identifier(**args.merge({ with_date: with_date,
|
|
37
37
|
with_language_code: with_language_code,
|
|
38
|
-
with_edition: with_edition
|
|
38
|
+
with_edition: with_edition,
|
|
39
|
+
annotated: annotated })) +
|
|
39
40
|
@prerendered_params[:language].to_s
|
|
40
41
|
end
|
|
41
42
|
|
|
@@ -54,6 +55,10 @@ module Pubid::Iso::Renderer
|
|
|
54
55
|
def render_identifier(params, opts)
|
|
55
56
|
stage = params.key?(:stage) ? postrender_stage(params[:stage], opts, params) : ""
|
|
56
57
|
type = render_type_prefix(params, opts)
|
|
58
|
+
if opts[:annotated]
|
|
59
|
+
stage = annotate_value(:stage, stage) if stage && !stage.to_s.empty?
|
|
60
|
+
type = annotate_value(:typed_stage, type) if type && !type.to_s.empty?
|
|
61
|
+
end
|
|
57
62
|
"%<publisher>s#{stage}#{type} %<number>s%<part>s%<iteration>s%<year>s%" \
|
|
58
63
|
"<amendments>s%<corrigendums>s%<addendum>s%<edition>s" % params
|
|
59
64
|
end
|
|
@@ -7,14 +7,14 @@ module Pubid::Iso::Renderer
|
|
|
7
7
|
# Render identifier
|
|
8
8
|
# @param with_edition [Boolean] include edition in output
|
|
9
9
|
# @see Pubid::Core::Renderer::Base for another options
|
|
10
|
-
def render(with_edition: true, with_language_code: :iso, with_date: true, **args) # rubocop:disable Metrics/MethodLength
|
|
11
|
-
@params[:base].to_s(lang: args[:language], with_edition: with_edition) +
|
|
10
|
+
def render(with_edition: true, with_language_code: :iso, with_date: true, annotated: false, **args) # rubocop:disable Metrics/MethodLength
|
|
11
|
+
@params[:base].to_s(lang: args[:language], with_edition: with_edition, annotated: annotated) +
|
|
12
12
|
super(
|
|
13
13
|
with_edition: with_edition, with_language_code: with_language_code, with_date: with_date,
|
|
14
|
-
base_type: @params[:base].type[:key],
|
|
14
|
+
annotated: annotated, base_type: @params[:base].type[:key],
|
|
15
15
|
**args
|
|
16
16
|
) +
|
|
17
|
-
if @params[:base].language
|
|
17
|
+
if !@params[:language] && @params[:base].language
|
|
18
18
|
render_language(@params[:base].language,
|
|
19
19
|
{ with_language_code: with_language_code }, nil).to_s
|
|
20
20
|
else
|
|
@@ -28,18 +28,26 @@ module Pubid::Iso::Renderer
|
|
|
28
28
|
stage = params[:stage]
|
|
29
29
|
|
|
30
30
|
if params[:stage].instance_of?(Pubid::Core::Stage) && !params[:stage].to_s(with_prf: opts[:with_prf]).empty?
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
stage_str = params[:stage].to_s(with_prf: opts[:with_prf])
|
|
32
|
+
if stage_str == "IS"
|
|
33
|
+
stage = ""
|
|
34
|
+
else
|
|
35
|
+
type_prefix = " #{type_prefix}"
|
|
36
|
+
stage = stage_str
|
|
37
|
+
end
|
|
33
38
|
end
|
|
34
39
|
|
|
40
|
+
sep = params[:separator]
|
|
41
|
+
sep = "/" if sep.nil? || sep.empty?
|
|
42
|
+
|
|
35
43
|
if instance_of?(Supplement)
|
|
36
44
|
if opts[:base_type] == :dir
|
|
37
45
|
"%<stage>s%<publisher>s SUP%<number>s%<part>s%<iteration>s%<year>s%<month>s%<edition>s" % params
|
|
38
46
|
else
|
|
39
|
-
"
|
|
47
|
+
"#{sep}#{stage}#{type_prefix}%<number>s%<part>s%<iteration>s%<year>s%<edition>s" % params
|
|
40
48
|
end
|
|
41
49
|
else
|
|
42
|
-
"
|
|
50
|
+
"#{sep}#{stage}#{type_prefix}%<number>s%<part>s%<iteration>s%<year>s%<edition>s" % params
|
|
43
51
|
end
|
|
44
52
|
end
|
|
45
53
|
|
|
@@ -10,8 +10,14 @@ module Pubid::Iso
|
|
|
10
10
|
context[:root]
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
rule(edition:
|
|
14
|
-
|
|
13
|
+
rule(edition: subtree(:edition)) do |context|
|
|
14
|
+
if context[:edition].to_s == "Ed"
|
|
15
|
+
{ edition: "1" }
|
|
16
|
+
elsif context[:edition].is_a?(Hash)
|
|
17
|
+
{ edition: context[:edition].transform_values(&:to_s) }
|
|
18
|
+
else
|
|
19
|
+
context
|
|
20
|
+
end
|
|
15
21
|
end
|
|
16
22
|
|
|
17
23
|
rule(stage: subtree(:stage)) do |context|
|
|
@@ -26,15 +32,20 @@ module Pubid::Iso
|
|
|
26
32
|
context[:supplements] =
|
|
27
33
|
context[:supplements].map do |supplement|
|
|
28
34
|
if supplement[:typed_stage]
|
|
29
|
-
supplement
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if supplement[:typed_stage] == "published"
|
|
36
|
+
supplement[:typed_stage] = "IS"
|
|
37
|
+
supplement.merge(convert_urn_sup_stage_code(supplement))
|
|
38
|
+
else
|
|
39
|
+
supplement.merge(
|
|
40
|
+
case supplement[:typed_stage]
|
|
41
|
+
when "PDAM" then { typed_stage: "CD", type: "Amd" }
|
|
42
|
+
when "pDCOR" then { typed_stage: "CD", type: "Cor" }
|
|
43
|
+
# when "DAD" then { typed_stage: "WD", type: "Amd" }
|
|
44
|
+
when "draft" then convert_urn_sup_draft_type supplement[:type]
|
|
45
|
+
else convert_urn_sup_stage_code(supplement)
|
|
46
|
+
end,
|
|
47
|
+
)
|
|
48
|
+
end
|
|
38
49
|
else
|
|
39
50
|
case supplement[:type]
|
|
40
51
|
when "Addendum" then supplement.merge({ type: "Add" })
|
|
@@ -141,8 +152,12 @@ module Pubid::Iso
|
|
|
141
152
|
|
|
142
153
|
def self.convert_urn_sup_stage_code(sup)
|
|
143
154
|
stage_type = convert_urn_sup_type(sup[:type])
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
if /\A[\d.]+\z/.match?(sup[:typed_stage].to_s)
|
|
156
|
+
stage_type[:typed_stage] = sup[:typed_stage].to_s
|
|
157
|
+
else
|
|
158
|
+
abbr = convert_stage_code(sup[:typed_stage])
|
|
159
|
+
stage_type[:typed_stage] = abbr if abbr
|
|
160
|
+
end
|
|
146
161
|
stage_type
|
|
147
162
|
end
|
|
148
163
|
|
data/lib/pubid/iso/version.rb
CHANGED
data/update_codes.yaml
CHANGED
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: 1.15.
|
|
4
|
+
version: 1.15.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: parslet
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.15.
|
|
33
|
+
version: 1.15.9
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.15.
|
|
40
|
+
version: 1.15.9
|
|
41
41
|
description: Library to generate, parse and manipulate ISO PubID.
|
|
42
42
|
email:
|
|
43
43
|
- open.source@ribose.com
|