pubid-iec 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pubid/iec/configuration.rb +9 -0
  3. data/lib/pubid/iec/errors.rb +2 -1
  4. data/lib/pubid/iec/identifier/amendment.rb +19 -1
  5. data/lib/pubid/iec/identifier/base.rb +43 -23
  6. data/lib/pubid/iec/identifier/component_specification.rb +1 -1
  7. data/lib/pubid/iec/identifier/conformity_assessment.rb +1 -1
  8. data/lib/pubid/iec/identifier/corrigendum.rb +19 -1
  9. data/lib/pubid/iec/identifier/guide.rb +14 -1
  10. data/lib/pubid/iec/identifier/international_standard.rb +5 -1
  11. data/lib/pubid/iec/identifier/interpretation_sheet.rb +10 -2
  12. data/lib/pubid/iec/identifier/operational_document.rb +1 -1
  13. data/lib/pubid/iec/identifier/publicly_available_specification.rb +9 -1
  14. data/lib/pubid/iec/identifier/societal_technology_trend_report.rb +1 -1
  15. data/lib/pubid/iec/identifier/systems_reference_document.rb +1 -1
  16. data/lib/pubid/iec/identifier/technical_report.rb +10 -2
  17. data/lib/pubid/iec/identifier/technical_specification.rb +10 -2
  18. data/lib/pubid/iec/identifier/technology_report.rb +1 -1
  19. data/lib/pubid/iec/identifier/test_report_form.rb +1 -1
  20. data/lib/pubid/iec/identifier/white_paper.rb +1 -1
  21. data/lib/pubid/iec/identifier/working_document.rb +7 -3
  22. data/lib/pubid/iec/identifier.rb +4 -0
  23. data/lib/pubid/iec/parser.rb +1 -1
  24. data/lib/pubid/iec/renderer/interpretation_sheet.rb +4 -4
  25. data/lib/pubid/iec/renderer/pubid.rb +3 -3
  26. data/lib/pubid/iec/renderer/urn.rb +1 -1
  27. data/lib/pubid/iec/stage.rb +27 -3
  28. data/lib/pubid/iec/trf_identifier.rb +1 -1
  29. data/lib/pubid/iec/typed_project_stage.rb +36 -0
  30. data/lib/pubid/iec/version.rb +1 -1
  31. data/lib/pubid/iec.rb +3 -1
  32. data/stages.yaml +73 -14
  33. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1873b70daa92fcd0ca9a5a4db60a23bf2e7ec228f2036f1a81a06a589f3e5c67
4
- data.tar.gz: b01fc14aeed19ecae83b61a7ad57c9899c584ca88a4d5144dc4db0a39a6abbc8
3
+ metadata.gz: 3e57bcfb0e8b8e333e16b5fae2f8103cc7fb3c755717f55afd485f5d100931e4
4
+ data.tar.gz: 57af222f9db3651ec847af8b5b21ec0715eeadf0883df955de4cc69ccf2b7b72
5
5
  SHA512:
6
- metadata.gz: a84aede1cc1d76a1fe2e59d7d944e05e9ea087d3687616b9331be21625b103fb1be16645fcada73869b197b2e8b27b5ddd843546fbc819508a9e08185881625b
7
- data.tar.gz: 9c397e13902622f6bcbd4b18984c74d814f10005269e32938838580ec1774ed8088ce9b54622d25c497091789702d46c614634dc09662c3a85e77083806a5576
6
+ metadata.gz: bcb6be5089d7225c204df7209102cb429e13eebaf4782097edfc664a588e536d19dfdbd4d3f8bc2e27e8456772c996c7fb5dd1ceb59f47e1400f7fd0627c55ca
7
+ data.tar.gz: 838eb82be8b4385f99f028e87fcf301b7f128901369309adaffaee00ec245e36132581111f658b60e66aae6a3b448ccd3571d7cbcb8f3f447895823aff836d1b
@@ -0,0 +1,9 @@
1
+ module Pubid::Iec
2
+ class Configuration < Pubid::Core::Configuration
3
+ def typed_project_stages
4
+ types.inject({}) do |res, type|
5
+ res.merge(type::PROJECT_STAGES)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,8 +1,9 @@
1
1
  module Pubid::Iec
2
2
  module Errors
3
3
  class StageParseError < StandardError; end
4
- class StageInvalidError < StandardError; end
5
4
  class ParseTypeError < StandardError; end
6
5
  class WrongTypeError < StandardError; end
6
+ class ProjectStageInvalidError < StandardError; end
7
+ class ProjectStageConversionError < StandardError; end
7
8
  end
8
9
  end
@@ -6,6 +6,24 @@ module Pubid::Iec
6
6
  class Amendment < Supplement
7
7
  def_delegators 'Pubid::Iec::Identifier::Amendment', :type
8
8
 
9
+ TYPED_STAGES = {
10
+ cdam: {
11
+ abbr: "CDAM",
12
+ name: "Committee Draft Ammendment",
13
+ harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
14
+ },
15
+ dcor: {
16
+ abbr: "DAM",
17
+ name: "Draft Ammendment",
18
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.98 40.99],
19
+ },
20
+ fdcor: {
21
+ abbr: "FDAM",
22
+ name: "Final Draft Ammendment",
23
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
24
+ }
25
+ }.freeze
26
+
9
27
  def self.type
10
28
  { key: :amd, title: "Amendment" }
11
29
  end
@@ -15,7 +33,7 @@ module Pubid::Iec
15
33
  end
16
34
 
17
35
  def urn
18
- Renderer::UrnAmendment.new(get_params).render
36
+ Renderer::UrnAmendment.new(renderer_data).render
19
37
  end
20
38
  end
21
39
  end
@@ -9,32 +9,15 @@ module Pubid::Iec
9
9
 
10
10
  extend Forwardable
11
11
 
12
+ PROJECT_STAGES = {}.freeze
13
+
12
14
  # @param stage [String] stage eg. "PWI", "PNW"
13
- def initialize(publisher: "IEC", stage: nil, vap: nil, database: nil,
15
+ def initialize(publisher: "IEC", vap: nil, database: nil,
14
16
  fragment: nil, version: nil, decision_sheet: nil,
15
17
  conjuction_part: nil, part_version: nil, trf_publisher: nil,
16
18
  trf_series: nil, trf_version: nil, test_type: nil,
17
19
  edition: nil, type: nil, month: nil, day: nil,
18
- language: nil, **args)
19
- # @stage = stage.to_s if stage
20
- # @stage = Stage.parse(stage) if stage
21
-
22
- if stage
23
- if stage.is_a?(Stage)
24
- @stage = stage
25
- @typed_stage = resolve_typed_stage(@stage.harmonized_code) unless @stage.abbr
26
- elsif self.class.has_typed_stage?(stage)
27
- @typed_stage, @stage = self.class.find_typed_stage(stage)
28
- else
29
- @stage = Identifier.parse_stage(stage)
30
- # resolve typed stage when harmonized code provided as stage
31
- # or stage abbreviation was not resolved
32
- if /\A[\d.]+\z/.match?(stage) || @stage.empty_abbr?(with_prf: true)
33
- @typed_stage = self.class.resolve_typed_stage(@stage.harmonized_code)
34
- end
35
- end
36
- @typed_stage = self.class::TYPED_STAGES[@typed_stage][:abbr] if @typed_stage
37
- end
20
+ language: nil, stage: nil, **args)
38
21
 
39
22
  @vap = vap.to_s if vap
40
23
  @database = database if database
@@ -52,18 +35,47 @@ module Pubid::Iec
52
35
  @day = day if day
53
36
  @language = language if language
54
37
 
38
+ if stage
39
+ @stage = self.class.has_project_stage?(stage) ? self.class.resolve_project_stage(stage) : resolve_stage(stage)
40
+ end
41
+
55
42
  super(**args.merge(publisher: publisher))
56
43
  end
57
44
 
58
45
  def urn
59
- Renderer::Urn.new(get_params).render
46
+ Renderer::Urn.new(renderer_data).render
47
+ end
48
+
49
+ def lookup_typed_stage(lookup_code)
50
+ self.class::TYPED_STAGES.each do |abbr, stage|
51
+ if stage[:harmonized_stages] & lookup_code == lookup_code
52
+ return Identifier.build_typed_stage(abbr: abbr, harmonized_code: lookup_code)
53
+ end
54
+ end
55
+
56
+ nil
57
+ end
58
+
59
+ def renderer_data
60
+ values = to_h(deep: false)
61
+
62
+ # convert project stage to typed stage
63
+ if values.key?(:stage) && values[:stage].is_a?(TypedProjectStage)
64
+ values[:stage] = lookup_typed_stage(values[:stage].harmonized_code.stages) ||
65
+ resolve_stage(values[:stage].harmonized_code.stages.first)
66
+ end
67
+ values
60
68
  end
61
69
 
62
70
  def to_s(with_edition_month_date: false)
63
- self.class.get_renderer_class.new(get_params).render(with_edition_month_date: with_edition_month_date)
71
+ self.class.get_renderer_class.new(renderer_data).render(with_edition_month_date: with_edition_month_date)
64
72
  end
65
73
 
66
74
  class << self
75
+ def has_project_stage?(project_stage)
76
+ self::PROJECT_STAGES.any? { |k, v| v[:abbr] == project_stage }
77
+ end
78
+
67
79
  def has_type?(type)
68
80
  return type == self.type[:key] if type.is_a?(Symbol)
69
81
 
@@ -74,6 +86,14 @@ module Pubid::Iec
74
86
  end
75
87
  end
76
88
 
89
+ def resolve_project_stage(project_stage)
90
+ stage = self::PROJECT_STAGES.find do |k, v|
91
+ v[:abbr] == project_stage
92
+ end
93
+
94
+ Identifier.build_project_stage(abbr: stage[1][:abbr], harmonized_code: stage[1][:harmonized_stages])
95
+ end
96
+
77
97
  def transform_hash(params)
78
98
  params.map do |k, v|
79
99
  get_transformer_class.new.apply(k => v.is_a?(Hash) ? transform_hash(v) : v)
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :cs, title: "Component Specification", short: "CS" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "CS")
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :ca, title: "Conformity Assessment", short: "CA" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "CA")
12
12
  end
13
13
  end
@@ -6,6 +6,24 @@ module Pubid::Iec
6
6
  class Corrigendum < Supplement
7
7
  def_delegators 'Pubid::Iec::Identifier::Corrigendum', :type
8
8
 
9
+ TYPED_STAGES = {
10
+ cdcor: {
11
+ abbr: "CDCor",
12
+ name: "Committee Draft Corrigendum",
13
+ harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
14
+ },
15
+ dcor: {
16
+ abbr: "DCOR",
17
+ name: "Draft Corrigendum",
18
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.98 40.99],
19
+ },
20
+ fdcor: {
21
+ abbr: "FDCOR",
22
+ name: "Final Draft Corrigendum",
23
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
24
+ }
25
+ }.freeze
26
+
9
27
  def self.type
10
28
  { key: :cor, title: "Corrigendum" }
11
29
  end
@@ -15,7 +33,7 @@ module Pubid::Iec
15
33
  end
16
34
 
17
35
  def urn
18
- Renderer::UrnCorrigendum.new(get_params).render
36
+ Renderer::UrnCorrigendum.new(renderer_data).render
19
37
  end
20
38
  end
21
39
  end
@@ -3,11 +3,24 @@ module Pubid::Iec
3
3
  class Guide < Base
4
4
  def_delegators 'Pubid::Iec::Identifier::Guide', :type
5
5
 
6
+ TYPED_STAGES = {
7
+ dguide: {
8
+ abbr: "DGuide",
9
+ name: "Draft Guide",
10
+ harmonized_stages: %w[40.00 40.20 40.60 40.92 40.98 40.99],
11
+ },
12
+ fdguide: {
13
+ abbr: "FDGuide",
14
+ name: "Final Draft Guide",
15
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
16
+ }
17
+ }.freeze
18
+
6
19
  def self.type
7
20
  { key: :guide, title: "Guide", short: %w[Guide GUIDE] }
8
21
  end
9
22
 
10
- def get_params
23
+ def to_h(deep: false)
11
24
  super.merge(type: "Guide")
12
25
  end
13
26
  end
@@ -4,6 +4,10 @@ module Pubid::Iec
4
4
  def_delegators 'Pubid::Iec::Identifier::InternationalStandard', :type
5
5
 
6
6
  TYPED_STAGES = {
7
+
8
+ }.freeze
9
+
10
+ PROJECT_STAGES = {
7
11
  afdis: {
8
12
  abbr: "AFDIS",
9
13
  name: "Approved for FDIS",
@@ -62,7 +66,7 @@ module Pubid::Iec
62
66
  }.freeze
63
67
 
64
68
  def self.type
65
- { key: :is, title: "International Standard", short: "IS" }
69
+ { key: :is, title: "International Standard", short: nil }
66
70
  end
67
71
  end
68
72
  end
@@ -7,8 +7,16 @@ module Pubid::Iec
7
7
  cdish: {
8
8
  abbr: "CDISH",
9
9
  name: "Draft circulated as DISH",
10
- harmonized_stages: %w[50.20],
10
+ harmonized_stages: %w[30.00 30.20 30.60 30.92 30.98 30.99],
11
11
  },
12
+ dish: {
13
+ abbr: "DISH",
14
+ name: "Draft Interpretation Sheet",
15
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
16
+ }
17
+ }.freeze
18
+
19
+ PROJECT_STAGES = {
12
20
  decdish: {
13
21
  abbr: "DECDISH",
14
22
  name: "DISH at editing check",
@@ -37,7 +45,7 @@ module Pubid::Iec
37
45
  end
38
46
 
39
47
  def self.type
40
- { key: :ish, title: "InterpretationSheet", short: "ISH" }
48
+ { key: :ish, title: "Interpretation Sheet", short: "ISH" }
41
49
  end
42
50
 
43
51
  def self.get_renderer_class
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :od, title: "Operational Document", short: "OD" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "OD")
12
12
  end
13
13
  end
@@ -9,6 +9,14 @@ module Pubid::Iec
9
9
  name: "Draft circulated as DPAS",
10
10
  harmonized_stages: %w[50.20],
11
11
  },
12
+ dpas: {
13
+ abbr: "DPAS",
14
+ name: "Draft Publicly Available Specification",
15
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
16
+ }
17
+ }.freeze
18
+
19
+ PROJECT_STAGES = {
12
20
  PRVDPAS: {
13
21
  abbr: "PRVDPAS",
14
22
  name: "Preparation of RVDPAS",
@@ -20,7 +28,7 @@ module Pubid::Iec
20
28
  { key: :pas, title: "Publicly Available Specification", short: "PAS" }
21
29
  end
22
30
 
23
- def get_params
31
+ def to_h(deep: false)
24
32
  super.merge(type: "PAS")
25
33
  end
26
34
  end
@@ -8,7 +8,7 @@ module Pubid::Iec
8
8
  { key: :sttr, title: "Societal and Technology Trend Report", short: "Trend Report" }
9
9
  end
10
10
 
11
- def get_params
11
+ def to_h(deep: false)
12
12
  super.merge(type: "Trend Report")
13
13
  end
14
14
  end
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :srd, title: "Systems Reference Document", short: "SRD" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "SRD")
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@ module Pubid::Iec
3
3
  class TechnicalReport < Base
4
4
  def_delegators 'Pubid::Iec::Identifier::TechnicalReport', :type
5
5
 
6
- TYPED_STAGES = {
6
+ PROJECT_STAGES = {
7
7
  adtr: {
8
8
  abbr: "ADTR",
9
9
  name: "Approved for DTR",
@@ -36,11 +36,19 @@ module Pubid::Iec
36
36
  }
37
37
  }.freeze
38
38
 
39
+ TYPED_STAGES = {
40
+ dtr: {
41
+ abbr: "DTR",
42
+ name: "Draft Technical Report",
43
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
44
+ }
45
+ }.freeze
46
+
39
47
  def self.type
40
48
  { key: :tr, title: "Technical Report", short: "TR" }
41
49
  end
42
50
 
43
- def get_params
51
+ def to_h(deep: false)
44
52
  super.merge(type: "TR")
45
53
  end
46
54
  end
@@ -1,7 +1,7 @@
1
1
  module Pubid::Iec
2
2
  module Identifier
3
3
  class TechnicalSpecification < Base
4
- TYPED_STAGES = {
4
+ PROJECT_STAGES = {
5
5
  adts: {
6
6
  abbr: "ADTS",
7
7
  name: "Approved for DTS",
@@ -34,13 +34,21 @@ module Pubid::Iec
34
34
  },
35
35
  }.freeze
36
36
 
37
+ TYPED_STAGES = {
38
+ dts: {
39
+ abbr: "DTS",
40
+ name: "Draft Technical Specification",
41
+ harmonized_stages: %w[50.00 50.20 50.60 50.92 50.98 50.99],
42
+ }
43
+ }.freeze
44
+
37
45
  def_delegators 'Pubid::Iec::Identifier::TechnicalSpecification', :type
38
46
 
39
47
  def self.type
40
48
  { key: :ts, title: "Technical Specification", short: "TS" }
41
49
  end
42
50
 
43
- def get_params
51
+ def to_h(deep: true)
44
52
  super.merge(type: "TS")
45
53
  end
46
54
  end
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :tec, title: "Technology Report", short: "Technology Report" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "Technology Report")
12
12
  end
13
13
  end
@@ -23,7 +23,7 @@ module Pubid::Iec
23
23
  end
24
24
 
25
25
  def urn
26
- Renderer::TrfUrn.new(get_params).render
26
+ Renderer::TrfUrn.new(renderer_data).render
27
27
  end
28
28
 
29
29
  class << self
@@ -7,7 +7,7 @@ module Pubid::Iec
7
7
  { key: :wp, title: "Write Paper", short: "White Paper" }
8
8
  end
9
9
 
10
- def get_params
10
+ def to_h(deep: false)
11
11
  super.merge(type: "White Paper")
12
12
  end
13
13
  end
@@ -15,14 +15,18 @@ module Pubid::Iec
15
15
 
16
16
  attr_accessor :technical_committee
17
17
 
18
- def initialize(publisher: "IEC", technical_committee: nil, **args)
18
+ def initialize(publisher: "IEC", technical_committee: nil, stage: nil, **args)
19
19
  super(**args.merge(publisher: publisher))
20
-
20
+ @stage = stage
21
21
  @technical_committee = technical_committee
22
22
  end
23
23
 
24
24
  def urn
25
- Renderer::WorkingDocumentUrn.new(get_params).render
25
+ Renderer::WorkingDocumentUrn.new(renderer_data).render
26
+ end
27
+
28
+ def renderer_data
29
+ to_h(deep: false)
26
30
  end
27
31
 
28
32
  class << self
@@ -6,6 +6,10 @@ module Pubid::Iec
6
6
  def parse(*args)
7
7
  Base.parse(*args)
8
8
  end
9
+
10
+ def build_project_stage(**args)
11
+ TypedProjectStage.new(config: @config, **args)
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -8,7 +8,7 @@ module Pubid::Iec
8
8
  end
9
9
 
10
10
  rule(:stage) do
11
- array_to_str(Renderer::Urn::STAGES.keys)
11
+ array_to_str(Identifier.config.typed_stages.map { |_, v| v[:abbr] } + Identifier.config.stages["abbreviations"].keys)
12
12
  end
13
13
 
14
14
  rule(:type) do
@@ -1,13 +1,13 @@
1
1
  module Pubid::Iec::Renderer
2
2
  class InterpretationSheet < Pubid
3
3
  def render_identifier(params)
4
- type_prefix = params[:typed_stage].nil? || params[:typed_stage].empty? ? "ISH" : ""
4
+ type_prefix = params[:stage].nil? || params[:stage].to_s.empty? ? "ISH" : ""
5
5
 
6
- "%{base}/%{typed_stage}#{type_prefix}%{number}%{year}" % params
6
+ "%{base}/%{stage}#{type_prefix}%{number}%{year}" % params
7
7
  end
8
8
 
9
- def render_typed_stage(typed_stage, _opts, _params)
10
- typed_stage
9
+ def render_stage(stage, _opts, _params)
10
+ stage
11
11
  end
12
12
 
13
13
  def render_year(year, _opts, _params)
@@ -9,8 +9,8 @@ module Pubid::Iec::Renderer
9
9
  " #{typed_stage}"
10
10
  end
11
11
 
12
- def render_type(type, _opts, _params)
13
- return if params[:typed_stage]
12
+ def render_type(type, _opts, params)
13
+ return if params[:stage].is_a?(::Pubid::Core::TypedStage)
14
14
 
15
15
  " #{type}"
16
16
  end
@@ -20,7 +20,7 @@ module Pubid::Iec::Renderer
20
20
  end
21
21
 
22
22
  def render_stage(stage, _opts, params)
23
- return if params[:typed_stage]
23
+ return if params[:typed_stage] || stage.abbr.nil?
24
24
 
25
25
  " #{stage}"
26
26
  end
@@ -88,7 +88,7 @@ module Pubid::Iec::Renderer
88
88
  end
89
89
 
90
90
  def render_stage(stage, _opts, params)
91
- ":stage-#{sprintf('%05.2f', stage.to_s(:urn))}"
91
+ ":stage-#{sprintf('%s', stage.to_s(:urn))}"
92
92
  end
93
93
 
94
94
  def render_type(type, _, _)
@@ -1,12 +1,36 @@
1
1
  module Pubid::Iec
2
2
  class Stage < Pubid::Core::Stage
3
3
 
4
- def to_s(format = :short)
5
- return "" if empty_abbr?
4
+ def initialize(config:, abbr: nil, harmonized_code: nil)
5
+ @config = config
6
+ @abbr = abbr&.to_s
7
+
8
+ if harmonized_code
9
+ @harmonized_code = if harmonized_code.is_a?(Pubid::Core::HarmonizedStageCode)
10
+ harmonized_code
11
+ else
12
+ Pubid::Core::HarmonizedStageCode.new(harmonized_code, config: config)
13
+ end
14
+ @abbr ||= lookup_abbr(@harmonized_code.stages)
15
+ end
16
+
17
+ if abbr
18
+ if config.stages["project_stages"].key?(abbr.to_s)
19
+ @harmonized_code ||= Pubid::Core::HarmonizedStageCode.new(config.stages["project_stages"][abbr.to_s], config: config)
20
+ # update abbreviation with identifier's stage
21
+ @abbr = lookup_abbr(@harmonized_code.stages)
22
+ else
23
+ raise Pubid::Core::Errors::StageInvalidError, "#{abbr} is not valid stage" unless config.stages["abbreviations"].key?(abbr.to_s)
6
24
 
25
+ @harmonized_code ||= Pubid::Core::HarmonizedStageCode.new(lookup_code(abbr), config: config)
26
+ end
27
+ end
28
+ end
29
+
30
+ def to_s(format = :short)
7
31
  case format
8
32
  when :short
9
- abbr
33
+ empty_abbr? ? "" : abbr
10
34
  else
11
35
  @harmonized_code.to_s
12
36
  end
@@ -18,7 +18,7 @@ module Pubid::Iec
18
18
  end
19
19
 
20
20
  def urn
21
- Renderer::TrfUrn.new(get_params).render
21
+ Renderer::TrfUrn.new(renderer_data).render
22
22
  end
23
23
 
24
24
  class << self
@@ -0,0 +1,36 @@
1
+ module Pubid::Iec
2
+ class TypedProjectStage < Stage
3
+ attr_accessor :config, :abbr
4
+
5
+ # @param config [Configuration]
6
+ # @param abbr [Symbol] typed stage symbol, e.g. :dtr
7
+ # @param harmonized_code [String, Float, HarmonizedStageCode]
8
+ def initialize(config:, abbr:, harmonized_code: nil)
9
+ @config = config
10
+ @abbr = abbr
11
+
12
+ if harmonized_code
13
+ @harmonized_code = if harmonized_code.is_a?(Pubid::Core::HarmonizedStageCode)
14
+ harmonized_code
15
+ else
16
+ Pubid::Core::HarmonizedStageCode.new(harmonized_code, config: config)
17
+ end
18
+ end
19
+
20
+ raise Errors::ProjectStageInvalidError, "#{abbr} is not valid project stage" unless config.typed_project_stages.any? { |k, v| v[:abbr] == abbr }
21
+ end
22
+
23
+ # Compares one stage with another
24
+ # should return false if
25
+ def ==(other)
26
+ return false unless other.is_a?(self.class)
27
+
28
+ other&.harmonized_code == harmonized_code
29
+ end
30
+
31
+ def to_s(_opts = nil)
32
+ abbr
33
+ # config.typed_project_stages[abbr][:abbr]
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iec
3
- VERSION = "0.2.5".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
5
5
  end
data/lib/pubid/iec.rb CHANGED
@@ -10,6 +10,7 @@ end
10
10
  require "pubid-core"
11
11
  require_relative "iec/errors"
12
12
  require_relative "iec/stage"
13
+ require_relative "iec/typed_project_stage"
13
14
  require_relative "iec/parser"
14
15
  require_relative "iec/trf_parser"
15
16
  require_relative "iec/renderer/pubid"
@@ -43,8 +44,9 @@ require_relative "iec/identifier/working_document"
43
44
  require_relative "iec/trf_identifier"
44
45
  require_relative "iec/identifier"
45
46
  require_relative "iec/working_document"
47
+ require_relative "iec/configuration"
46
48
 
47
- config = Pubid::Core::Configuration.new
49
+ config = Pubid::Iec::Configuration.new
48
50
  config.stages = YAML.load_file(File.join(File.dirname(__FILE__), "../../stages.yaml"))
49
51
  config.stage_class = Pubid::Iec::Stage
50
52
  config.default_type = Pubid::Iec::Identifier::InternationalStandard
data/stages.yaml CHANGED
@@ -1,25 +1,76 @@
1
1
  abbreviations:
2
+ PWI: ["00.00", "00.20", "00.60", "00.98", "00.99"]
3
+ PNW: ["10.20"]
4
+ NP: ["10.00", "10.60", "10.98", "10.92"]
5
+ ANW: ["10.99", "20.00"]
6
+ WD: [ "20.20", "20.60", "20.98", "20.99" ]
7
+ CD: ["30.00", "30.20", "30.60", "30.92", "30.98", "30.99"]
8
+ CDV: [ "40.00", "40.20", "40.60", "40.92", "40.98", "40.99" ]
9
+
10
+ project_stages:
2
11
  ACD: "20.99"
3
- ACDV: "30.99"
4
12
  APUB: "50.99"
5
13
  BPUB: "60.00"
6
- CAN: "30.98"
7
- CD: "30.20"
14
+ CAN: ["30.98", "50.98"]
8
15
  CDM: "30.60"
9
16
  DECPUB: "60.00"
10
- DEL: "10.98"
17
+ DEL: ["10.98", "20.98"]
11
18
  DELPUB: "99.60"
12
19
  MERGED: "30.97"
13
- PCC: "30.60"
14
- PNW: "10.20"
15
- PPUB: "60.60"
16
- PRVN: "10.60"
17
- PWI: "00.00"
18
- RPUB: "60.00"
19
- SPLIT: "30.96"
20
- TCDV: "40.00"
21
- TPUB: "60.00"
22
- WPUB: "95.99"
20
+
21
+ names:
22
+ ACD: Approved for CD
23
+ ACDV: Approved for CDV
24
+ ADTR: Approved for DTR
25
+ ADTS: Approved for DTS
26
+ AFDIS: Approved for FDIS
27
+ APUB: Approved for publication
28
+ BPUB: Being published
29
+ CAN: Draft cancelled
30
+ CD: Draft circulated as CD
31
+ CDM: CD to be discussed at meeting
32
+ CCDV: Draft circulated as CDV
33
+ CDISH: Draft circulated as DISH
34
+ CDVM: Rejected CDV to be discussed at a meeting
35
+ CFDIS: Draft circulated as FDIS
36
+ CDPAS: Draft circulated as DPAS
37
+ CDTR: Draft circulated as DTR
38
+ CDTS: Draft circulated as DTS
39
+ DTRM: Rejected DTR to be discussed at meeting
40
+ DTSM: Rejected DTS to be discussed at meeting
41
+ DECDISH: DISH at editing check
42
+ DECFDIS: FDIS at editing check
43
+ DECPUB: Publication at editing check
44
+ DEL: Deleted/abandoned
45
+ DELPUB: Deleted publication
46
+ NCDV: CDV rejected
47
+ NDTR: DTR rejected
48
+ NDTS: DTS rejected
49
+ NFDIS: FDIS rejected
50
+ PCC: Preparation of CC
51
+ PNW: New work item proposal
52
+ PPUB: Publication issued
53
+ PRVC: Preparation of RVC
54
+ PRVDISH: Preparation of RVDISH
55
+ PRVD: Preparation of RVD
56
+ PRVDPAS: Preparation of RVDPAS
57
+ PRVDTR: Preparation of RVDTR
58
+ PRVDTS: Preparation of RVDTS
59
+ PRVN: Preparation of RVN
60
+ PWI: Preliminary work item
61
+ RDISH: DISH received and registered
62
+ RFDIS: FDIS received and registered
63
+ RPUB: Publication received and registered
64
+ TCDV: Translation of CDV
65
+ TDISH: Translation of DISH
66
+ TDTR: Translation of DTR
67
+ TDTS: Translation of DTS
68
+ TPUB: Translation of publication
69
+ WPUB: Publication withdrawn
70
+ WD: Working Draft
71
+ NP: New Proposal
72
+ CDV: Committee Draft for Vote
73
+ ANW: Registration of new project
23
74
 
24
75
  codes_description:
25
76
  "00.00": Proposal for new project received
@@ -68,3 +119,11 @@ codes_description:
68
119
  "95.60": Close of voting
69
120
  "95.92": Decision not to withdraw International Standard
70
121
  "95.99": Withdrawal of International Standard
122
+
123
+ draft_codes: ["00.00", "00.20", "00.60", "00.99", "10.00", "10.20", "10.60", "10.92",
124
+ "10.99", "20.00", "20.20", "20.60", "20.99", "30.00",
125
+ "30.20", "30.60", "30.92", "30.99", "40.00", "40.20", "40.60", "40.92",
126
+ "40.93", "40.99", "50.00", "50.20", "50.60", "50.92", "50.99"]
127
+
128
+ canceled_codes: ["00.98", "10.98", "20.98", "30.98", "40.98", "50.98", "95.99"]
129
+ published_codes: ["60.00", "60.60", "90.20", "90.60", "90.92", "90.93", "90.99", "95.20", "95.60", "95.92"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
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-08-06 00:00:00.000000000 Z
11
+ date: 2024-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.8.6
61
+ version: 1.12.2
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.6
68
+ version: 1.12.2
69
69
  description: Library to generate, parse and manipulate IEC PubID.
70
70
  email:
71
71
  - open.source@ribose.com
@@ -79,6 +79,7 @@ files:
79
79
  - README.adoc
80
80
  - lib/pubid-iec.rb
81
81
  - lib/pubid/iec.rb
82
+ - lib/pubid/iec/configuration.rb
82
83
  - lib/pubid/iec/errors.rb
83
84
  - lib/pubid/iec/identifier.rb
84
85
  - lib/pubid/iec/identifier/amendment.rb
@@ -117,6 +118,7 @@ files:
117
118
  - lib/pubid/iec/transformer.rb
118
119
  - lib/pubid/iec/trf_identifier.rb
119
120
  - lib/pubid/iec/trf_parser.rb
121
+ - lib/pubid/iec/typed_project_stage.rb
120
122
  - lib/pubid/iec/version.rb
121
123
  - lib/pubid/iec/working_document.rb
122
124
  - lib/pubid/iec/working_document_parser.rb