pubid-core 1.11.0 → 1.12.0

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: 0b73ed4ff507dfe5cb2c7b506eaa392ef6fbf3af9b2ff0d500151a430d0a8d2c
4
- data.tar.gz: 46108a14c2cbb1446085668ab46a8b60837e596a8a893f2f2731a2b247c6d7c2
3
+ metadata.gz: 8752ce15b475a7cf21261ea7d1cac28e181052b6a888487a93f89c679bc3a317
4
+ data.tar.gz: 85f903a2d68b26497c832a41255a571ba76b55f56c754f277ca1b6a27ccde9ca
5
5
  SHA512:
6
- metadata.gz: 93fcaaf9757fc059fe26cfd9506c5d42806e56e6f1abd1a86d2464abdfcb64cba933e777813d988e06abe997099504a5e8f632fe08784c926fea105916301643
7
- data.tar.gz: d84b1ac6d760d5de765e87e041ad82a5dd7c76c762f69cb5a56074376981d7a0a13929162a462fd421144c1042042a51eae1c9cbb51433b7a4c9f377713d8ea5
6
+ metadata.gz: 87c242c84385cbdceb1e711ea16ebf96b844d591e900e75923fe1812ffff1a7ab5383ca8442e22a562a2d89b0cd910364a145c0044ce71ab8380c956dab7eba2
7
+ data.tar.gz: aa97a199ccaec9ddda10615c339308d64240d28f2bebf32075f50b17d34776b1f0d25d87f278498d6f4d79cb07291a5a1250c11d81446184c163d5a7637998b7
@@ -102,8 +102,8 @@ module Pubid::Core
102
102
 
103
103
  # Return typed stage name, eg. "Final Draft Technical Report" for "FDTR"
104
104
  def typed_stage_name
105
- if self.class::TYPED_STAGES.key?(stage&.typed_stage)
106
- return self.class::TYPED_STAGES[stage.typed_stage][:name]
105
+ if stage.is_a?(TypedStage) && self.class::TYPED_STAGES.key?(stage.abbr)
106
+ return self.class::TYPED_STAGES[stage.abbr][:name]
107
107
  end
108
108
 
109
109
  stage ? "#{stage.name} #{self.class.type[:title]}" : self.class.type[:title]
@@ -113,15 +113,9 @@ module Pubid::Core
113
113
  # @return [[nil, Stage], [Symbol, Stage]] typed stage and stage values
114
114
  def resolve_stage(stage)
115
115
  if stage.is_a?(Stage)
116
- # return [nil, stage] if stage.abbr
117
- # return stage if stage.abbr
116
+ return self.class.resolve_typed_stage(stage.harmonized_code) || stage unless stage.abbr
118
117
 
119
- # return [self.class.resolve_typed_stage(stage.harmonized_code), stage]
120
- unless stage.abbr
121
- stage.typed_stage = self.class.resolve_typed_stage(stage.harmonized_code)
122
- end
123
118
  return stage
124
- # @typed_stage = resolve_typed_stage(@stage.harmonized_code) unless @stage.abbr
125
119
  end
126
120
 
127
121
  if self.class.has_typed_stage?(stage)
@@ -132,7 +126,7 @@ module Pubid::Core
132
126
  # resolve typed stage when harmonized code provided as stage
133
127
  # or stage abbreviation was not resolved
134
128
  if /\A[\d.]+\z/.match?(stage) || parsed_stage.empty_abbr?(with_prf: true)
135
- parsed_stage.typed_stage = self.class.resolve_typed_stage(parsed_stage.harmonized_code)
129
+ return self.class.resolve_typed_stage(parsed_stage.harmonized_code) || parsed_stage
136
130
  end
137
131
 
138
132
  parsed_stage
@@ -280,7 +274,7 @@ module Pubid::Core
280
274
  def resolve_typed_stage(harmonized_code)
281
275
  self::TYPED_STAGES.each do |k, v|
282
276
  if (v[:harmonized_stages] & harmonized_code.stages) == harmonized_code.stages
283
- return k
277
+ return get_identifier.build_typed_stage(abbr: k, harmonized_code: harmonized_code)
284
278
  end
285
279
  end
286
280
  nil
@@ -1,14 +1,13 @@
1
1
  module Pubid::Core
2
2
  class Stage
3
- attr_accessor :config, :abbr, :harmonized_code, :typed_stage
3
+ attr_accessor :config, :abbr, :harmonized_code
4
4
 
5
5
  # @param abbr [String, Symbol] abbreviation eg. :PWI, :WD
6
6
  # @param harmonized_code [String, Float, HarmonizedStageCode]
7
7
  # @param config [Configuration]
8
- def initialize(config:, abbr: nil, harmonized_code: nil, typed_stage: nil)
8
+ def initialize(config:, abbr: nil, harmonized_code: nil)
9
9
  @config = config
10
10
  @abbr = abbr&.to_s
11
- @typed_stage = typed_stage
12
11
 
13
12
  if harmonized_code
14
13
  @harmonized_code = if harmonized_code.is_a?(HarmonizedStageCode)
@@ -5,7 +5,7 @@ module Pubid::Core
5
5
  # @param config [Configuration]
6
6
  # @param abbr [Symbol] typed stage symbol, e.g. :dtr
7
7
  # @param harmonized_code [String, Float, HarmonizedStageCode]
8
- def initialize(config:, abbr:, harmonized_code: nil)
8
+ def initialize(config:, abbr: nil, harmonized_code: nil)
9
9
  @config = config
10
10
  @abbr = abbr
11
11
 
@@ -15,14 +15,26 @@ module Pubid::Core
15
15
  else
16
16
  HarmonizedStageCode.new(harmonized_code, config: config)
17
17
  end
18
- # @abbr ||= lookup_abbr(@harmonized_code.stages)
18
+ @abbr ||= lookup_abbr(@harmonized_code.stages)
19
19
  end
20
20
 
21
- raise Errors::TypedStageInvalidError, "#{abbr} is not valid typed stage" unless config.typed_stages.key?(abbr)
21
+ if abbr && !config.typed_stages.key?(abbr)
22
+ raise Errors::TypedStageInvalidError, "#{abbr} is not valid typed stage"
23
+ end
22
24
 
23
25
  @harmonized_code ||= HarmonizedStageCode.new(abbr, config: config)
24
26
  end
25
27
 
28
+ def lookup_abbr(lookup_code)
29
+ lookup_code = lookup_code.first if lookup_code.is_a?(Array) && lookup_code.count == 1
30
+
31
+ config.typed_stages.each do |abbr, stage|
32
+ return abbr if stage[:harmonized_stages].include?(lookup_code)
33
+ end
34
+
35
+ nil
36
+ end
37
+
26
38
  # Compares one stage with another
27
39
  # should return false if
28
40
  def ==(other)
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Core
3
- VERSION = "1.11.0".freeze
3
+ VERSION = "1.12.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.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-11-18 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake