pubid-nist 0.2.3 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7f76d8947ccd706282e78b94eb9c4284671b866acc1630c08a1fdd398dbd73e
4
- data.tar.gz: 01dfd5d1e8afbe479916a906566406f2d3a7d8d3235053a86be6d0cf1c09de5c
3
+ metadata.gz: effbdd3a2d023969c91461079bcb6b2ac8fc24d1260a7655cdacaf50858a6084
4
+ data.tar.gz: '07885e3191c545d7f5796c5ad431094af88a4334fa12b3f97357c8dbebc71d6f'
5
5
  SHA512:
6
- metadata.gz: 051144f72ccff63f56b875f2bb843750b14b86d3b9014f27ecd15cfd61e084052df6ae44be931a2c9b7a7e63dee3e03a927e4c6123cf6ff3727cb134fcb43340
7
- data.tar.gz: 7b26bc1e82271f82286079bda318834594dc93eca2ef6e3569109e2323d47c06708404aed1f1dd02aead5a1d03d60efe14d900556696976945fa4778fd2a032a
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
@@ -1,5 +1,5 @@
1
1
  module Pubid::Nist
2
- class Edition
2
+ class Edition < Pubid::Core::Entity
3
3
  attr_accessor :year, :month, :day, :parsed, :sequence
4
4
 
5
5
  def initialize(parsed: nil, year: nil, month: nil, day: nil, sequence: nil)
@@ -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(get_params).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
- doi = doc.at("doi_data/doi").text.gsub("10.6028/", "")
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
@@ -1,17 +1,12 @@
1
1
  module Pubid::Nist
2
- class Parser < Parslet::Parser
2
+ class Parser < Pubid::Core::Parser
3
3
  attr_accessor :parsed
4
4
 
5
5
  rule(:series) do
6
- ((SERIES["long"].keys
7
- .sort_by(&:length).reverse
8
- .flatten
9
- .reduce do |acc, s|
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
- parsed = parser.new.parse(parsed[:remaining].to_s)
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,8 @@ module Pubid::Nist
40
40
  end
41
41
 
42
42
  rule(:stage) do
43
- (space >> (array_to_str(STAGES["id"].keys).as(:id) >> array_to_str(STAGES["type"].keys).as(:type)).as(:stage))
43
+ ((space | dot) >> (array_to_str(STAGES["id"].keys + STAGES["id"].keys.map(&:upcase)).as(:id) >>
44
+ array_to_str(STAGES["type"].keys + STAGES["type"].keys.map(&:upcase)).as(:type)).as(:stage))
44
45
  end
45
46
 
46
47
  rule(:draft) do
@@ -67,7 +68,7 @@ module Pubid::Nist
67
68
  rule(:part_prefixes) { str("pt") | str("p") }
68
69
 
69
70
  rule(:part) do
70
- part_prefixes >> digits.as(:part)
71
+ part_prefixes >> (digits >> (str("-") >> digits).maybe).as(:part)
71
72
  end
72
73
 
73
74
  rule(:revision) do
@@ -83,7 +84,7 @@ module Pubid::Nist
83
84
  end
84
85
 
85
86
  rule(:update) do
86
- (str("/Upd") | str("/upd")) >> (digits.as(:number) >> str("-") >> digits.as(:year)).as(:update)
87
+ (str("/Upd") | str("/upd")) >> (digits.as(:number) >> (str("-") >> digits.as(:year)).maybe).as(:update)
87
88
  end
88
89
 
89
90
  rule(:translation) do
@@ -98,7 +99,8 @@ module Pubid::Nist
98
99
  end
99
100
 
100
101
  rule(:addendum) do
101
- (str("-add") | str(".add-1")).as(:addendum)
102
+ (str("-add") | str(".add") | str(" Add.")) >>
103
+ (str(" ") | str("-")).maybe >> (digits | str("")).as(:number).as(:addendum)
102
104
  end
103
105
 
104
106
  rule(:section) do
@@ -2,7 +2,7 @@ require_relative "nbs_fips"
2
2
 
3
3
  module Pubid::Nist
4
4
  module Parsers
5
- class FipsPub < NbsFips
5
+ class Fips < NbsFips
6
6
  end
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@ module Pubid::Nist
3
3
  class NbsCirc < Default
4
4
  rule(:revision) do
5
5
  ((str("rev") >> (words >> year_digits).as(:revision)) |
6
- (str("r") >> digits.as(:revision))
6
+ (str("r") >> (digits | (words >> year_digits)).as(:revision))
7
7
  )
8
8
  end
9
9
 
@@ -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
@@ -5,7 +5,7 @@ module Pubid::Nist
5
5
  (str(" ") | str(".")) >> report_number.maybe >> parts.repeat.as(:parts)
6
6
  end
7
7
 
8
- rule(:part_prefixes) { str("n") }
8
+ rule(:part_prefixes) { str("n") | str("pt") }
9
9
  end
10
10
  end
11
11
  end
@@ -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
@@ -2,7 +2,7 @@ module Pubid::Nist
2
2
  module Parsers
3
3
  class NbsSp < Default
4
4
  rule(:part_prefixes) do
5
- str("p") | str("P")
5
+ str("pt") | str("p") | str("P")
6
6
  end
7
7
 
8
8
  rule(:volume) do
@@ -2,7 +2,7 @@ module Pubid::Nist
2
2
  module Parsers
3
3
  class NistSp < Default
4
4
  rule(:version) do
5
- (((str("ver") | str(" Ver. ")) >> (digits >> (str(".") >> digits).repeat).as(:version)) |
5
+ (((str("ver") | str(" Ver. ") | str(" Version ")) >> (digits >> (str(".") >> digits).repeat).as(:version)) |
6
6
  (str("v") >>
7
7
  (match('\d') >> str(".") >> match('\d') >> (str(".") >> match('\d')).maybe).as(:version)))
8
8
  end
@@ -39,15 +39,21 @@ module Pubid::Nist
39
39
 
40
40
  rule(:edition) do
41
41
  ((str("e") >> year_digits.as(:edition_year)) | (str("-") >> year_digits.as(:edition_year)) |
42
- (str("e") >> digits.as(:edition)))
42
+ ((str("e") | str(" E")) >> digits.as(:edition)))
43
43
  end
44
44
 
45
45
  rule(:revision) do
46
- ((str("rev") | str("r")) >> (digits >> match("[a-z]").maybe).as(:revision)) |
46
+ ((str("rev") | str("r") | str(" Rev. ")) >> (digits >> match("[a-z]").maybe).as(:revision)) |
47
47
  (str("-") >> digits.as(:revision)) |
48
48
  (str("r") >> match("[a-z]").as(:revision)) |
49
- (str("r") >> str("").as(:revision))
49
+ ((str("r") | str(" Revision (r)")) >> str("").as(:revision))
50
50
  end
51
+
52
+ rule(:volume) do
53
+ (str("v") | str(" Vol. ")) >> digits.as(:volume)
54
+ end
55
+
56
+ rule(:part_prefixes) { str("pt") | str("p") | str(" Part ") }
51
57
  end
52
58
  end
53
59
  end
@@ -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
@@ -1,7 +1,7 @@
1
1
  STAGES = YAML.load_file(File.join(File.dirname(__FILE__), "../../../stages.yaml"))
2
2
 
3
3
  module Pubid::Nist
4
- class Stage
4
+ class Stage < Pubid::Core::Entity
5
5
  attr_accessor :id, :type
6
6
 
7
7
  def initialize(id:, type:)
@@ -13,7 +13,7 @@ module Pubid::Nist
13
13
 
14
14
  case format
15
15
  when :short
16
- " #{@id}#{@type}"
16
+ "#{@id}#{@type}"
17
17
  when :mr
18
18
  "#{@id}#{@type}"
19
19
  else
@@ -1,5 +1,5 @@
1
1
  module Pubid::Nist
2
- class Update
2
+ class Update < Pubid::Core::Entity
3
3
  attr_accessor :number, :year, :month
4
4
 
5
5
  def initialize(number: nil, year: nil, month: nil)
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Nist
3
- VERSION = "0.2.3".freeze
3
+ VERSION = "0.2.6".freeze
4
4
  end
5
5
  end
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/series.yaml CHANGED
@@ -15,7 +15,7 @@ long:
15
15
  NBS CS-E: Commercial Standards (emergency)
16
16
  NBS CSM: Commercial Standards Monthly
17
17
  NBS FIPS: Federal Information Processing Standards Publication
18
- FIPS PUB: Federal Information Processing Standards Publication
18
+ FIPS: Federal Information Processing Standards Publication
19
19
  NIST GCR: Grant/Contract Reports
20
20
  NBS GCR: Grant/Contract Reports
21
21
  NIST HB: Handbook
@@ -59,7 +59,7 @@ abbrev:
59
59
  NIST BSS: Bldg. Sci. Ser.
60
60
  NBS BSS: Bldg. Sci. Ser.
61
61
  NBS FIPS: Federal Inf. Process. Stds.
62
- FIPS PUB: Federal Inf. Process. Stds.
62
+ FIPS: Federal Inf. Process. Stds.
63
63
  NIST HB: Handb.
64
64
  NBS HB: Handb.
65
65
  NIST MN: Monogr.
@@ -98,7 +98,7 @@ mr:
98
98
  NBS CS-E: NBS.CS-E
99
99
  NBS CSM: NBS.CSM
100
100
  NBS FIPS: NBS.FIPS
101
- FIPS PUB: NIST.FIPS
101
+ FIPS: NIST.FIPS
102
102
  NIST GCR: NIST.GCR
103
103
  NBS GCR: NBS.GCR
104
104
  NIST HB: NIST.HB
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: NBS CIRC 24e7sup
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
@@ -17,12 +17,14 @@ NIST LCIRC: NIST LC
17
17
  NBS LCIRC: NBS LC
18
18
  NIST SP 800-57Pt3r1: NIST SP 800-57pt3r1
19
19
  NISTIR: NIST IR
20
- NIST FIPS: FIPS PUB
20
+ NIST FIPS: FIPS
21
21
  NIST.CSWP.01162020pt: NIST.CSWP.01162020(por)
22
22
  /^NBS FIPS 11-1-Sep30$/: NBS FIPS 11-1-Sep30/1977
23
23
  /^NBS FIPS 89-Sep1$/: NBS FIPS 89-Sep1981
24
- /^FIPS PUB 54-1-Jan15$/: FIPS PUB 54-1
25
- /^FIPS PUB 54-1-Jan17$/: FIPS PUB 54-1-Jan17/1991
24
+ /^FIPS PUB 54-1-Jan15$/: FIPS 54-1
25
+ /^FIPS 54-1-Jan15$/: FIPS 54-1
26
+ /^FIPS 54-1-Jan17$/: FIPS 54-1-Jan17/1991
27
+ FIPS PUB: FIPS
26
28
  NBS CRPL c4-4: NBS CRPL 4-4
27
29
  NIST AMS 300-8r1 (February 2021 update): NIST AMS 300-8r1/Upd1-202102
28
30
  NIST AMS 300-8r1/upd: NIST AMS 300-8r1/Upd1-202102
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.3
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: 2023-09-11 00:00:00.000000000 Z
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,28 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.8.0
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.8.0
138
+ version: 1.12.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubyzip
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: Library to generate, parse and manipulate NIST PubID.
140
154
  email:
141
155
  - open.source@ribose.com
@@ -151,13 +165,14 @@ files:
151
165
  - exe/pubid-nist
152
166
  - lib/pubid-nist.rb
153
167
  - lib/pubid/nist.rb
168
+ - lib/pubid/nist/addendum.rb
154
169
  - lib/pubid/nist/edition.rb
155
170
  - lib/pubid/nist/errors.rb
156
171
  - lib/pubid/nist/identifier.rb
157
172
  - lib/pubid/nist/nist_tech_pubs.rb
158
173
  - lib/pubid/nist/parser.rb
159
174
  - lib/pubid/nist/parsers/default.rb
160
- - lib/pubid/nist/parsers/fips_pub.rb
175
+ - lib/pubid/nist/parsers/fips.rb
161
176
  - lib/pubid/nist/parsers/nbs_bh.rb
162
177
  - lib/pubid/nist/parsers/nbs_circ.rb
163
178
  - lib/pubid/nist/parsers/nbs_crpl.rb
@@ -179,7 +194,8 @@ files:
179
194
  - lib/pubid/nist/parsers/nist_sp.rb
180
195
  - lib/pubid/nist/parsers/nist_tn.rb
181
196
  - lib/pubid/nist/publisher.rb
182
- - lib/pubid/nist/renderer.rb
197
+ - lib/pubid/nist/renderer/addendum.rb
198
+ - lib/pubid/nist/renderer/base.rb
183
199
  - lib/pubid/nist/serie.rb
184
200
  - lib/pubid/nist/stage.rb
185
201
  - lib/pubid/nist/transformer.rb
@@ -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