pubid-iso 0.1.6 → 0.1.7

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: d3db426781c12fb80bbd99118bc9b601fe93473d0c9b395f88929ac8eb3b996d
4
- data.tar.gz: 7e2c155d3397e1ac4888258c680357b204edb8252a3e03fa8d336292be85ccbb
3
+ metadata.gz: 821262e1b683c07f484d9102195fe832fd1eb00fb3a6b23f713893f081a527f3
4
+ data.tar.gz: 105da964ba57e1c703bf4d77f485a3fc981660b218b4bf019376f937758a4f6c
5
5
  SHA512:
6
- metadata.gz: 765bdaef471049f21f15ba5cf9f45bbb42edfe88baf53ee5f67d155fdba6f0b8ef8a1b8cf212a9f6d3d35ce289946c6c5281efd94e913d59274b9ea1a7143e8c
7
- data.tar.gz: 628307f60259f11b97476d893861b73f1042104c940958ee695acc24069033e4689b0bfe490a641a6c7d557a5f8635ec6cf2140bed56d594910c8e2c46670d6f
6
+ metadata.gz: 1e5fb2bdd1b05f02c788f4b546fa0f6b2054ef0ab01dd4b59961e8c92ccd063a95b655d04969062c2d3674ab7511058b22e7882e586c9ae00e666065592cc5d3
7
+ data.tar.gz: d5ded0494dbf495d81da9a98b25d72ed90303a343159bbe4d30315d857ae19e0824437f0ebbb0e47371c6f89565b39ca9d4f08bdc5b4bc8358656f7a56b54795
@@ -0,0 +1,14 @@
1
+ module Pubid::Iso
2
+ class Amendment < Supplement
3
+
4
+ def render_pubid
5
+ stage = render_pubid_stage
6
+ stage += " " unless stage.size == 0
7
+ "/#{stage}Amd #{render_pubid_number}"
8
+ end
9
+
10
+ def render_urn
11
+ "#{render_urn_stage}:amd#{render_urn_number}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Pubid::Iso
2
+ class Corrigendum < Supplement
3
+
4
+ def render_pubid
5
+ stage = render_pubid_stage
6
+ stage += " " unless stage.size == 0
7
+ "/#{stage}Cor #{render_pubid_number}"
8
+ end
9
+
10
+ def render_urn
11
+ "#{render_urn_stage}:cor#{render_urn_number}"
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,9 @@
1
1
  module Pubid::Iso
2
2
  class French < Identifier
3
+ def initialize(**opts)
4
+ opts.each { |key, value| send("#{key}=", value) }
5
+ end
6
+
3
7
  def identifier(with_date, with_language_code)
4
8
  if @type == "Guide"
5
9
  "Guide #{originator}#{stage} #{number}#{part}#{iteration}"\
@@ -13,20 +17,8 @@ module Pubid::Iso
13
17
  super.map { |copublisher| copublisher.sub("IEC", "CEI") }
14
18
  end
15
19
 
16
- def amendment
17
- if @amendment_number
18
- "Amd.#{@amendment_version}:#{@amendment_number}"
19
- else
20
- "Amd.#{@amendment_version}"
21
- end
22
- end
23
-
24
- def corrigendum
25
- if @corrigendum_number
26
- "Cor.#{@corrigendum_version}:#{@corrigendum_number}"
27
- else
28
- "Cor.#{@corrigendum_version}"
29
- end
20
+ def supplements
21
+ super.gsub(" ", ".")
30
22
  end
31
23
  end
32
24
  end
@@ -17,6 +17,10 @@ module Pubid::Iso
17
17
  "ISP" => "ИСП",
18
18
  }.freeze
19
19
 
20
+ def initialize(**opts)
21
+ opts.each { |key, value| send("#{key}=", value) }
22
+ end
23
+
20
24
  def identifier(with_date, with_language_code)
21
25
  if @type == "Guide"
22
26
  "Руководство #{originator}#{stage} #{number}#{part}#{iteration}"\
@@ -37,5 +41,9 @@ module Pubid::Iso
37
41
  def stage
38
42
  "#{(@copublisher && ' ') || '/'}#{STAGE[@stage]}" if @stage
39
43
  end
44
+
45
+ def supplements
46
+ super.gsub(" ", ".")
47
+ end
40
48
  end
41
49
  end
@@ -15,7 +15,21 @@ module Pubid::Iso
15
15
  "ar" => "A",
16
16
  }.freeze
17
17
 
18
- def initialize(**opts)
18
+ def initialize(amendment: nil, amendment_number: nil, amendment_version: nil,
19
+ amendment_stage: nil,
20
+ corrigendum: nil, corrigendum_number: nil, corrigendum_version: nil,
21
+ corrigendum_stage: nil, **opts)
22
+ if amendment_version
23
+ @amendment = Amendment.new(number: amendment_number,
24
+ version: amendment_version,
25
+ stage: amendment_stage)
26
+ end
27
+ if corrigendum_version
28
+ @corrigendum = Corrigendum.new(number: corrigendum_number,
29
+ version: corrigendum_version,
30
+ stage: corrigendum_stage)
31
+ end
32
+
19
33
  opts.each { |key, value| send("#{key}=", value.is_a?(Array) && value || value.to_s) }
20
34
  end
21
35
 
@@ -156,35 +170,10 @@ module Pubid::Iso
156
170
  ".#{@iteration}" if @iteration
157
171
  end
158
172
 
159
- def amendment
160
- if @amendment_number
161
- "Amd #{@amendment_version}:#{@amendment_number}"
162
- else
163
- "Amd #{@amendment_version}"
164
- end
165
- end
166
-
167
- def corrigendum
168
- if @corrigendum_number
169
- "Cor #{@corrigendum_version}:#{@corrigendum_number}"
170
- else
171
- "Cor #{@corrigendum_version}"
172
- end
173
- end
174
-
175
173
  def supplements
176
- result = ""
177
- if @amendment_version
178
- result += (@amendment_stage && "/#{@amendment_stage} ") || "/"
179
- result += amendment
180
- end
181
-
182
- if @corrigendum_version
183
- result += (@corrigendum_stage && "/#{@corrigendum_stage} ") || "/"
184
- result += corrigendum
185
- end
174
+ result = @amendment&.version && @amendment.render_pubid || ""
186
175
 
187
- result
176
+ result + (@corrigendum&.version && @corrigendum.render_pubid || "")
188
177
  end
189
178
 
190
179
  def language(with_language_code = :iso)
@@ -0,0 +1,37 @@
1
+ module Pubid::Iso
2
+ class Supplement
3
+ attr_accessor :version, :number, :stage
4
+
5
+ def initialize(version:, number:, stage: nil)
6
+ @version, @number, @stage = version, number, stage
7
+ end
8
+
9
+ def ==(other)
10
+ other.version == version && (number.nil? || other.number == number) && (stage.nil? || other.stage == stage)
11
+ end
12
+
13
+ def render_pubid_stage
14
+ ((@stage && @stage) || "")
15
+ end
16
+
17
+ def render_pubid_number
18
+ if @number
19
+ "#{@version}:#{@number}"
20
+ else
21
+ "#{@version}"
22
+ end
23
+ end
24
+
25
+ def render_urn_stage
26
+ ((@stage && ":stage-#{sprintf('%05.2f', Urn::STAGES[@stage.to_sym])}") || "")
27
+ end
28
+
29
+ def render_urn_number
30
+ if @number
31
+ ":#{@number}:v#{@version}"
32
+ else
33
+ ":#{@version}:v1"
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/pubid/iso/urn.rb CHANGED
@@ -64,8 +64,6 @@ module Pubid::Iso
64
64
 
65
65
  return render_stage(@stage) if @stage
66
66
 
67
- return render_stage(@amendment_stage) if @amendment_stage
68
-
69
67
  render_stage(@corrigendum_stage) if @corrigendum_stage
70
68
  end
71
69
 
@@ -100,21 +98,9 @@ module Pubid::Iso
100
98
  end
101
99
 
102
100
  def supplement
103
- result = ""
104
- if @amendment
105
- result += if @amendment_number
106
- ":amd:#{@amendment_number}:v#{@amendment_version}"
107
- else
108
- ":amd:#{@amendment_version}:v1"
109
- end
110
- end
111
- if @corrigendum
112
- result += if @corrigendum_number
113
- ":cor:#{@corrigendum_number}:v#{@corrigendum_version}"
114
- else
115
- ":cor:#{@corrigendum_version}:v1"
116
- end
117
- end
101
+ result = @amendment&.render_urn || ""
102
+
103
+ result += @corrigendum&.render_urn || ""
118
104
 
119
105
  result
120
106
  end
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Iso
3
- VERSION = "0.1.6".freeze
3
+ VERSION = "0.1.7".freeze
4
4
  end
5
5
  end
data/lib/pubid/iso.rb CHANGED
@@ -11,6 +11,9 @@ end
11
11
  require_relative "iso/errors"
12
12
  require_relative "iso/parser"
13
13
  require_relative "iso/transformer"
14
+ require_relative "iso/supplement"
15
+ require_relative "iso/amendment"
16
+ require_relative "iso/corrigendum"
14
17
  require_relative "iso/identifier"
15
18
  require_relative "iso/identifier/french"
16
19
  require_relative "iso/identifier/russian"
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.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -107,11 +107,14 @@ files:
107
107
  - README.adoc
108
108
  - lib/pubid-iso.rb
109
109
  - lib/pubid/iso.rb
110
+ - lib/pubid/iso/amendment.rb
111
+ - lib/pubid/iso/corrigendum.rb
110
112
  - lib/pubid/iso/errors.rb
111
113
  - lib/pubid/iso/identifier.rb
112
114
  - lib/pubid/iso/identifier/french.rb
113
115
  - lib/pubid/iso/identifier/russian.rb
114
116
  - lib/pubid/iso/parser.rb
117
+ - lib/pubid/iso/supplement.rb
115
118
  - lib/pubid/iso/transformer.rb
116
119
  - lib/pubid/iso/urn.rb
117
120
  - lib/pubid/iso/version.rb