pubid-iso 0.6.1 → 0.7.1

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: e0cd99c30184d624f0019e7d10fd9d3d752e86ff701b4852de0d97f79e9ac095
4
- data.tar.gz: 1c2c1988f300757de153e28ff528f01a488c058e2b3b49a41be94a73ef242397
3
+ metadata.gz: 554740ba301fe225d6b7a58931013bb6d33d2c9ffa41de45c2b72b53b16340e7
4
+ data.tar.gz: ad603b65a477dbf70222252e0b286226d9dc576ff24fc794e9873fdea4a0a45e
5
5
  SHA512:
6
- metadata.gz: 7f63fbc6f3f030698619fa235ee2ba17bc3ba8d237ae05b2b0397a6e211654defe106d6f13fabf4c28e40470bc8ba68664b07ff90ec12f8e1fb7d7f33a1302b2
7
- data.tar.gz: dfa9bcb9441abc1ce2d5e56cce1ea915d72f3c9599ba64b6ec5e554e464397fe22940abc659eee1298136abba27acc26d5457f8e025a2f648a1fa32dfbe88159
6
+ metadata.gz: 731c5b93d0c2a443a6d1af5c965d6eb4984279bb062d1bd3136436cf65044186332661cbc6ae51a0500131b1cc13204991c4ed8e211fe28937298db806c65817
7
+ data.tar.gz: 441fbee4c9481f6c60f7f25a7ea6256550dab0241c0fb1a048e3272eaab4b87ac1089c08d2f7a33dbd74d418151793193ee7e0d36143b8c46ac79594134b3fcf
@@ -13,7 +13,7 @@ module Pubid::Iso
13
13
  },
14
14
  }.freeze
15
15
  def self.type
16
- { key: :add, title: "Addendum" }
16
+ { key: :add, title: "Addendum", short: "ADD" }
17
17
  end
18
18
 
19
19
  def self.get_renderer_class
@@ -21,7 +21,7 @@ module Pubid::Iso
21
21
  },
22
22
  }.freeze
23
23
  def self.type
24
- { key: :amd, title: "Amendment" }
24
+ { key: :amd, title: "Amendment", short: "AMD" }
25
25
  end
26
26
 
27
27
  def self.get_renderer_class
@@ -31,7 +31,7 @@ module Pubid::Iso
31
31
  def urn
32
32
  raise Errors::NoEditionError, "Base document must have edition" unless base_has_edition?
33
33
 
34
- Renderer::UrnAmendment.new(get_params).render
34
+ Renderer::UrnAmendment.new(to_h(deep: false)).render
35
35
  end
36
36
  end
37
37
  end
@@ -12,7 +12,7 @@ module Pubid::Iso
12
12
  :tctype, :sctype, :wgtype, :tcnumber, :scnumber, :wgnumber,
13
13
  :dirtype,
14
14
  :base,
15
- :typed_stage,
15
+ # :typed_stage,
16
16
  :supplements,
17
17
  :addendum
18
18
 
@@ -21,7 +21,7 @@ module Pubid::Iso
21
21
  #
22
22
  # @param stage [Stage, Symbol, String] stage or typed stage, e.g. "PWI", "NP", "50.00", Stage.new(abbr: :WD), "DTR"
23
23
  # @param iteration [Integer] document iteration, eg. "1", "2", "3"
24
- # @param joint_document [Identifier] joint document
24
+ # @param joint_document [Identifier, Hash] joint document
25
25
  # @param supplements [Array<Supplement>] supplements
26
26
  # @param tctype [String] Technical Committee type, eg. "TC", "JTC"
27
27
  # @param sctype [String] TC subsommittee, eg. "SC"
@@ -30,7 +30,7 @@ module Pubid::Iso
30
30
  # @param scnumber [Integer] Subsommittee number, eg. "1", "2"
31
31
  # @param wgnumber [Integer] Working group number, eg. "1", "2"
32
32
  # @param dirtype [String] Directives document type, eg. "JTC"
33
- # @param base [Identifier] base document for supplement's identifier
33
+ # @param base [Identifier, Hash] base document for supplement's identifier
34
34
  # @param type [nil, :tr, :ts, :amd, :cor, :guide, :dir, :tc, Type] document's type, eg. :tr, :ts, :amd, :cor, Type.new(:tr)
35
35
  # @raise [Errors::SupplementWithoutYearOrStageError] when trying to apply
36
36
  # supplement to the document without edition year or stage
@@ -62,13 +62,19 @@ module Pubid::Iso
62
62
  end
63
63
 
64
64
  if stage
65
- @typed_stage, @stage = resolve_stage(stage)
65
+ @stage = resolve_stage(stage)
66
66
  elsif iteration && !is_a?(Supplement)
67
67
  raise Errors::IterationWithoutStageError, "Document without stage cannot have iteration"
68
68
  end
69
69
 
70
70
  @iteration = iteration.to_i if iteration
71
- @joint_document = joint_document if joint_document
71
+ if joint_document
72
+ if joint_document.is_a?(Hash)
73
+ @joint_document = Identifier.create(**joint_document)
74
+ else
75
+ @joint_document = joint_document
76
+ end
77
+ end
72
78
  @tctype = tctype if tctype
73
79
  @sctype = sctype.to_s if sctype
74
80
  @wgtype = wgtype.to_s if wgtype
@@ -77,7 +83,13 @@ module Pubid::Iso
77
83
  @wgnumber = wgnumber.to_s if wgnumber
78
84
  @dir = dir.to_s if dir
79
85
  @dirtype = dirtype.to_s if dirtype
80
- @base = base if base
86
+ if base
87
+ if base.is_a?(Hash)
88
+ @base = Identifier.create(**base)
89
+ else
90
+ @base = base
91
+ end
92
+ end
81
93
  @part = part if part
82
94
  @addendum = addendum if addendum
83
95
  @edition = edition
@@ -178,7 +190,7 @@ module Pubid::Iso
178
190
  # @return [String] URN identifier
179
191
  def urn
180
192
  ((@tctype && Renderer::UrnTc) || Pubid::Iso::Renderer::Urn).new(
181
- get_params.merge({ type: type[:key] }),
193
+ to_h(deep: false).merge({ type: type[:key] }),
182
194
  ).render + (language ? ":#{language}" : "")
183
195
  end
184
196
 
@@ -243,7 +255,7 @@ module Pubid::Iso
243
255
  options[:with_prf] = with_prf
244
256
  options[:language] = lang
245
257
 
246
- self.class.get_renderer_class.new(get_params).render(**options) +
258
+ self.class.get_renderer_class.new(to_h(deep: false)).render(**options) +
247
259
  if @joint_document
248
260
  render_joint_document(@joint_document)
249
261
  end.to_s
@@ -22,7 +22,7 @@ module Pubid::Iso
22
22
  }.freeze
23
23
 
24
24
  def self.type
25
- { key: :cor, title: "Corrigendum" }
25
+ { key: :cor, title: "Corrigendum", short: "COR" }
26
26
  end
27
27
 
28
28
  def self.get_renderer_class
@@ -32,7 +32,7 @@ module Pubid::Iso
32
32
  def urn
33
33
  raise Errors::NoEditionError, "Base document must have edition" unless base_has_edition?
34
34
 
35
- Renderer::UrnCorrigendum.new(get_params).render
35
+ Renderer::UrnCorrigendum.new(to_h(deep: false)).render
36
36
  end
37
37
  end
38
38
  end
@@ -16,7 +16,7 @@ module Pubid::Iso
16
16
  end
17
17
 
18
18
  def self.type
19
- { key: :dir, title: "Directives" }
19
+ { key: :dir, title: "Directives", short: "DIR" }
20
20
  end
21
21
 
22
22
  def self.get_renderer_class
@@ -24,7 +24,7 @@ module Pubid::Iso
24
24
  end
25
25
 
26
26
  def urn
27
- Renderer::UrnDir.new(get_params).render
27
+ Renderer::UrnDir.new(to_h(deep: false)).render
28
28
  end
29
29
 
30
30
  def render_joint_document(joint_document)
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :ext, title: "Extract" }
11
+ { key: :ext, title: "Extract", short: "EXT" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -25,7 +25,7 @@ module Pubid::Iso
25
25
  end
26
26
 
27
27
  def self.type
28
- { key: :guide, title: "Guide" }
28
+ { key: :guide, title: "Guide", short: "GUIDE" }
29
29
  end
30
30
  end
31
31
  end
@@ -31,7 +31,7 @@ module Pubid::Iso
31
31
  end
32
32
 
33
33
  def typed_stage_abbrev
34
- if self.class::TYPED_STAGES.key?(typed_stage)
34
+ if self.class::TYPED_STAGES.key?(stage)
35
35
  super
36
36
  else
37
37
  stage&.abbr
@@ -39,7 +39,7 @@ module Pubid::Iso
39
39
  end
40
40
 
41
41
  def self.type
42
- { key: :is, title: "International Standard" }
42
+ { key: :is, title: "International Standard", short: nil }
43
43
  end
44
44
  end
45
45
  end
@@ -6,12 +6,12 @@ module Pubid::Iso
6
6
  def_delegators 'Pubid::Iso::Identifier::InternationalStandardizedProfile', :type
7
7
 
8
8
  TYPED_STAGES = {
9
- dis: {
9
+ disp: {
10
10
  abbr: "DISP",
11
11
  name: "Draft International Standardized Profile",
12
12
  harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
13
13
  },
14
- fdis: {
14
+ fdisp: {
15
15
  abbr: "FDISP",
16
16
  name: "Final Draft International Standardized Profile",
17
17
  harmonized_stages: %w[50.00 50.20 50.60 50.92],
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :isp, title: "International Standardized Profile" }
22
+ { key: :isp, title: "International Standardized Profile", short: "ISP" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -6,7 +6,7 @@ module Pubid::Iso
6
6
  def_delegators 'Pubid::Iso::Identifier::InternationalWorkshopAgreement', :type
7
7
 
8
8
  TYPED_STAGES = {
9
- dis: {
9
+ diwa: {
10
10
  abbr: "DIWA",
11
11
  name: "Draft International Workshop Agreement",
12
12
  harmonized_stages: %w[40.00 40.20 40.60 40.92 40.93 40.98 40.99],
@@ -14,7 +14,7 @@ module Pubid::Iso
14
14
  }.freeze
15
15
 
16
16
  def self.type
17
- { key: :iwa, title: "International Workshop Agreement" }
17
+ { key: :iwa, title: "International Workshop Agreement", short: "IWA" }
18
18
  end
19
19
 
20
20
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :pas, title: "Publicly Available Specification" }
22
+ { key: :pas, title: "Publicly Available Specification", short: "PAS" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :r, title: "Recommendation" }
11
+ { key: :r, title: "Recommendation", short: "R" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -24,7 +24,7 @@ module Pubid::Iso
24
24
  end
25
25
 
26
26
  def self.type
27
- { key: :sup, title: "Supplement", values: %w[Supplement Suppl SUP] }
27
+ { key: :sup, title: "Supplement", values: %w[Supplement Suppl SUP], short: "SUP" }
28
28
  end
29
29
 
30
30
  def self.get_renderer_class
@@ -32,7 +32,7 @@ module Pubid::Iso
32
32
  end
33
33
 
34
34
  def urn
35
- Renderer::UrnSupplement.new(get_params).render
35
+ Renderer::UrnSupplement.new(to_h(deep: false)).render
36
36
  end
37
37
  end
38
38
  end
@@ -8,7 +8,7 @@ module Pubid::Iso
8
8
  TYPED_STAGES = {}.freeze
9
9
 
10
10
  def self.type
11
- { key: :tc, title: "Technical Committee" }
11
+ { key: :tc, title: "Technical Committee", short: "TC" }
12
12
  end
13
13
 
14
14
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :tr, title: "Technical Report" }
22
+ { key: :tr, title: "Technical Report", short: "TR" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :ts, title: "Technical Specification" }
22
+ { key: :ts, title: "Technical Specification", short: "TS" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -19,7 +19,7 @@ module Pubid::Iso
19
19
  }.freeze
20
20
 
21
21
  def self.type
22
- { key: :tta, title: "Technology Trends Assessments" }
22
+ { key: :tta, title: "Technology Trends Assessments", short: "TTA" }
23
23
  end
24
24
 
25
25
  def self.get_renderer_class
@@ -42,10 +42,10 @@ module Pubid::Iso::Renderer
42
42
  def render_base(_base, _opts, _params)
43
43
  end
44
44
 
45
- def render_type_prefix(params)
46
- result = params[:typed_stage].nil? || params[:typed_stage].empty? ? self.class::TYPE : ""
45
+ def render_type_prefix(params, opts)
46
+ result = params[:stage].nil? || !params[:stage].is_a?(Pubid::Core::TypedStage) ? self.class::TYPE : ""
47
47
 
48
- if params[:stage] && !params[:stage].empty? && !result.empty?
48
+ if params[:stage] != "" && !params[:stage].to_s(with_prf: opts[:with_prf]).empty? && !result.empty?
49
49
  " #{result}"
50
50
  else
51
51
  result
@@ -53,7 +53,8 @@ module Pubid::Iso::Renderer
53
53
  end
54
54
 
55
55
  def render_identifier(params, opts)
56
- "%{publisher}%{typed_stage}%{stage}#{render_type_prefix(params)} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{addendum}%{edition}" % params
56
+ stage = params.key?(:stage) ? postrender_stage(params[:stage], opts, params) : ""
57
+ "%{publisher}#{stage}#{render_type_prefix(params, opts)} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{addendum}%{edition}" % params
57
58
  end
58
59
 
59
60
  def render_copublisher_string(publisher, copublishers, opts)
@@ -125,8 +126,11 @@ module Pubid::Iso::Renderer
125
126
  typed_stage.to_s
126
127
  end
127
128
 
128
- def render_stage(stage, opts, params)
129
- return if params[:typed_stage]
129
+ def render_stage(stage, _opts, _params)
130
+ stage
131
+ end
132
+
133
+ def postrender_stage(stage, opts, params)
130
134
  return if stage.empty_abbr?(with_prf: opts[:with_prf])
131
135
 
132
136
  if opts[:language]
@@ -7,7 +7,7 @@ module Pubid::Iso::Renderer
7
7
  res = ("%{publisher} DIR%{dirtype}%{number}%{year}%{edition}" % params)
8
8
 
9
9
  if params.key?(:joint_document)
10
- joint_params = prerender_params(params[:joint_document].get_params, {})
10
+ joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
11
11
  joint_params.default = ""
12
12
  res += (" + %{publisher}%{dirtype}%{number}%{year}" % joint_params)
13
13
  end
@@ -8,8 +8,8 @@ module Pubid::Iso::Renderer
8
8
  elsif opts[:language] == :russian
9
9
  "Руководство %{publisher}%{stage} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{edition}" % params
10
10
  else
11
- if params[:typed_stage] && !params[:typed_stage].empty?
12
- "%{publisher}%{typed_stage}%{stage} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{edition}" % params
11
+ if params[:stage] && params[:stage].is_a?(Pubid::Core::TypedStage)
12
+ "%{publisher}%{stage} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{edition}" % params
13
13
  else
14
14
  "%{publisher}%{stage} Guide %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{edition}" % params
15
15
  end
@@ -11,7 +11,8 @@ module Pubid::Iso::Renderer
11
11
  end
12
12
 
13
13
  def render_identifier(params, opts)
14
- "%{typed_stage}%{stage}#{render_type_prefix(params)} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{addendum}%{edition}" % params
14
+ stage = params.key?(:stage) ? postrender_stage(params[:stage], opts, params) : ""
15
+ "#{stage}#{render_type_prefix(params, opts)} %{number}%{part}%{iteration}%{year}%{amendments}%{corrigendums}%{addendum}%{edition}" % params
15
16
  end
16
17
  end
17
18
  end
@@ -23,21 +23,22 @@ module Pubid::Iso::Renderer
23
23
  end
24
24
 
25
25
  def render_identifier(params, opts)
26
- type_prefix = params[:typed_stage].nil? || params[:typed_stage].empty? ? self.class::TYPE : ""
26
+ type_prefix = params[:stage].nil? || !params[:stage].is_a?(Pubid::Core::TypedStage) ? self.class::TYPE : ""
27
+ # type_prefix = params[:typed_stage].nil? || params[:typed_stage].empty? ? self.class::TYPE : ""
27
28
 
28
- if params[:stage].is_a?(Pubid::Core::Stage) && !params[:stage].empty_abbr?
29
+ if params[:stage].instance_of?(Pubid::Core::Stage) && !params[:stage].empty_abbr?
29
30
  type_prefix = " #{type_prefix}"
30
31
  end
31
32
 
32
33
  if self.class == Supplement
33
34
  if opts[:base_type] == :dir
34
- "%{typed_stage}%{stage}%{publisher} SUP%{number}%{part}%{iteration}%{year}%{edition}" % params
35
+ "%{stage}%{publisher} SUP%{number}%{part}%{iteration}%{year}%{edition}" % params
35
36
  else
36
37
  # type_prefix = "/#{type_prefix}" unless type_prefix.empty?
37
- "/%{typed_stage}%{stage}#{type_prefix}%{number}%{part}%{iteration}%{year}%{edition}" % params
38
+ "/%{stage}#{type_prefix}%{number}%{part}%{iteration}%{year}%{edition}" % params
38
39
  end
39
40
  else
40
- "/%{typed_stage}%{stage}#{type_prefix}%{number}%{part}%{iteration}%{year}%{edition}" % params
41
+ "/%{stage}#{type_prefix}%{number}%{part}%{iteration}%{year}%{edition}" % params
41
42
  end
42
43
  end
43
44
 
@@ -8,10 +8,10 @@ module Pubid::Iso::Renderer
8
8
 
9
9
  if params.key?(:joint_document)
10
10
  if params[:joint_document].is_a?(Pubid::Iso::Identifier::Supplement)
11
- joint_params = params[:joint_document].get_params
11
+ joint_params = params[:joint_document].to_h(deep: false)
12
12
  res += ":#{joint_params[:base].publisher.downcase}:sup:%{year}" % joint_params
13
13
  else
14
- joint_params = prerender_params(params[:joint_document].get_params, {})
14
+ joint_params = prerender_params(params[:joint_document].to_h(deep: false), {})
15
15
  joint_params.default = ""
16
16
  res += (":%{publisher}%{copublisher}%{dirtype}%{number}%{supplement}" % joint_params)
17
17
  end
@@ -13,7 +13,7 @@ module Pubid::Iso::Renderer
13
13
  return base.urn if base.base || base.is_a?(Pubid::Iso::Identifier::Directives)
14
14
 
15
15
  # to avoid rendering language as part of base
16
- Urn.new(base.get_params).render
16
+ Urn.new(base.to_h(deep: false)).render
17
17
  end
18
18
 
19
19
  def render_number(number, _opts, params)
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iso
3
- VERSION = "0.6.1".freeze
3
+ VERSION = "0.7.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pubid-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.1
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-10-02 00:00:00.000000000 Z
11
+ date: 2024-01-14 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.7
61
+ version: '1.12'
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.7
68
+ version: '1.12'
69
69
  description: Library to generate, parse and manipulate ISO PubID.
70
70
  email:
71
71
  - open.source@ribose.com