pubid-nist 0.2.2 → 0.2.3

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: c7f76d8947ccd706282e78b94eb9c4284671b866acc1630c08a1fdd398dbd73e
4
+ data.tar.gz: 01dfd5d1e8afbe479916a906566406f2d3a7d8d3235053a86be6d0cf1c09de5c
5
5
  SHA512:
6
- metadata.gz: f0252ea5cf1e0f418d15b29a051dbaa203ff0765dcf1d45124b3fb123a5d0baaaa6aac5e2cca8de138e0fbf21f20d4b7aba0ecaf79de7fbc79164a119763d971
7
- data.tar.gz: a8e8a4c490568753bd6233432825c7cf717dbd379c1eb56155082bdbe9ce74040365e9579f802c241ca6c98631da38ca7caa6ac6ff2687e6ada9003cc21e28de
6
+ metadata.gz: 051144f72ccff63f56b875f2bb843750b14b86d3b9014f27ecd15cfd61e084052df6ae44be931a2c9b7a7e63dee3e03a927e4c6123cf6ff3727cb134fcb43340
7
+ data.tar.gz: 7b26bc1e82271f82286079bda318834594dc93eca2ef6e3569109e2323d47c06708404aed1f1dd02aead5a1d03d60efe14d900556696976945fa4778fd2a032a
@@ -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(get_params).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)
@@ -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 "
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Nist
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.2.3".freeze
4
4
  end
5
5
  end
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.3
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-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake