pubid-nist 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pubid/nist/addendum.rb +21 -0
  3. data/lib/pubid/nist/edition.rb +26 -14
  4. data/lib/pubid/nist/identifier.rb +21 -18
  5. data/lib/pubid/nist/nist_tech_pubs.rb +7 -1
  6. data/lib/pubid/nist/parser.rb +21 -15
  7. data/lib/pubid/nist/parsers/{nbs_circ.rb → circ.rb} +2 -2
  8. data/lib/pubid/nist/parsers/{nbs_crpl.rb → crpl.rb} +3 -3
  9. data/lib/pubid/nist/parsers/{nbs_csm.rb → csm.rb} +2 -2
  10. data/lib/pubid/nist/parsers/default.rb +6 -5
  11. data/lib/pubid/nist/parsers/fips.rb +10 -3
  12. data/lib/pubid/nist/parsers/{nist_gcr.rb → gcr.rb} +1 -1
  13. data/lib/pubid/nist/parsers/{nbs_hb.rb → hb.rb} +2 -10
  14. data/lib/pubid/nist/parsers/{nbs_mp.rb → mp.rb} +1 -1
  15. data/lib/pubid/nist/parsers/{nist_ncstar.rb → ncstar.rb} +1 -1
  16. data/lib/pubid/nist/parsers/{nist_owmwp.rb → owmwp.rb} +1 -1
  17. data/lib/pubid/nist/parsers/{nbs_rpt.rb → rpt.rb} +1 -1
  18. data/lib/pubid/nist/parsers/{nist_sp.rb → sp.rb} +5 -3
  19. data/lib/pubid/nist/parsers/tn.rb +17 -0
  20. data/lib/pubid/nist/publisher.rb +1 -5
  21. data/lib/pubid/nist/renderer/addendum.rb +20 -0
  22. data/lib/pubid/nist/renderer/base.rb +202 -0
  23. data/lib/pubid/nist/series.rb +30 -0
  24. data/lib/pubid/nist/stage.rb +2 -2
  25. data/lib/pubid/nist/transformer.rb +10 -2
  26. data/lib/pubid/nist/update.rb +1 -1
  27. data/lib/pubid/nist/version.rb +1 -1
  28. data/lib/pubid/nist.rb +4 -2
  29. data/series.yaml +60 -82
  30. data/update_codes.yaml +4 -4
  31. metadata +19 -23
  32. data/lib/pubid/nist/parsers/nbs_bh.rb +0 -6
  33. data/lib/pubid/nist/parsers/nbs_fips.rb +0 -14
  34. data/lib/pubid/nist/parsers/nbs_mn.rb +0 -6
  35. data/lib/pubid/nist/parsers/nbs_sp.rb +0 -13
  36. data/lib/pubid/nist/parsers/nbs_tn.rb +0 -9
  37. data/lib/pubid/nist/parsers/nist_hb.rb +0 -9
  38. data/lib/pubid/nist/parsers/nist_tn.rb +0 -13
  39. data/lib/pubid/nist/renderer.rb +0 -213
  40. data/lib/pubid/nist/serie.rb +0 -29
@@ -1,13 +0,0 @@
1
- module Pubid::Nist
2
- module Parsers
3
- class NistTn < Default
4
- rule(:report_number) do
5
- first_report_number
6
- end
7
-
8
- rule(:edition_prefixes) do
9
- str("-") | str("e")
10
- end
11
- end
12
- end
13
- end
@@ -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
@@ -1,29 +0,0 @@
1
- SERIES = YAML.load_file(File.join(File.dirname(__FILE__), "../../../series.yaml"))
2
-
3
- module Pubid::Nist
4
- class Serie
5
- attr_accessor :serie, :parsed
6
-
7
- def initialize(serie:, parsed: nil)
8
- raise Errors::SerieInvalidError, "#{serie} is not valid serie" unless SERIES["long"].key?(serie)
9
-
10
- @serie = serie
11
- @parsed = parsed
12
- end
13
-
14
- def to_s(format = :short)
15
- return @serie if format == :short
16
-
17
- result = SERIES[format.to_s][@serie]
18
- return @serie if result.nil? && format == :mr
19
-
20
- return SERIES["long"][@serie] if result.nil?
21
-
22
- result
23
- end
24
-
25
- def ==(other)
26
- other.serie == @serie
27
- end
28
- end
29
- end