pubid-nist 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pubid/nist/addendum.rb +21 -0
- data/lib/pubid/nist/edition.rb +1 -1
- data/lib/pubid/nist/identifier.rb +9 -11
- data/lib/pubid/nist/nist_tech_pubs.rb +7 -1
- data/lib/pubid/nist/parser.rb +12 -11
- data/lib/pubid/nist/parsers/default.rb +6 -5
- data/lib/pubid/nist/parsers/nbs_circ.rb +1 -1
- data/lib/pubid/nist/parsers/nbs_crpl.rb +2 -2
- data/lib/pubid/nist/parsers/nbs_csm.rb +1 -1
- data/lib/pubid/nist/parsers/nbs_fips.rb +2 -1
- data/lib/pubid/nist/parsers/nbs_sp.rb +1 -1
- data/lib/pubid/nist/publisher.rb +1 -5
- data/lib/pubid/nist/renderer/addendum.rb +20 -0
- data/lib/pubid/nist/renderer/base.rb +200 -0
- data/lib/pubid/nist/stage.rb +1 -1
- data/lib/pubid/nist/update.rb +1 -1
- data/lib/pubid/nist/version.rb +1 -1
- data/lib/pubid/nist.rb +3 -1
- data/update_codes.yaml +1 -1
- metadata +7 -5
- data/lib/pubid/nist/renderer.rb +0 -213
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: effbdd3a2d023969c91461079bcb6b2ac8fc24d1260a7655cdacaf50858a6084
|
4
|
+
data.tar.gz: '07885e3191c545d7f5796c5ad431094af88a4334fa12b3f97357c8dbebc71d6f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5612165d60141ecccaf5c757f5cf30a8eb7d9dd4c62855d44d4a67489b7ff32216fdc81baa5f8d17fd8b5a58bfe38602421083a0ac23e36f2cc7bda62bb5206
|
7
|
+
data.tar.gz: d5b169cb694230dbb1d9667a6c38d7b7b0a900dac783412364026ea3d58a330d6045440a26770f01a63d3afb805f2d86907bdf42171e57b5e0258363a89bf226
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
module Pubid::Nist
|
3
|
+
class Addendum < Identifier
|
4
|
+
def_delegators 'Pubid::Nist::Addendum', :type
|
5
|
+
|
6
|
+
attr_accessor :base
|
7
|
+
|
8
|
+
def initialize(base:, number: nil)
|
9
|
+
@number = number
|
10
|
+
@base = base
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.type
|
14
|
+
{ key: :add, title: "Addendum" }
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_renderer_class
|
18
|
+
Renderer::Addendum
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/pubid/nist/edition.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "json"
|
4
|
+
require "forwardable"
|
4
5
|
|
5
6
|
UPDATE_CODES = YAML.load_file(File.join(File.dirname(__FILE__), "../../../update_codes.yaml"))
|
6
7
|
|
7
8
|
module Pubid::Nist
|
8
9
|
class Identifier < Pubid::Core::Identifier::Base
|
10
|
+
extend Forwardable
|
9
11
|
attr_accessor :serie, :code, :revision, :publisher, :version, :volume,
|
10
12
|
:part, :addendum, :stage, :translation,
|
11
13
|
:edition, :supplement, :update,
|
@@ -73,7 +75,7 @@ module Pubid::Nist
|
|
73
75
|
|
74
76
|
# @param without_edition [Boolean] render pubid without rendering edition
|
75
77
|
def to_s(format = :short, without_edition: false)
|
76
|
-
self.class.get_renderer_class.new(to_h).render(format: format, without_edition: without_edition)
|
78
|
+
self.class.get_renderer_class.new(to_h(deep: false)).render(format: format, without_edition: without_edition)
|
77
79
|
end
|
78
80
|
|
79
81
|
def to_json(*args)
|
@@ -98,11 +100,6 @@ module Pubid::Nist
|
|
98
100
|
new(**opts)
|
99
101
|
end
|
100
102
|
|
101
|
-
# def transform(params)
|
102
|
-
# identifier_params = get_transformer_class.new.apply(params)
|
103
|
-
#
|
104
|
-
# Identifier.create(**identifier_params)
|
105
|
-
# end
|
106
103
|
def transform(params)
|
107
104
|
# run transform through each element,
|
108
105
|
# like running transformer.apply(number: 1) and transformer.apply(year: 1999)
|
@@ -114,11 +111,12 @@ module Pubid::Nist
|
|
114
111
|
get_transformer_class.new.apply({ k => v }, params)
|
115
112
|
end.inject({}, :merge)
|
116
113
|
|
114
|
+
if identifier_params[:addendum]
|
115
|
+
return Addendum.new(base: new(
|
116
|
+
**identifier_params.dup.tap { |h| h.delete(:addendum) }
|
117
|
+
), **identifier_params[:addendum])
|
118
|
+
end
|
117
119
|
|
118
|
-
# identifier_params = params.map do |k, v|
|
119
|
-
# get_transformer_class.new.apply({k => v}, params).to_a.first
|
120
|
-
# end.compact.to_h
|
121
|
-
#
|
122
120
|
new(**identifier_params)
|
123
121
|
end
|
124
122
|
|
@@ -131,7 +129,7 @@ module Pubid::Nist
|
|
131
129
|
end
|
132
130
|
|
133
131
|
def get_renderer_class
|
134
|
-
Renderer
|
132
|
+
Renderer::Base
|
135
133
|
end
|
136
134
|
end
|
137
135
|
end
|
@@ -45,7 +45,13 @@ module Pubid::Nist
|
|
45
45
|
def parse_docid(doc)
|
46
46
|
id = doc.at("publisher_item/item_number", "publisher_item/identifier")
|
47
47
|
&.text&.sub(%r{^/}, "")
|
48
|
-
|
48
|
+
if id == "NBS BH 10"
|
49
|
+
# XXX: "doi" attribute is missing for doi_data
|
50
|
+
doi = "NBS.BH.10"
|
51
|
+
else
|
52
|
+
doi = doc.at("doi_data/doi").text.gsub("10.6028/", "")
|
53
|
+
end
|
54
|
+
|
49
55
|
title = doc.at("titles/title").text
|
50
56
|
title += " #{doc.at('titles/subtitle').text}" if doc.at("titles/subtitle")
|
51
57
|
case doi
|
data/lib/pubid/nist/parser.rb
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
module Pubid::Nist
|
2
|
-
class Parser <
|
2
|
+
class Parser < Pubid::Core::Parser
|
3
3
|
attr_accessor :parsed
|
4
4
|
|
5
5
|
rule(:series) do
|
6
|
-
((SERIES["long"].keys
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
(acc.is_a?(String) ? str(acc) : acc) | str(s)
|
11
|
-
end).as(:series) |
|
12
|
-
(SERIES["mr"].values.reduce do |acc, s|
|
13
|
-
(acc.is_a?(String) ? str(acc) : acc) | str(s)
|
14
|
-
end).as(:series_mr)) >> any.repeat.as(:remaining)
|
6
|
+
(array_to_str(SERIES["long"].keys.sort_by(&:length).reverse.flatten).as(:series) |
|
7
|
+
array_to_str(SERIES["mr"].values).as(:series_mr) |
|
8
|
+
(str("NIST ") >> array_to_str(SERIES["long"].keys.sort_by(&:length).reverse.flatten).as(:series))) >>
|
9
|
+
any.repeat.as(:remaining)
|
15
10
|
end
|
16
11
|
|
17
12
|
root(:series)
|
@@ -24,7 +19,13 @@ module Pubid::Nist
|
|
24
19
|
SERIES["mr"].key(parsed[:series_mr].to_s)
|
25
20
|
end
|
26
21
|
parser = find_parser(series)
|
27
|
-
|
22
|
+
begin
|
23
|
+
parsed = parser.new.parse(parsed[:remaining].to_s)
|
24
|
+
rescue Parslet::ParseFailed
|
25
|
+
# for PubID 1.0 identifier series specific parser might fail,
|
26
|
+
# so parse using Default parser which is comply with PubID 1.0
|
27
|
+
parsed = Parsers::Default.new.parse(parsed[:remaining].to_s)
|
28
|
+
end
|
28
29
|
parsed.is_a?(Array) ? parsed << { series: series } : parsed.merge({ series: series })
|
29
30
|
end
|
30
31
|
|
@@ -19,11 +19,11 @@ module Pubid::Nist
|
|
19
19
|
end
|
20
20
|
|
21
21
|
rule(:supplement) do
|
22
|
-
(str("supp") | str("sup")) >> match('\d').repeat.as(:supplement)
|
22
|
+
(str("supp") | str("sup")) >> match('[A-Z\d]').repeat.as(:supplement)
|
23
23
|
end
|
24
24
|
|
25
25
|
rule(:errata) do
|
26
|
-
str("-").maybe >> str("errata").as(:errata)
|
26
|
+
str("-").maybe >> (str("errata") | str("err")).as(:errata)
|
27
27
|
end
|
28
28
|
|
29
29
|
rule(:index) do
|
@@ -40,7 +40,7 @@ module Pubid::Nist
|
|
40
40
|
end
|
41
41
|
|
42
42
|
rule(:stage) do
|
43
|
-
(space >> (array_to_str(STAGES["id"].keys + STAGES["id"].keys.map(&:upcase)).as(:id) >>
|
43
|
+
((space | dot) >> (array_to_str(STAGES["id"].keys + STAGES["id"].keys.map(&:upcase)).as(:id) >>
|
44
44
|
array_to_str(STAGES["type"].keys + STAGES["type"].keys.map(&:upcase)).as(:type)).as(:stage))
|
45
45
|
end
|
46
46
|
|
@@ -68,7 +68,7 @@ module Pubid::Nist
|
|
68
68
|
rule(:part_prefixes) { str("pt") | str("p") }
|
69
69
|
|
70
70
|
rule(:part) do
|
71
|
-
part_prefixes >> digits.as(:part)
|
71
|
+
part_prefixes >> (digits >> (str("-") >> digits).maybe).as(:part)
|
72
72
|
end
|
73
73
|
|
74
74
|
rule(:revision) do
|
@@ -99,7 +99,8 @@ module Pubid::Nist
|
|
99
99
|
end
|
100
100
|
|
101
101
|
rule(:addendum) do
|
102
|
-
(str("-add") | str(".add
|
102
|
+
(str("-add") | str(".add") | str(" Add.")) >>
|
103
|
+
(str(" ") | str("-")).maybe >> (digits | str("")).as(:number).as(:addendum)
|
103
104
|
end
|
104
105
|
|
105
106
|
rule(:section) do
|
@@ -2,11 +2,11 @@ module Pubid::Nist
|
|
2
2
|
module Parsers
|
3
3
|
class NbsCrpl < Default
|
4
4
|
rule(:first_report_number) do
|
5
|
-
(digits >> str("-m").maybe).as(:first_report_number)
|
5
|
+
(digits >> (str("-m") | str("-M")).maybe).as(:first_report_number)
|
6
6
|
end
|
7
7
|
|
8
8
|
rule(:part) do
|
9
|
-
str("_") >> (digits >> str("-") >> digits).as(:part)
|
9
|
+
(str("_") | str("pt")) >> (digits >> str("-") >> digits).as(:part)
|
10
10
|
end
|
11
11
|
|
12
12
|
rule(:supplement) do
|
@@ -7,7 +7,8 @@ module Pubid::Nist
|
|
7
7
|
year_digits.as(:edition_year) |
|
8
8
|
(month_letters.as(:edition_month) >> match('\d').repeat(2, 2).as(:edition_day) >>
|
9
9
|
str("/") >> year_digits.as(:edition_year))
|
10
|
-
)
|
10
|
+
) |
|
11
|
+
(str("e") >> year_digits.as(:edition_year) >> month_digits.as(:edition_month).maybe)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/pubid/nist/publisher.rb
CHANGED
@@ -2,7 +2,7 @@ PUBLISHERS = YAML.load_file(File.join(File.dirname(__FILE__),
|
|
2
2
|
"../../../publishers.yaml"))
|
3
3
|
|
4
4
|
module Pubid::Nist
|
5
|
-
class Publisher
|
5
|
+
class Publisher < Pubid::Core::Entity
|
6
6
|
attr_accessor :publisher
|
7
7
|
|
8
8
|
def initialize(publisher:)
|
@@ -17,10 +17,6 @@ module Pubid::Nist
|
|
17
17
|
PUBLISHERS[format.to_s][@publisher]
|
18
18
|
end
|
19
19
|
|
20
|
-
def ==(other)
|
21
|
-
other.publisher == @publisher
|
22
|
-
end
|
23
|
-
|
24
20
|
def self.publishers_keys
|
25
21
|
PUBLISHERS["long"].keys
|
26
22
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Pubid::Nist::Renderer
|
4
|
+
class Addendum < Base
|
5
|
+
def render_identifier(params, opts)
|
6
|
+
# = "%{base}" % params
|
7
|
+
result = params[:base].to_s(opts[:format])
|
8
|
+
case opts[:format]
|
9
|
+
when :long
|
10
|
+
"Addendum to #{result}"
|
11
|
+
when :abbrev
|
12
|
+
"Add. to #{result}"
|
13
|
+
when :short
|
14
|
+
"#{result} Add."
|
15
|
+
when :mr
|
16
|
+
"#{result}.add-1"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
module Pubid::Nist
|
2
|
+
module Renderer
|
3
|
+
class Base < Pubid::Core::Renderer::Base
|
4
|
+
def render_base_identifier(**opts)
|
5
|
+
prerender(**opts)
|
6
|
+
|
7
|
+
render_identifier(@prerendered_params, opts)
|
8
|
+
end
|
9
|
+
|
10
|
+
def render_identifier(params, opts)
|
11
|
+
case opts[:format]
|
12
|
+
when :short, :mr
|
13
|
+
"%{serie}%{code}%{volume}%{part}%{edition}%{revision}%{version}"\
|
14
|
+
"%{supplement}%{section}%{appendix}%{errata}%{index}%{insert}%{update}"\
|
15
|
+
"%{stage}%{translation}" % params
|
16
|
+
else
|
17
|
+
"%{serie}%{stage}%{code}%{volume}%{part}%{edition}%{revision}%{version}"\
|
18
|
+
"%{supplement}%{section}%{appendix}%{errata}%{index}%{insert}%{update}"\
|
19
|
+
"%{translation}" % params
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_serie(serie, opts, params)
|
24
|
+
if serie.to_s(opts[:format]).include?(params[:publisher].to_s(opts[:format]))
|
25
|
+
return serie.to_s(opts[:format])
|
26
|
+
end
|
27
|
+
|
28
|
+
"#{params[:publisher].to_s(opts[:format])} #{serie.to_s(opts[:format])}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def render_code(code, opts, _params)
|
32
|
+
(opts[:format] == :mr ? "." : " ") + code.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def render_edition(edition, opts, _params)
|
36
|
+
return if opts[:without_edition]
|
37
|
+
|
38
|
+
case opts[:format]
|
39
|
+
when :long
|
40
|
+
" Edition "
|
41
|
+
when :abbrev
|
42
|
+
" Ed. "
|
43
|
+
when :short, :mr
|
44
|
+
"e"
|
45
|
+
end + edition.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_revision(revision, opts, _params)
|
49
|
+
case opts[:format]
|
50
|
+
when :long
|
51
|
+
", Revision "
|
52
|
+
when :abbrev
|
53
|
+
", Rev. "
|
54
|
+
when :short, :mr
|
55
|
+
"r"
|
56
|
+
end + (revision == '' ? '1' : revision).to_s
|
57
|
+
end
|
58
|
+
|
59
|
+
def render_version(version, opts, _params)
|
60
|
+
case opts[:format]
|
61
|
+
when :long
|
62
|
+
", Version "
|
63
|
+
when :abbrev
|
64
|
+
", Ver. "
|
65
|
+
when :short, :mr
|
66
|
+
"ver"
|
67
|
+
end + version
|
68
|
+
end
|
69
|
+
|
70
|
+
def render_volume(volume, opts, params)
|
71
|
+
case opts[:format]
|
72
|
+
when :long
|
73
|
+
", Volume "
|
74
|
+
when :abbrev
|
75
|
+
", Vol. "
|
76
|
+
when :short
|
77
|
+
params[:code] ? "v" : " v"
|
78
|
+
when :mr
|
79
|
+
params[:code] ? "v" : ".v"
|
80
|
+
end + volume
|
81
|
+
end
|
82
|
+
|
83
|
+
def render_update(update, opts, _params)
|
84
|
+
update_text = update.number.to_s
|
85
|
+
update_text += "-#{update.year}" if update.year
|
86
|
+
update_text += sprintf("%02d", update.month) if update.month
|
87
|
+
|
88
|
+
case opts[:format]
|
89
|
+
when :long
|
90
|
+
" Update #{update_text}"
|
91
|
+
when :abbrev
|
92
|
+
" Upd. #{update_text}"
|
93
|
+
when :short
|
94
|
+
"/Upd#{update_text}"
|
95
|
+
when :mr
|
96
|
+
".u#{update_text}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def render_translation(translation, opts, _params)
|
101
|
+
case opts[:format]
|
102
|
+
when :long, :abbrev
|
103
|
+
" (#{translation.upcase})"
|
104
|
+
when :mr
|
105
|
+
".#{translation}"
|
106
|
+
when :short
|
107
|
+
" #{translation}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def render_part(part, opts, _params)
|
112
|
+
case opts[:format]
|
113
|
+
when :long
|
114
|
+
" Part "
|
115
|
+
when :abbrev
|
116
|
+
" Pt. "
|
117
|
+
when :short, :mr
|
118
|
+
"pt"
|
119
|
+
end + part
|
120
|
+
end
|
121
|
+
|
122
|
+
def render_supplement(supplement, opts, _params)
|
123
|
+
case opts[:format]
|
124
|
+
when :long
|
125
|
+
" Supplement "
|
126
|
+
when :abbrev
|
127
|
+
" Suppl. "
|
128
|
+
when :short, :mr
|
129
|
+
"sup"
|
130
|
+
end + supplement
|
131
|
+
end
|
132
|
+
|
133
|
+
def render_appendix(appendix, opts, _params)
|
134
|
+
case opts[:format]
|
135
|
+
when :long
|
136
|
+
" Appendix "
|
137
|
+
when :abbrev
|
138
|
+
" App. "
|
139
|
+
when :short, :mr
|
140
|
+
"app"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def render_section(section, opts, _params)
|
145
|
+
case opts[:format]
|
146
|
+
when :long
|
147
|
+
" Section "
|
148
|
+
when :abbrev
|
149
|
+
" Sec. "
|
150
|
+
when :short, :mr
|
151
|
+
"sec"
|
152
|
+
end + section
|
153
|
+
end
|
154
|
+
|
155
|
+
def render_errata(errata, opts, _params)
|
156
|
+
case opts[:format]
|
157
|
+
when :long
|
158
|
+
" Errata "
|
159
|
+
when :abbrev
|
160
|
+
" Err. "
|
161
|
+
when :short, :mr
|
162
|
+
"err"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def render_index(index, opts, _params)
|
167
|
+
case opts[:format]
|
168
|
+
when :long
|
169
|
+
" Index "
|
170
|
+
when :abbrev
|
171
|
+
" Index. "
|
172
|
+
when :short, :mr
|
173
|
+
"indx"
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def render_insert(insert, opts, _params)
|
178
|
+
case opts[:format]
|
179
|
+
when :long
|
180
|
+
" Insert "
|
181
|
+
when :abbrev
|
182
|
+
" Ins. "
|
183
|
+
when :short, :mr
|
184
|
+
"ins"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def render_stage(stage, opts, _params)
|
189
|
+
case opts[:format]
|
190
|
+
when :mr
|
191
|
+
"."
|
192
|
+
when :short
|
193
|
+
" "
|
194
|
+
else
|
195
|
+
" "
|
196
|
+
end + stage.to_s(opts[:format])
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
data/lib/pubid/nist/stage.rb
CHANGED
data/lib/pubid/nist/update.rb
CHANGED
data/lib/pubid/nist/version.rb
CHANGED
data/lib/pubid/nist.rb
CHANGED
@@ -15,7 +15,8 @@ require_relative "nist/parsers/default"
|
|
15
15
|
require_relative "nist/update"
|
16
16
|
require_relative "nist/transformer"
|
17
17
|
require_relative "nist/parser"
|
18
|
-
require_relative "nist/renderer"
|
18
|
+
require_relative "nist/renderer/base"
|
19
|
+
require_relative "nist/renderer/addendum"
|
19
20
|
|
20
21
|
Dir[File.join(__dir__, 'nist/parsers', '*.rb')].each do |file|
|
21
22
|
require file
|
@@ -34,3 +35,4 @@ require_relative "nist/stage"
|
|
34
35
|
require_relative "nist/errors"
|
35
36
|
require_relative "nist/nist_tech_pubs"
|
36
37
|
require_relative "nist/edition"
|
38
|
+
require_relative "nist/addendum"
|
data/update_codes.yaml
CHANGED
@@ -5,7 +5,7 @@ NIST SP 260-162 2006ed.: NIST SP 260-162e2006
|
|
5
5
|
NBS CIRC 154suprev: NBS CIRC 154r1sup
|
6
6
|
NBS CIRC supJun1925-Jun1926: NBS CIRC 24e7sup2
|
7
7
|
NBS CIRC supJun1925-Jun1927: NBS CIRC 24e7sup3
|
8
|
-
NBS CIRC sup
|
8
|
+
/^NBS CIRC sup$/: NBS CIRC 24e7sup
|
9
9
|
NBS CIRC e2: NBS CIRC 2e2
|
10
10
|
NBS CIRC 25sup-1924: NBS CIRC 25sup
|
11
11
|
NIST SP 260-126 rev 2013: NIST SP 260-126r2013
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubid-nist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
131
|
+
version: 1.12.2
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
138
|
+
version: 1.12.2
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubyzip
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- exe/pubid-nist
|
166
166
|
- lib/pubid-nist.rb
|
167
167
|
- lib/pubid/nist.rb
|
168
|
+
- lib/pubid/nist/addendum.rb
|
168
169
|
- lib/pubid/nist/edition.rb
|
169
170
|
- lib/pubid/nist/errors.rb
|
170
171
|
- lib/pubid/nist/identifier.rb
|
@@ -193,7 +194,8 @@ files:
|
|
193
194
|
- lib/pubid/nist/parsers/nist_sp.rb
|
194
195
|
- lib/pubid/nist/parsers/nist_tn.rb
|
195
196
|
- lib/pubid/nist/publisher.rb
|
196
|
-
- lib/pubid/nist/renderer.rb
|
197
|
+
- lib/pubid/nist/renderer/addendum.rb
|
198
|
+
- lib/pubid/nist/renderer/base.rb
|
197
199
|
- lib/pubid/nist/serie.rb
|
198
200
|
- lib/pubid/nist/stage.rb
|
199
201
|
- lib/pubid/nist/transformer.rb
|
data/lib/pubid/nist/renderer.rb
DELETED
@@ -1,213 +0,0 @@
|
|
1
|
-
module Pubid::Nist
|
2
|
-
class Renderer < Pubid::Core::Renderer::Base
|
3
|
-
def render_base_identifier(**opts)
|
4
|
-
prerender(**opts)
|
5
|
-
|
6
|
-
render_identifier(@prerendered_params, opts)
|
7
|
-
end
|
8
|
-
|
9
|
-
def render_identifier(params, opts)
|
10
|
-
result = case opts[:format]
|
11
|
-
when :short, :mr
|
12
|
-
"%{serie}%{code}%{volume}%{part}%{edition}%{revision}%{version}"\
|
13
|
-
"%{supplement}%{section}%{appendix}%{errata}%{index}%{insert}%{update}"\
|
14
|
-
"%{stage}%{translation}" % params
|
15
|
-
else
|
16
|
-
"%{serie}%{stage}%{code}%{volume}%{part}%{edition}%{revision}%{version}"\
|
17
|
-
"%{supplement}%{section}%{appendix}%{errata}%{index}%{insert}%{update}"\
|
18
|
-
"%{translation}" % params
|
19
|
-
end
|
20
|
-
|
21
|
-
if params[:addendum] && !params[:addendum].empty?
|
22
|
-
case opts[:format]
|
23
|
-
when :long
|
24
|
-
"Addendum to #{result}"
|
25
|
-
when :abbrev
|
26
|
-
"Add. to #{result}"
|
27
|
-
when :short
|
28
|
-
"#{result} Add."
|
29
|
-
when :mr
|
30
|
-
"#{result}.add-1"
|
31
|
-
end
|
32
|
-
else
|
33
|
-
result
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def render_serie(serie, opts, params)
|
38
|
-
if serie.to_s(opts[:format]).include?(params[:publisher].to_s(opts[:format]))
|
39
|
-
return serie.to_s(opts[:format])
|
40
|
-
end
|
41
|
-
|
42
|
-
"#{params[:publisher].to_s(opts[:format])} #{serie.to_s(opts[:format])}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def render_code(code, opts, _params)
|
46
|
-
(opts[:format] == :mr ? "." : " ") + code.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def render_edition(edition, opts, _params)
|
50
|
-
return if opts[:without_edition]
|
51
|
-
|
52
|
-
case opts[:format]
|
53
|
-
when :long
|
54
|
-
" Edition "
|
55
|
-
when :abbrev
|
56
|
-
" Ed. "
|
57
|
-
when :short, :mr
|
58
|
-
"e"
|
59
|
-
end + edition.to_s
|
60
|
-
end
|
61
|
-
|
62
|
-
def render_revision(revision, opts, _params)
|
63
|
-
case opts[:format]
|
64
|
-
when :long
|
65
|
-
", Revision "
|
66
|
-
when :abbrev
|
67
|
-
", Rev. "
|
68
|
-
when :short, :mr
|
69
|
-
"r"
|
70
|
-
end + (revision == '' ? '1' : revision).to_s
|
71
|
-
end
|
72
|
-
|
73
|
-
def render_version(version, opts, _params)
|
74
|
-
case opts[:format]
|
75
|
-
when :long
|
76
|
-
", Version "
|
77
|
-
when :abbrev
|
78
|
-
", Ver. "
|
79
|
-
when :short, :mr
|
80
|
-
"ver"
|
81
|
-
end + version
|
82
|
-
end
|
83
|
-
|
84
|
-
def render_volume(volume, opts, params)
|
85
|
-
case opts[:format]
|
86
|
-
when :long
|
87
|
-
", Volume "
|
88
|
-
when :abbrev
|
89
|
-
", Vol. "
|
90
|
-
when :short
|
91
|
-
params[:code] ? "v" : " v"
|
92
|
-
when :mr
|
93
|
-
params[:code] ? "v" : ".v"
|
94
|
-
end + volume
|
95
|
-
end
|
96
|
-
|
97
|
-
def render_update(update, opts, _params)
|
98
|
-
update_text = update.number.to_s
|
99
|
-
update_text += "-#{update.year}" if update.year
|
100
|
-
update_text += sprintf("%02d", update.month) if update.month
|
101
|
-
|
102
|
-
case opts[:format]
|
103
|
-
when :long
|
104
|
-
" Update #{update_text}"
|
105
|
-
when :abbrev
|
106
|
-
" Upd. #{update_text}"
|
107
|
-
when :short
|
108
|
-
"/Upd#{update_text}"
|
109
|
-
when :mr
|
110
|
-
".u#{update_text}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def render_translation(translation, opts, _params)
|
115
|
-
case opts[:format]
|
116
|
-
when :long, :abbrev
|
117
|
-
" (#{translation.upcase})"
|
118
|
-
when :mr
|
119
|
-
".#{translation}"
|
120
|
-
when :short
|
121
|
-
" #{translation}"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def render_part(part, opts, _params)
|
126
|
-
case opts[:format]
|
127
|
-
when :long
|
128
|
-
" Part "
|
129
|
-
when :abbrev
|
130
|
-
" Pt. "
|
131
|
-
when :short, :mr
|
132
|
-
"pt"
|
133
|
-
end + part
|
134
|
-
end
|
135
|
-
|
136
|
-
def render_supplement(supplement, opts, _params)
|
137
|
-
case opts[:format]
|
138
|
-
when :long
|
139
|
-
" Supplement "
|
140
|
-
when :abbrev
|
141
|
-
" Suppl. "
|
142
|
-
when :short, :mr
|
143
|
-
"sup"
|
144
|
-
end + supplement
|
145
|
-
end
|
146
|
-
|
147
|
-
def render_appendix(appendix, opts, _params)
|
148
|
-
case opts[:format]
|
149
|
-
when :long
|
150
|
-
" Appendix "
|
151
|
-
when :abbrev
|
152
|
-
" App. "
|
153
|
-
when :short, :mr
|
154
|
-
"app"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
def render_section(section, opts, _params)
|
159
|
-
case opts[:format]
|
160
|
-
when :long
|
161
|
-
" Section "
|
162
|
-
when :abbrev
|
163
|
-
" Sec. "
|
164
|
-
when :short, :mr
|
165
|
-
"sec"
|
166
|
-
end + section
|
167
|
-
end
|
168
|
-
|
169
|
-
def render_errata(errata, opts, _params)
|
170
|
-
case opts[:format]
|
171
|
-
when :long
|
172
|
-
" Errata "
|
173
|
-
when :abbrev
|
174
|
-
" Err. "
|
175
|
-
when :short, :mr
|
176
|
-
"err"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def render_index(index, opts, _params)
|
181
|
-
case opts[:format]
|
182
|
-
when :long
|
183
|
-
" Index "
|
184
|
-
when :abbrev
|
185
|
-
" Index. "
|
186
|
-
when :short, :mr
|
187
|
-
"indx"
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
def render_insert(insert, opts, _params)
|
192
|
-
case opts[:format]
|
193
|
-
when :long
|
194
|
-
" Insert "
|
195
|
-
when :abbrev
|
196
|
-
" Ins. "
|
197
|
-
when :short, :mr
|
198
|
-
"ins"
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
def render_stage(stage, opts, _params)
|
203
|
-
case opts[:format]
|
204
|
-
when :mr
|
205
|
-
"."
|
206
|
-
when :short
|
207
|
-
" "
|
208
|
-
else
|
209
|
-
" "
|
210
|
-
end + stage.to_s(opts[:format])
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|