pubid-ieee 0.2.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c39ac43789fb576d032ed8907c5c130c99a4efc3c1a3d25d24e697b89814aba
4
- data.tar.gz: 0e7094c52ca4117f48e350e35e0bdfacb84d7256a75766a2da0d1a0728a91bdf
3
+ metadata.gz: 54475d8eda5cb1c2a1b5963b81fed10c0e9c140f26c2ae9cc87fc8fdccb53b91
4
+ data.tar.gz: 0621c17ab7a6c3d0954fd8bb7cab835bb6bdf722c0045c7f53c5f6dd9aa39153
5
5
  SHA512:
6
- metadata.gz: 5de60ef5c6a3c5220eefeb989c183a508e5db312c983eab114d4771702d5bd5a4ee01028d93499036916ea38ea1062e45ad7f9b1999093b3fbf8ba037c372f1f
7
- data.tar.gz: a55911eebc7b2a4964f6a8be5955ad0c0f750c5f6047daa0bd392d35b19aa719d30a4c42c29b1c75a0ddb0f3d6999597a583d8416c09c47a3e74cc2eaa47b835
6
+ metadata.gz: be58ef300b8821a14c19a5d8659513952e352bd8686a454f17bf1d358179c825645839dbb14d23d5fd034bf7ffafe288e10432fcdec32e170c4d699a7d2c8eb7
7
+ data.tar.gz: 63b336a44c3b1927dd59c651a4c21bf6d358212fe29c99f19f81f43d14111d162b910a0934e061ae38198b1a062f3c98c28f1779f86d5b68bfe1a36ba8f45b1f
@@ -1,6 +1,5 @@
1
1
  module Pubid::Ieee
2
2
  module Errors
3
- class ParseError < StandardError; end
4
3
  class ParseTypeError < StandardError; end
5
4
  end
6
5
  end
@@ -10,7 +10,7 @@ module Pubid::Ieee
10
10
  :draft_status, :revision, :adoption_year, :amendment, :supersedes,
11
11
  :corrigendum, :corrigendum_comment, :reaffirmed, :incorporates,
12
12
  :supplement, :proposal, :iso_identifier, :iso_amendment,
13
- :iteration, :includes, :adoption
13
+ :iteration, :includes, :adoption, :day
14
14
 
15
15
  def initialize(publisher: "IEEE", number: nil, stage: nil, subpart: nil, edition: nil,
16
16
  draft: nil, redline: nil, month: nil, revision: nil,
@@ -19,20 +19,12 @@ module Pubid::Ieee
19
19
  amendment: nil, supersedes: nil, corrigendum: nil,
20
20
  corrigendum_comment: nil, reaffirmed: nil,
21
21
  incorporates: nil, supplement: nil, proposal: nil,
22
- iso_amendment: nil, iteration: nil, includes: nil, adoption: nil, **opts)
22
+ iso_amendment: nil, iteration: nil, includes: nil, adoption: nil,
23
+ year: nil, day: nil, **opts)
23
24
 
24
25
  super(**opts.merge(number: number, publisher: publisher))#.merge(amendments: amendments, corrigendums: corrigendums))
25
26
 
26
- if edition
27
- @edition = edition.update(edition) do |key, value|
28
- case key
29
- when :year, :month
30
- value.to_i
31
- else
32
- value
33
- end
34
- end
35
- end
27
+ @edition = edition if edition
36
28
 
37
29
  @proposal = @number.to_s[0] == "P"
38
30
  @revision = revision
@@ -71,6 +63,8 @@ module Pubid::Ieee
71
63
  @iteration = iteration
72
64
  @includes = includes
73
65
  @adoption = adoption
66
+ @year = year.is_a?(Array) ? year.first.to_i : year.to_i if year
67
+ @day = day.to_i if day
74
68
  end
75
69
 
76
70
  def self.type
@@ -94,26 +88,65 @@ module Pubid::Ieee
94
88
  end
95
89
 
96
90
 
97
- def self.parse(code)
98
- parsed = Parser.new.parse(update_old_code(code))
99
- transform(parsed)
91
+ def self.transform_parameters(params)
92
+ return params if params == ""
93
+
94
+ if params[:iso_identifier]
95
+ if params[:iso_identifier].is_a?(Array)
96
+ params[:iso_identifier] = array_to_hash(params[:iso_identifier])
97
+ end
98
+
99
+ if params[:iso_identifier][:month]
100
+ params[:month] = params[:iso_identifier][:month]
101
+ params[:year] = params[:iso_identifier][:year]
102
+ params[:iso_identifier].delete(:year)
103
+ params[:iso_identifier].delete(:month)
104
+ end
105
+ end
100
106
 
101
- rescue Parslet::ParseFailed => failure
102
- raise Pubid::Ieee::Errors::ParseError, "#{failure.message}\ncause: #{failure.parse_failure_cause.ascii_tree}"
107
+ params.map do |k, v|
108
+ case k
109
+ when :parameters, :draft, :alternative
110
+ v = Identifier.merge_parameters(v) if k == :draft
111
+ # apply transformer for each separate item when array provided
112
+ if v.is_a?(Array)
113
+ get_transformer_class.new.apply(k => v.map { |vv| transform_parameters(vv) })
114
+ else
115
+ get_transformer_class.new.apply(k => transform_parameters(v))
116
+ end
117
+ when :iso_identifier
118
+ v = Identifier.merge_parameters(v)
119
+ result = get_transformer_class.new.apply(k => v)
120
+ # apply transformation when output was transformed to IEEE
121
+ result.key?(:iso_identifier) ? result : transform_parameters(result)
122
+ else
123
+ get_transformer_class.new.apply(k => v)
124
+ end
125
+ end.inject({}, :merge)
103
126
  end
104
127
 
105
128
  def self.transform(params)
106
- identifier_params = params.map do |k, v|
107
- get_transformer_class.new.apply(k => v)
108
- end.inject({}, :merge)
129
+ # transform inside parameters
130
+
131
+ identifier_params = transform_parameters(
132
+ Identifier.convert_parser_parameters(**params),
133
+ )
134
+
135
+ if identifier_params.key?(:draft) && identifier_params[:draft].key?(:year)
136
+ identifier_params[:year] = identifier_params[:draft][:year]
137
+ identifier_params[:month] = identifier_params[:draft][:month]
138
+ identifier_params[:day] = identifier_params[:draft][:day]
139
+ identifier_params[:draft].delete(:year)
140
+ identifier_params[:draft].delete(:month)
141
+ end
109
142
 
110
- Identifier.create(**Identifier.convert_parser_parameters(**identifier_params))
143
+ Identifier.create(**identifier_params)
111
144
  end
112
145
 
113
146
  # @param [:short, :full] format
114
147
  def to_s(format = :short, with_trademark: false)
115
148
  opts = { format: format, with_trademark: with_trademark }
116
- (@iso_identifier ? @iso_identifier.to_s(format: :ref_num_short) : "") +
149
+ (@iso_identifier ? @iso_identifier.to_s(format: :ref_num_short, with_edition: true) : "") +
117
150
  self.class.get_renderer_class.new(to_h(deep: false)).render(**opts) +
118
151
  (with_trademark ? trademark(@number) : "")
119
152
  end
@@ -130,6 +163,10 @@ module Pubid::Ieee
130
163
  def get_transformer_class
131
164
  Transformer
132
165
  end
166
+
167
+ def get_parser_class
168
+ Parser
169
+ end
133
170
  end
134
171
  end
135
172
  end
@@ -43,7 +43,7 @@ module Pubid::Ieee
43
43
  end
44
44
 
45
45
  def has_stage?(stage)
46
- Pubid::Iso::Identifier.has_stage?(stage)
46
+ Pubid::Iso::Identifier.has_stage?(stage) || Pubid::Iso::Parser::TYPED_STAGES.include?(stage)
47
47
  end
48
48
  end
49
49
  end
@@ -16,7 +16,7 @@ module Pubid::Ieee
16
16
  rule(:words_digits) { match('[\dA-Za-z]').repeat(1) }
17
17
  rule(:words) { match("[A-Za-z]").repeat(1) }
18
18
  rule(:words?) { words.maybe }
19
- rule(:year_digits) { (str("19") | str("20")) >> match('\d').repeat(2, 2) }
19
+ rule(:year_digits) { (str("19") | str("20")) >> match('\d').repeat(2, 2) >> digits.absent? }
20
20
 
21
21
  rule(:month_digits) do
22
22
  match('\d').repeat(2, 2)
@@ -32,11 +32,11 @@ module Pubid::Ieee
32
32
 
33
33
  rule(:organization) do
34
34
  str("IEEE") | str("AIEE") | str("ANSI") | str("ASA") | str("NCTA") |
35
- str("IEC") | str("ISO") | str("ASTM") | str("NACE") | str("NSF")
35
+ str("IEC") | str("ISO") | str("ASTM") | str("NACE") | str("NSF") | str("ASHRAE")
36
36
  end
37
37
 
38
38
  rule(:number) do
39
- str("D").absent? >> ((digits | match("[A-Z]")).repeat(1) >> match("[a-z]").maybe).as(:number)
39
+ str("D").absent? >> (str("P").maybe >> (digits | match("[A-Z]")).repeat(1) >> match("[a-z]").maybe).as(:number)
40
40
  end
41
41
 
42
42
  rule(:type) do
@@ -49,7 +49,7 @@ module Pubid::Ieee
49
49
 
50
50
  rule(:edition) do
51
51
  (comma >> year_digits.as(:year) >> str(" Edition")) |
52
- ((space | dash) >> str("Edition ") >> (digits >> dot >> digits).as(:version) >> (str(" - ") | space) >>
52
+ ((space | dash) >> str("Edition ") >> (digits >> dot >> digits).as(:edition) >> (str(" - ") | space) >>
53
53
  year_digits.as(:year) >> (dash >>
54
54
  month_digits.as(:month)).maybe) |
55
55
  #, February 2018 (E)
@@ -57,7 +57,7 @@ module Pubid::Ieee
57
57
  # (comma_month_year >> space? >> str("(E)")) |
58
58
  # comma_month_year |
59
59
  # First edition 2002-11-01
60
- space >> str("First").as(:version) >>
60
+ space >> str("First").as(:edition) >>
61
61
  str(" edition ") >>
62
62
  year_digits.as(:year) >> dash >>
63
63
  month_digits.as(:month) >> (dash >>
@@ -74,7 +74,7 @@ module Pubid::Ieee
74
74
  end
75
75
 
76
76
  rule(:draft_date) do
77
- ((space? >> comma | space) >> words.as(:month)).maybe >>
77
+ ((space? >> str(",") >> space? | space) >> words.as(:month)).maybe >>
78
78
  (
79
79
  ((space >> digits.as(:day)).maybe >> comma >> year_digits.as(:year)) |
80
80
  (comma_space >> match('\d').repeat(2, 4).as(:year))
@@ -86,14 +86,15 @@ module Pubid::Ieee
86
86
  (str("D") >> digits.as(:version)).repeat(2) |
87
87
  # for DD3, D3Q
88
88
  # don't parse "DIS" as draft
89
- (str("D") >> str("IS").absent? >> words_digits.as(:version)).repeat(1, 1)
89
+ # "-d" suffix for IEEE Unapproved Draft Std P336/D2009-d, Jul 2009
90
+ (str("D") >> str("IS").absent? >> str("-").maybe >> (words_digits >> str("-d").maybe).as(:version)).repeat(1, 1)
90
91
  end
91
92
 
92
93
  rule(:draft) do
93
94
  # /D14, April 2020
94
95
  # /D7 November, 2019
95
96
  (draft_prefix >> draft_version >>
96
- ((dot | str("r")) >> (digits >> words?).as(:revision)).maybe >>
97
+ ((dot | str("r")) >> (digits >> words? >> (dot >> digits).maybe).as(:revision)).maybe >>
97
98
  draft_date.maybe).as(:draft)
98
99
  end
99
100
 
@@ -102,7 +103,7 @@ module Pubid::Ieee
102
103
  end
103
104
 
104
105
  rule(:subpart) do
105
- (dot | dash) >> ((str("REV") | str("Rev")).maybe >> match('[\da-z]').repeat(1) | (str("REV") | str("Rev")))
106
+ (dot | dash | str("_")) >> ((str("REV") | str("Rev")).maybe >> match('[\da-z]').repeat(1) >> (dot >> digits).maybe | (str("REV") | str("Rev")))
106
107
  end
107
108
 
108
109
  rule(:part_subpart_year) do
@@ -119,7 +120,7 @@ module Pubid::Ieee
119
120
  # C57.19.101
120
121
  (part >> subpart.as(:subpart)) |
121
122
  # IEC 62525-Edition 1.0 - 2007
122
- edition.as(:edition) |
123
+ edition |
123
124
  # IEEE P11073-10101
124
125
  # IEEE P11073-10420/D4D5
125
126
  # IEEE Unapproved Draft Std P11073-20601a/D13, Jan 2010
@@ -146,9 +147,9 @@ module Pubid::Ieee
146
147
  rule(:dual_pubid_without_parameters) do
147
148
  space? >>
148
149
  (
149
- (str("(") >> (iso_identifier >> iso_parameters).as(:alternative) >> str(")") |
150
- str("(") >> (identifier_no_params.as(:alternative) >> str(", ").maybe).repeat(1) >> str(")"))# |
151
- #identifier_no_params.as(:alternative)
150
+ (str("(") >> (identifier_no_params.as(:alternative) >> str(", ").maybe).repeat(1) >> str(")") |
151
+ str("(") >> (iso_identifier >> iso_parameters).as(:alternative) >> str(")")
152
+ )
152
153
  )
153
154
  end
154
155
 
@@ -231,9 +232,9 @@ module Pubid::Ieee
231
232
  (
232
233
  # IEEE P2410-D4, July 2019
233
234
  (draft |
234
- part_subpart_year.maybe >> corrigendum.maybe >> draft.maybe >> iso_amendment.maybe
235
+ part_subpart_year.maybe >> edition.maybe >> corrigendum.maybe >> draft.maybe >> iso_amendment.maybe
235
236
  ) >>
236
- # iso_stage_part_iteration.maybe >>
237
+ iso_stage_part_iteration.repeat >>
237
238
  # ((str("-") | str("/") | str("_")) >> (str("D") >> digits).absent? >>
238
239
  # (iso_parser.typed_stage.as(:stage) | iso_parser.stage.as(:stage))) >> digits.as(:iteration).maybe >>
239
240
  if skip_parameters
@@ -244,7 +245,7 @@ module Pubid::Ieee
244
245
  if skip_parameters
245
246
  str("")
246
247
  else
247
- edition.as(:edition).maybe
248
+ edition.maybe
248
249
  end >>
249
250
  # dual-PubIDs
250
251
  ((without_dual_pubids && str("")) || dual_pubids.maybe) >>
@@ -357,19 +358,21 @@ module Pubid::Ieee
357
358
  (str("P").maybe >> iso_parser.digits).as(:number) >> iso_parser.iteration.maybe >>
358
359
  # for identifiers like ISO 5537/IDF 26
359
360
  (str("|") >> (str("IDF") >> str(" ") >> digits).as(:joint_document)).maybe >>
361
+ (str(":") >> iso_parser.year).maybe >>
360
362
  iso_part_stage_iteration_matcher.maybe >>
361
363
  (str(" ").maybe >> str(":") >> iso_parser.year).maybe >>
362
364
  # stage before amendment
363
- (
364
- # stage before corrigendum
365
- iso_parser.supplement.maybe) >>
365
+ iso_amendment.maybe >>
366
+ corrigendum.maybe >>
367
+ iso_parser.supplement.maybe >>
368
+ (edition | iso_parser.edition ).maybe >>
366
369
  iso_parser.language.maybe).as(:iso_identifier)
367
370
  end
368
371
 
369
372
  rule(:iso_parameters) do
370
373
  iso_amendment.maybe >> (dual_pubid_without_parameters.maybe >>
371
374
  (publication_date >> space? >> str("(E)").maybe).maybe >>
372
- edition.as(:edition).maybe >> draft.maybe >> additional_parameters).as(:parameters)
375
+ edition.maybe >> draft.maybe >> additional_parameters).as(:parameters)
373
376
  end
374
377
 
375
378
  rule(:identifier_before_edition) do
@@ -4,11 +4,19 @@ module Pubid::Ieee::Renderer
4
4
  if params[:iso_identifier].to_s != "" && params[:number] != ""
5
5
  " (%{publisher}%{stage}%{draft_status}%{type}%{number}%{iteration}%{part}%{subpart}%{month}%{year}%{corrigendum_comment}"\
6
6
  "%{corrigendum}%{draft}%{edition})%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\
7
- "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params
7
+ "%{revision}%{iso_amendment}%{amendment}%{edition}%{includes}%{redline}%{adoption}" % params
8
8
  else
9
- "%{publisher}%{stage}%{draft_status}%{type}%{number}%{iteration}%{part}%{subpart}%{month}%{year}%{corrigendum_comment}"\
10
- "%{corrigendum}%{draft}%{edition}%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\
11
- "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params
9
+ if params[:day].empty? && params[:month].empty?
10
+ # if only year - edition and draft after year
11
+ "%{publisher}%{draft_status}%{type}%{number}%{part}%{subpart}%{stage}"\
12
+ "%{year}%{edition}%{corrigendum_comment}%{corrigendum}%{draft}%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\
13
+ "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params
14
+ else
15
+ # if year and month - edition and draft before
16
+ "%{publisher}%{draft_status}%{type}%{number}%{part}%{subpart}%{edition}%{stage}"\
17
+ "%{corrigendum_comment}%{corrigendum}%{draft}%{month}%{day}%{year}%{alternative}%{supersedes}%{reaffirmed}%{incorporates}%{supplement}"\
18
+ "%{revision}%{iso_amendment}%{amendment}%{includes}%{redline}%{adoption}" % params
19
+ end
12
20
  end
13
21
  end
14
22
 
@@ -22,18 +30,30 @@ module Pubid::Ieee::Renderer
22
30
  end
23
31
 
24
32
  def render_type(type, opts, params)
25
- result = type.to_s(params[:publisher] == "IEEE" ? opts[:format] : :alternative)
33
+ result = if params[:publisher] == "IEEE" ||
34
+ (params[:copublisher].is_a?(Array) && params[:copublisher].include?("IEEE") || params[:copublisher] == "IEEE")
35
+ type.to_s(opts[:format])
36
+ else
37
+ type.to_s(:alternative)
38
+ end
26
39
 
27
40
  " #{result}" unless result.empty?
28
- #" #{type}"
29
41
  end
30
42
 
31
43
  def render_part(part, _opts, _params)
32
- "#{part}"
44
+ (part =~ /^[-.]/ ? "" : "-") + part
33
45
  end
34
46
 
35
- def render_month(month, _opts, _params)
36
- ", #{month}"
47
+ def render_day(day, _opts, params)
48
+ # month = Date.parse(params[:month]).month
49
+ # " %s-%s-%02d" % [params[:year], month, day]
50
+ " #{day}"
51
+ end
52
+
53
+ def render_month(month, _opts, params)
54
+ # return if params[:day]
55
+
56
+ ", #{Date::MONTHNAMES[month]}"
37
57
  end
38
58
 
39
59
  def render_corrigendum_comment(corrigendum_comment, _opts, params)
@@ -41,7 +61,10 @@ module Pubid::Ieee::Renderer
41
61
  end
42
62
 
43
63
  def render_year(year, _opts, params)
44
- return " #{year}" if params[:month]
64
+ # return if params[:day]
65
+
66
+ # add comma when day appears before year
67
+ return (params[:day] ? "," : "") + " #{year}" if params[:month]
45
68
 
46
69
  if params[:corrigendum_comment]
47
70
  "-#{params[:corrigendum_comment].year}"
@@ -61,26 +84,27 @@ module Pubid::Ieee::Renderer
61
84
  end
62
85
 
63
86
  def render_edition(edition, _opts, _params)
64
- result = ""
65
- if edition[:version]
66
- result += edition[:version] == "First" ? " Edition 1.0 " : " Edition #{edition[:version]} "
67
- end
68
-
69
- if edition[:year]
70
- result += if edition[:version]
71
- "#{edition[:year]}"
72
- else
73
- " #{edition[:year]} Edition"
74
- end
75
- end
87
+ edition == "First" ? " Edition 1.0" : " Edition #{edition}"
88
+ # result = ""
89
+ # if edition[:version]
90
+ # result +=
91
+ # end
76
92
 
77
- if edition[:month]
78
- month = edition[:month]
79
- month = Date.parse(edition[:month]).month if month.to_i.zero?
80
- result += "-#{sprintf('%02d', month)}"
81
- end
82
- result += "-#{edition[:day]}" if edition[:day]
83
- result
93
+ # if edition[:year]
94
+ # result += if edition[:version]
95
+ # " #{edition[:year]}"
96
+ # else
97
+ # " #{edition[:year]} Edition"
98
+ # end
99
+ # end
100
+ #
101
+ # if edition[:month]
102
+ # month = edition[:month]
103
+ # month = Date.parse(edition[:month]).month if month.to_i.zero?
104
+ # result += "-#{sprintf('%02d', month)}"
105
+ # end
106
+ # result += "-#{edition[:day]}" if edition[:day]
107
+ # result
84
108
  end
85
109
 
86
110
  def render_alternative(alternative, _opts, _params)
@@ -91,14 +115,19 @@ module Pubid::Ieee::Renderer
91
115
  end
92
116
  end
93
117
 
94
- def render_draft(draft, _opts, _params)
118
+ def render_draft(draft, _opts, params)
95
119
  draft = Pubid::Ieee::Identifier.merge_parameters(draft) if draft.is_a?(Array)
96
120
 
97
- result = "/D#{draft[:version].is_a?(Array) ? draft[:version].join('D') : draft[:version]}"
121
+ result = if draft[:version].is_a?(Array)
122
+ "/D#{draft[:version].join('D')}"
123
+ else
124
+ "/#{draft[:version].to_s.match?(/^\d/) ? 'D' : ''}#{draft[:version]}"
125
+ end
126
+ result += "#{params[:iteration]}" if params[:iteration]
98
127
  result += ".#{draft[:revision]}" if draft[:revision]
99
- result += ", #{draft[:month]}" if draft[:month]
100
- result += " #{draft[:day]}," if draft[:day]
101
- result += " #{draft[:year]}" if draft[:year]
128
+ # result += ", #{draft[:month]}" if draft[:month]
129
+ # result += " #{draft[:day]}," if draft[:day]
130
+ # result += " #{draft[:year]}" if draft[:year]
102
131
  result
103
132
  end
104
133
 
@@ -180,5 +209,9 @@ module Pubid::Ieee::Renderer
180
209
  def render_adoption(adoption, opts, _params)
181
210
  " (Adoption of #{Pubid::Ieee::Identifier::Base.transform(**adoption)})"
182
211
  end
212
+
213
+ def render_stage(stage, _opts, _params)
214
+ "/#{stage}"
215
+ end
183
216
  end
184
217
  end
@@ -1,11 +1,11 @@
1
1
  module Pubid::Ieee
2
2
  class Transformer < Parslet::Transform
3
- rule(month: simple(:month), year: simple(:year)) do |date|
4
- update_month_year(date[:month], date[:year])
3
+ rule(month: simple(:month)) do |month|
4
+ { month: update_month(month[:month]) }
5
5
  end
6
6
 
7
- rule(month: simple(:month), year: simple(:year), day: simple(:day)) do |date|
8
- update_month_year(date[:month], date[:year]).merge({ day: date[:day] })
7
+ rule(year: subtree(:year)) do |data|
8
+ { year: update_year(data[:year].is_a?(Array) ? data[:year].first : data[:year]) }
9
9
  end
10
10
 
11
11
  rule(identifier: subtree(:identifier)) do |data|
@@ -16,16 +16,72 @@ module Pubid::Ieee
16
16
  end
17
17
  end
18
18
 
19
+ rule(iso_identifier: subtree(:iso_identifier)) do |data|
20
+ # apply transformer to :iso_identifier => :month
21
+ if data[:iso_identifier].key?(:month)
22
+ data[:iso_identifier][:month] = update_month(data[:iso_identifier][:month])
23
+ end
24
+ # keep identifier in ISO format if it have ISO format Amendment in "supplements"
25
+ if (data[:iso_identifier][:publisher] == "IEEE" ||
26
+ (data[:iso_identifier][:copublisher].is_a?(Array) && data[:iso_identifier][:copublisher].include?("IEEE") ||
27
+ data[:iso_identifier][:copublisher] == "IEEE")) && !data[:iso_identifier].key?(:supplements) &&
28
+ !data[:iso_identifier].key?(:type)
29
+ if data[:iso_identifier].key?(:stage)
30
+ data[:iso_identifier][:draft] = { version: data[:iso_identifier][:stage] }
31
+ data[:iso_identifier][:stage] = nil
32
+ end
33
+ data[:iso_identifier]
34
+ else
35
+ if data[:iso_identifier][:corrigendum]
36
+ corrigendum = data[:iso_identifier][:corrigendum]
37
+ data[:iso_identifier][:supplements] = [
38
+ { type: "cor",
39
+ year: corrigendum[:year],
40
+ number: corrigendum[:version] },
41
+ ]
42
+ data[:iso_identifier].delete(:corrigendum)
43
+ end
44
+
45
+ # type status cannot be rendered in pubid-iso
46
+ data[:iso_identifier].delete(:type_status)
47
+ data
48
+ end
49
+ end
50
+
51
+ rule(stage: simple(:stage)) do |data|
52
+ { draft: { version: data[:stage] } }
53
+ end
54
+
55
+ rule(stage: simple(:stage), iteration: simple(:iteration)) do |data|
56
+ { draft: { version: data[:stage] }, iteration: data[:iteration] }
57
+ end
58
+
59
+ rule(stage: simple(:stage), iteration: simple(:iteration),
60
+ part: simple(:part)) do |data|
61
+ { draft: { version: data[:stage] }, iteration: data[:iteration] }.merge(part: data[:part])
62
+ end
63
+
64
+ def self.update_year(year)
65
+ if year.length == 2
66
+ case year.to_i
67
+ when 0..25 then "20#{year}"
68
+ when 26..99 then "19#{year}"
69
+ end
70
+ else
71
+ year
72
+ end
73
+ end
74
+
75
+ def self.update_month(month)
76
+ return month if month.is_a?(Integer)
77
+
78
+ # add year when only month digits provided to avoid parsing digits as year
79
+ Date.parse("1999/#{month}").month
80
+ end
81
+
19
82
  def self.update_month_year(month, year)
20
- { year: if year.length == 2
21
- case year.to_i
22
- when 0..25 then "20#{year}"
23
- when 26..99 then "19#{year}"
24
- end
25
- else
26
- year
27
- end,
28
- month: Date.parse(month).strftime("%B") }
83
+ { year: update_year(year),
84
+ month: update_month(month) }
29
85
  end
30
86
 
31
87
  rule(type: simple(:type)) do
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Ieee
3
- VERSION = "0.2.1".freeze
3
+ VERSION = "1.15.0".freeze
4
4
  end
5
5
  end
data/update_codes.yaml CHANGED
@@ -54,8 +54,51 @@ IEEE 1023-2020 (Revision of IEEE Std 1023-2004): IEEE No 1023-2020 (Revision of
54
54
  # Remove Unapproved Draft Std for ISO style identifiers with iso stage
55
55
  # using "[A-Z]{2,}" to exclude /D12 (drafts) from match
56
56
  # IEEE Unapproved Draft Std P15026.2/FCD -> IEEE P15026.2/FCD
57
- /(IEEE )(?:Unapproved )?(?:Draft )?Std (P[\d.]+[_/][A-Z]{2,}\d?)/: \1\2
57
+ #/(IEEE )(?:Unapproved )?(?:Draft )?Std (P[\d.]+[_/][A-Z]{2,}\d?)/: \1\2
58
58
  IEEE P90003-2014, April 2015: IEEE P90003, April 2015
59
59
  # Add space between year and month for dates without space, e.g. "Jul2014" -> "Jul 2014"
60
60
  /, (\w{3,4})(\d{4,4})$/: ", \\1 \\2"
61
61
  IEC/IEEE P61886-1_D2_May2020: IEC/IEEE P61886-1_D2, May 2020
62
+ IEEE Unapproved P1076.1/D-3.3-07-Feb20: IEEE Unapproved P1076.1/D-3.3-2007-02
63
+ IEEE Unapproved P11073.10407/D-09-08-Sep20: IEEE Unapproved P11073.10407/D-09-2008-09
64
+ IEEE Unapproved P1597.2/D-7.1-09-Oct20: IEEE Unapproved P1597.2/D7.1-2009-10
65
+ IEEE Unapproved P7.4.3.2/D-3-2010-01: IEEE Unapproved P7-4.3.2/D-3-2010-01
66
+ IEEE Unapproved P802.11k/D-13.0_Mar-08-20: IEEE Unapproved P802.11k/D-13.0-2008-03
67
+ IEEE Unapproved P802.16g/D-8-07-Feb20: IEEE Unapproved P802.16g/D-8-2007-02
68
+ #IEEE Unapproved P802.16_Rev2/D-2-2007: IEEE Unapproved P802.16Rev2/D-2-2007
69
+ IEEE Unapproved P802.1ah/D-4.-2008-02: IEEE Unapproved P802.1ah/D-4-2008-02
70
+ IEEE Unapproved P802.20.2/D-2.0-09-Oct20: IEEE Unapproved P802.20.2/D-2.0-2009-10
71
+ IEEE Unapproved P802.3/D-D1.1/Cor1-2009: IEEE Unapproved P802.3/D1.1/Cor1-2009
72
+ IEEE Unapproved Std PC57.129_D9, Mar07: IEEE Unapproved Std PC57.129_D9, Mar 07
73
+ IEEE Unapproved Draft Std PC62.21_D3, Sep07: IEEE Unapproved Draft Std PC62.21_D3, Sep 07
74
+ IEEE Unapproved Draft Std P2600.2/D41b, Jan09: IEEE Unapproved Draft Std P2600.2/D41b, Jan 09
75
+ IEEE Active Unapproved Draft Std IEEE PC37.06/D8.3, July 2007: IEEE Active Unapproved Draft Std PC37.06/D8.3, July 2007
76
+ IEEE Unapproved Draft Std PC57.21/D14, Dec. 2007: IEEE Unapproved Draft Std PC57.21/D14, Dec 2007
77
+ IEEE Unapproved Draft Std P802.1AB/REVD2.2, Dec 2007: IEEE Unapproved Draft Std P802.1AB/D2.2, Dec 2007
78
+ IEEE Unapproved Draft Std PC37.301/D3 R1, Feb 2008: IEEE Unapproved Draft Std PC37.301/D3.1, Feb 2008
79
+ IEEE Unapproved Draft Std PC37.27/D16_Dec 2007: IEEE Unapproved Draft Std PC37.27/D16, Dec 2007
80
+ IEEE Unapproved Draft Std PC37.13 / D21, Dec 2007: IEEE Unapproved Draft Std PC37.13/D21, Dec 2007
81
+ IEEE Unapproved Draft Std P802.1ah/D4., Feb 2008: IEEE Unapproved Draft Std P802.1ah/D4, Feb 2008
82
+ IEEE Unapproved Draft Std P802.11k_D13.0_Mar 2008: IEEE Unapproved Draft Std P802.11k_D13.0, Mar 2008
83
+ IEEE Unapproved Draft Std P1776/D9b, Feb. 2008: IEEE Unapproved Draft Std P1776/D9b, Feb 2008
84
+ IEEE Unapproved Draft Std PC62.21-2003-Cor_1/D5, Mar 2008: IEEE Unapproved Draft Std PC62.21-2003-Cor1/D5, Mar 2008
85
+ IEEE Unapproved Draft Std P1003.1 Draft 5.1, May 2008: IEEE Unapproved Draft Std P1003.1/D5.1, May 2008
86
+ IEEE Unapproved Draft Std P802-1Qay/D5-0, Jan 09: IEEE Unapproved Draft Std P802-1Qay/D5.0, Jan 09
87
+ IEEE Unapproved Draft Std P1775/1.9.7, Mar 2009: IEEE Unapproved Draft Std P1775/D1.9.7, Mar 2009
88
+ IEEE Unapproved Draft Std P1044/D00005, Aug-2009: IEEE Unapproved Draft Std P1044/D5, Aug 2009
89
+ IEEE Unapproved Draft Std P1584b/ D2, Jul 2009: IEEE Unapproved Draft Std P1584b/D2, Jul 2009
90
+ IEEE Unapproved Draft Std P11073-10421, D6, Oct 2009: IEEE Unapproved Draft Std P11073-10421/D6, Oct 2009
91
+ IEEE Unapproved Draft Std PC37.13.1a/D3. Nov 2009: IEEE Unapproved Draft Std PC37.13.1a/D3, Nov 2009
92
+ IEEE Unapproved Draft Std PC37.082_IEC62271-113/D2, Jan 2010: IEEE Unapproved Draft Std PC37.082/D2, Jan 2010 (IEC 62271-113)
93
+ IEEE Unapproved Draft Std PC37.20.7-2001 Cor 1/D3, Aug 2009: IEEE Unapproved Draft Std PC37.20.7-2001/Cor 1/D3, Aug 2009
94
+ IEEE Unapproved Draft Std PC37.20.7-2007 Cor 1/D4: IEEE Unapproved Draft Std PC37.20.7-2007/Cor 1/D4
95
+ IEEE Unapproved Draft Std P802.3-2008 (P802.3bb)/Cor 1/D1.1, Jan 2009: IEEE Unapproved Draft Std P802.3-2008/Cor 1/D1.1, Jan 2009 (IEEE P802.3bb)
96
+ IEEE Unapproved Draft Std P802.3-2008 (P802.3bb)/Cor 1/D2.0, Jul 2009: IEEE Unapproved Draft Std P802.3-2008/Cor 1/D2.0, Jul 2009 (IEEE P802.3bb)
97
+ IEEE Unapproved Draft Std P16326:2008/CD2, Sep 2008: IEEE P16326:2008/CD2, Sep 2008
98
+ IEEE Unapproved Draft Std 16326:2009: IEEE 16326:2009
99
+ IEEE Unapproved Draft Std PC37.082_IEC62271-113/D2, Jan 2010: IEEE Unapproved Draft Std PC37.082/D2, Jan 2010 (IEC 62271-113)
100
+ Unapproved Draft Std ISO/IEC FDIS 15288:2007(E) IEEE P15288/D3: IEEE Unapproved Draft Std P15288/D3 (ISO/IEC FDIS 15288:2007(E))
101
+ IEEE Unapproved Draft Std P1635/ASHRAE 21_D4, Jan 2010: IEEE Unapproved Draft Std P1635/D4, January 2010 (ASHRAE 21)
102
+ IEC/IEEE 62582-1:2011 Edition 1.0 2011-08: IEC/IEEE 62582-1-2011 Edition 1.0 2011-08
103
+ ISO/IEC/IEEE CD P26513/D1, August 2015: ISO/IEC/IEEE P26513/D1, August 2015
104
+ /C37.0I0d-1984/: C37.010d-1984
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-17 00:00:00.000000000 Z
11
+ date: 2025-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '13.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '13.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: parslet
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +28,16 @@ dependencies:
56
28
  name: pubid-iso
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
- - - "~>"
31
+ - - '='
60
32
  - !ruby/object:Gem::Version
61
- version: '0.7'
33
+ version: 1.15.0
62
34
  type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
- - - "~>"
38
+ - - '='
67
39
  - !ruby/object:Gem::Version
68
- version: '0.7'
40
+ version: 1.15.0
69
41
  description: Library to generate, parse and manipulate IEEE PubID.
70
42
  email:
71
43
  - open.source@ribose.com
@@ -92,7 +64,7 @@ homepage: https://github.com/metanorma/pubid-ieee
92
64
  licenses:
93
65
  - BSD-2-Clause
94
66
  metadata: {}
95
- post_install_message:
67
+ post_install_message:
96
68
  rdoc_options: []
97
69
  require_paths:
98
70
  - lib
@@ -107,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
79
  - !ruby/object:Gem::Version
108
80
  version: '0'
109
81
  requirements: []
110
- rubygems_version: 3.3.26
111
- signing_key:
82
+ rubygems_version: 3.5.22
83
+ signing_key:
112
84
  specification_version: 4
113
85
  summary: Library to generate, parse and manipulate IEEE PubID.
114
86
  test_files: []