pubid-iso 0.6.1 → 0.7.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: e0cd99c30184d624f0019e7d10fd9d3d752e86ff701b4852de0d97f79e9ac095
4
- data.tar.gz: 1c2c1988f300757de153e28ff528f01a488c058e2b3b49a41be94a73ef242397
3
+ metadata.gz: e4fd0f754d87e7496c307221422d69bb36c6d4b497843eafa27a547d68bcd4e6
4
+ data.tar.gz: c1d58a83fb0d672111b9fe6d0dc28df87c0070e483c3c19d487e7c2618c99293
5
5
  SHA512:
6
- metadata.gz: 7f63fbc6f3f030698619fa235ee2ba17bc3ba8d237ae05b2b0397a6e211654defe106d6f13fabf4c28e40470bc8ba68664b07ff90ec12f8e1fb7d7f33a1302b2
7
- data.tar.gz: dfa9bcb9441abc1ce2d5e56cce1ea915d72f3c9599ba64b6ec5e554e464397fe22940abc659eee1298136abba27acc26d5457f8e025a2f648a1fa32dfbe88159
6
+ metadata.gz: aff91d1b6b5bc709bb4929b2901ac7ee53e35a2e67e403f4c3eec4123b8ab29a4d42604ae06ff0777be19b29d598139b224bfd7f34fe206595f3946147fb440b
7
+ data.tar.gz: ec6219d66f0b62c97bb20c09adcb3c53f3d63f7fb245228e3463fe47b33d37087574f6a327461f839b0eef1f713c8ce33dd1408619194814fda9ccc8938fdab1
@@ -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
 
@@ -62,7 +62,7 @@ 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
@@ -178,7 +178,7 @@ module Pubid::Iso
178
178
  # @return [String] URN identifier
179
179
  def urn
180
180
  ((@tctype && Renderer::UrnTc) || Pubid::Iso::Renderer::Urn).new(
181
- get_params.merge({ type: type[:key] }),
181
+ to_h(deep: false).merge({ type: type[:key] }),
182
182
  ).render + (language ? ":#{language}" : "")
183
183
  end
184
184
 
@@ -243,7 +243,7 @@ module Pubid::Iso
243
243
  options[:with_prf] = with_prf
244
244
  options[:language] = lang
245
245
 
246
- self.class.get_renderer_class.new(get_params).render(**options) +
246
+ self.class.get_renderer_class.new(to_h(deep: false)).render(**options) +
247
247
  if @joint_document
248
248
  render_joint_document(@joint_document)
249
249
  end.to_s
@@ -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
@@ -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)
@@ -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
@@ -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],
@@ -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],
@@ -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
@@ -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.0".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.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-10-02 00:00:00.000000000 Z
11
+ date: 2023-12-29 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