pubid-nist 0.2.2 → 0.2.4

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: ae5b75b8cb77b433b69d107ca44d6f828602da328419436c24c25968412d1719
4
- data.tar.gz: 1377f4285c99bd9f1582f5ca1daff8ed79cf90543405bf43d4a8a9659d2ae21b
3
+ metadata.gz: 7e7f47e08604ec704f0cf6468e57bf119027caf37ccba4043269374d2e9381a3
4
+ data.tar.gz: ec580488f65954d7fcbbfff5dd17e0cdc2dc88f7d07cb81d0bada5812beae2fe
5
5
  SHA512:
6
- metadata.gz: f0252ea5cf1e0f418d15b29a051dbaa203ff0765dcf1d45124b3fb123a5d0baaaa6aac5e2cca8de138e0fbf21f20d4b7aba0ecaf79de7fbc79164a119763d971
7
- data.tar.gz: a8e8a4c490568753bd6233432825c7cf717dbd379c1eb56155082bdbe9ce74040365e9579f802c241ca6c98631da38ca7caa6ac6ff2687e6ada9003cc21e28de
6
+ metadata.gz: d3c2ec778fb99af9427532d92404c60fef8a4e1f65342ab61b0925ade00849c9e151604e2bc2b3cf2d71877dbad840c017c581036e0dc22b1a307bafd06ae2f4
7
+ data.tar.gz: 787c614f6716d8cc8044821c1ff90ae1afebbe2731673adef5aef5150fa77a5e8d32d633f7367d2929620578d84ed6b6bb81e39367e422f017704d2b34cc65e0
@@ -4,83 +4,6 @@ require "json"
4
4
 
5
5
  UPDATE_CODES = YAML.load_file(File.join(File.dirname(__FILE__), "../../../update_codes.yaml"))
6
6
 
7
- REVISION_DESC = {
8
- long: ", Revision ",
9
- abbrev: ", Rev. ",
10
- short: "r",
11
- mr: "r",
12
- }.freeze
13
-
14
- VERSION_DESC = {
15
- long: ", Version ",
16
- abbrev: ", Ver. ",
17
- short: "ver",
18
- mr: "ver",
19
- }.freeze
20
-
21
- VOLUME_DESC = {
22
- long: ", Volume ",
23
- abbrev: ", Vol. ",
24
- short: "v",
25
- mr: "v",
26
- }.freeze
27
-
28
- PART_DESC = {
29
- long: " Part ",
30
- abbrev: " Pt. ",
31
- short: "pt",
32
- mr: "pt",
33
- }.freeze
34
-
35
- EDITION_DESC = {
36
- long: " Edition ",
37
- abbrev: " Ed. ",
38
- short: "e",
39
- mr: "e",
40
- }.freeze
41
-
42
- SUPPLEMENT_DESC = {
43
- long: " Supplement ",
44
- abbrev: " Suppl. ",
45
- short: "sup",
46
- mr: "sup",
47
- }.freeze
48
-
49
- SECTION_DESC = {
50
- long: " Section ",
51
- abbrev: " Sec. ",
52
- short: "sec",
53
- mr: "sec",
54
- }.freeze
55
-
56
- APPENDIX_DESC = {
57
- long: " Appendix ",
58
- abbrev: " App. ",
59
- short: "app",
60
- mr: "app",
61
- }.freeze
62
-
63
- ERRATA_DESC = {
64
- long: " Errata ",
65
- abbrev: " Err. ",
66
- short: "err",
67
- mr: "err",
68
- }.freeze
69
-
70
- INDEX_DESC = {
71
- long: " Index ",
72
- abbrev: " Index. ",
73
- short: "indx",
74
- mr: "indx",
75
- }.freeze
76
-
77
- INSERT_DESC = {
78
- long: " Insert ",
79
- abbrev: " Ins. ",
80
- short: "ins",
81
- mr: "ins",
82
- }.freeze
83
-
84
7
  module Pubid::Nist
85
8
  class Identifier < Pubid::Core::Identifier::Base
86
9
  attr_accessor :serie, :code, :revision, :publisher, :version, :volume,
@@ -148,25 +71,11 @@ module Pubid::Nist
148
71
  code
149
72
  end
150
73
 
151
- # def to_s(format = :short)
152
- # result = render_serie(format)
153
- # result += " " unless format == :short || stage.nil?
154
- # result += "#{stage&.to_s(format)}"\
155
- # " #{code}#{render_part(format)}#{render_edition(format)}"\
156
- # "#{render_localities(format)}"\
157
- # "#{render_update(format)}#{render_translation(format)}"
158
- # result = render_addendum(result, format)
159
- #
160
- # return result.gsub(" ", ".") if format == :mr
161
- #
162
- # result
163
- # end
164
-
165
- def to_s(format = :short)
166
- self.class.get_renderer_class.new(get_params).render(format: format)
74
+ # @param without_edition [Boolean] render pubid without rendering edition
75
+ def to_s(format = :short, without_edition: false)
76
+ self.class.get_renderer_class.new(to_h).render(format: format, without_edition: without_edition)
167
77
  end
168
78
 
169
-
170
79
  def to_json(*args)
171
80
  result = {
172
81
  styles: {
@@ -184,104 +93,6 @@ module Pubid::Nist
184
93
  result.to_json(*args)
185
94
  end
186
95
 
187
- def render_serie(format)
188
- if serie.to_s(format).include?(publisher.to_s(format))
189
- return serie.to_s(format)
190
- end
191
-
192
- "#{publisher.to_s(format)} #{serie.to_s(format)}"
193
- end
194
-
195
- def render_part(format)
196
- result = ""
197
- result += "#{VOLUME_DESC[format]}#{volume}" unless volume.nil?
198
- result += "#{PART_DESC[format]}#{part}" unless part.nil?
199
- result
200
- end
201
-
202
- def render_edition(format)
203
- result = ""
204
-
205
- result += "#{EDITION_DESC[format]}#{edition.to_s}" unless edition.nil?
206
- result += "#{REVISION_DESC[format]}#{revision == '' ? '1' : revision}" if revision
207
- result += "#{VERSION_DESC[format]}#{version}" unless version.nil?
208
- result
209
- end
210
-
211
- def render_localities(format)
212
- result = ""
213
- result += "#{SUPPLEMENT_DESC[format]}#{supplement}" unless supplement.nil?
214
- result += "#{SECTION_DESC[format]}#{section}" unless section.nil?
215
- result += "#{APPENDIX_DESC[format]}" unless appendix.nil?
216
- result += "#{ERRATA_DESC[format]}" unless errata.nil?
217
- result += INDEX_DESC[format] unless index.nil?
218
- result += INSERT_DESC[format] unless insert.nil?
219
-
220
- result
221
- end
222
-
223
- def render_update(format)
224
- return "" if update_year.nil?
225
-
226
- if update_month && update_number.nil?
227
- @update_number = "1"
228
- end
229
-
230
- if update_year&.length == 2
231
- @update_year = "19#{update_year}"
232
- end
233
-
234
- if update_number.match?(/\d+/)
235
- update_text = update_number
236
- update_text += "-#{update_year}" if update_year && !update_year.empty?
237
- if update_month
238
- date = Date.parse("01/#{update_month}/#{update_year}")
239
- update_text += sprintf("%02d", date.month)
240
- end
241
- else
242
- update_text = "1"
243
- end
244
-
245
- case format
246
- when :long
247
- " Update #{update_text}"
248
- when :abbrev
249
- " Upd. #{update_text}"
250
- when :short
251
- "/Upd#{update_text}"
252
- when :mr
253
- ".u#{update_text}"
254
- end
255
- end
256
-
257
- def render_translation(format)
258
- return "" if translation.nil?
259
-
260
- case format
261
- when :long, :abbrev
262
- " (#{translation.upcase})"
263
- when :mr
264
- ".#{translation}"
265
- when :short
266
- "(#{translation})"
267
- end
268
- end
269
-
270
- def render_addendum(input, format)
271
- return input unless addendum
272
-
273
- case format
274
- when :long
275
- "Addendum to #{input}"
276
- when :abbrev
277
- "Add. to #{input}"
278
- when :short
279
- "#{input} Add."
280
- when :mr
281
- "#{input}.add-1"
282
- end
283
- end
284
-
285
96
  class << self
286
97
  def create(**opts)
287
98
  new(**opts)
@@ -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 >> (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
@@ -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
@@ -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
@@ -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
@@ -47,6 +47,8 @@ module Pubid::Nist
47
47
  end
48
48
 
49
49
  def render_edition(edition, opts, _params)
50
+ return if opts[:without_edition]
51
+
50
52
  case opts[:format]
51
53
  when :long
52
54
  " Edition "
@@ -202,7 +204,7 @@ module Pubid::Nist
202
204
  when :mr
203
205
  "."
204
206
  when :short
205
- ""
207
+ " "
206
208
  else
207
209
  " "
208
210
  end + stage.to_s(opts[:format])
@@ -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
2
2
  module Nist
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.2.4".freeze
4
4
  end
5
5
  end
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
@@ -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.2
4
+ version: 0.2.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: 2023-09-08 00:00:00.000000000 Z
11
+ date: 2023-11-15 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.10.3
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.10.3
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
@@ -157,7 +171,7 @@ files:
157
171
  - lib/pubid/nist/nist_tech_pubs.rb
158
172
  - lib/pubid/nist/parser.rb
159
173
  - lib/pubid/nist/parsers/default.rb
160
- - lib/pubid/nist/parsers/fips_pub.rb
174
+ - lib/pubid/nist/parsers/fips.rb
161
175
  - lib/pubid/nist/parsers/nbs_bh.rb
162
176
  - lib/pubid/nist/parsers/nbs_circ.rb
163
177
  - lib/pubid/nist/parsers/nbs_crpl.rb