pubid-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pubid/core/supplement.rb +14 -14
- data/lib/pubid/core/transformer.rb +6 -6
- data/lib/pubid/core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452665bfc83c23fed5563fb65e94b05e003491474be0572c10628838bf9bb8d4
|
4
|
+
data.tar.gz: 2c5282618c3bd1e04f26760791371205383191ab752878ac74ed32ac61ff6a2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57ec902835845daa759d264308e0456851e202a791d0f2dac62c6fb5253202741420f47c9c45f2a2a7398a691e3c17a61c6189ab01f177cbf2b46eb47be15d08
|
7
|
+
data.tar.gz: ae150bad555421587020450b38fba534f1b94429ad7506ff6b32c0a0a4717be367ead10d5b5266259dbd4f9dfdc7a407e87acba122d7bd4f5562e643685c8a88
|
@@ -1,36 +1,36 @@
|
|
1
1
|
module Pubid::Core
|
2
2
|
class Supplement
|
3
3
|
include Comparable
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :number, :year
|
5
5
|
|
6
|
-
# Creates new supplement with provided
|
7
|
-
# @param version [Integer]
|
6
|
+
# Creates new supplement with provided update number and optional year
|
8
7
|
# @param number [Integer]
|
9
|
-
|
10
|
-
|
8
|
+
# @param year [Integer]
|
9
|
+
def initialize(number:, year: nil)
|
10
|
+
@number, @year = number&.to_i, year&.to_i
|
11
11
|
end
|
12
12
|
|
13
13
|
def <=>(other)
|
14
|
-
return 0 if
|
14
|
+
return 0 if year.nil? && other.year
|
15
15
|
|
16
|
-
return
|
16
|
+
return year <=> other.year if number == other.number
|
17
17
|
|
18
|
-
(
|
18
|
+
(number <=> other.number) || year <=> other.year
|
19
19
|
end
|
20
20
|
|
21
21
|
def render_pubid_number
|
22
|
-
if @
|
23
|
-
"#{@
|
22
|
+
if @year
|
23
|
+
"#{@number}:#{@year}"
|
24
24
|
else
|
25
|
-
"#{@
|
25
|
+
"#{@number}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def render_urn_number
|
30
|
-
if @
|
31
|
-
":#{@
|
30
|
+
if @year
|
31
|
+
":#{@year}:v#{@number}"
|
32
32
|
else
|
33
|
-
":#{@
|
33
|
+
":#{@number}:v1"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -16,13 +16,13 @@ module Pubid::Core
|
|
16
16
|
rule(amendments: subtree(:amendments)) do |context|
|
17
17
|
if context[:amendments].is_a?(Array)
|
18
18
|
context[:amendments] = context[:amendments].map do |amendment|
|
19
|
-
self.class.get_amendment_class.new(
|
19
|
+
self.class.get_amendment_class.new(number: amendment[:number], year: amendment[:year])
|
20
20
|
end
|
21
21
|
else
|
22
22
|
context[:amendments] =
|
23
23
|
[self.class.get_amendment_class.new(
|
24
|
-
|
25
|
-
|
24
|
+
number: context[:amendments][:number],
|
25
|
+
year: context[:amendments][:year])]
|
26
26
|
|
27
27
|
end
|
28
28
|
context
|
@@ -31,13 +31,13 @@ module Pubid::Core
|
|
31
31
|
rule(corrigendums: subtree(:corrigendums)) do |context|
|
32
32
|
if context[:corrigendums].is_a?(Array)
|
33
33
|
context[:corrigendums] = context[:corrigendums].map do |corrigendum|
|
34
|
-
self.class.get_corrigendum_class.new(
|
34
|
+
self.class.get_corrigendum_class.new(number: corrigendum[:number], year: corrigendum[:year])
|
35
35
|
end
|
36
36
|
else
|
37
37
|
context[:corrigendums] =
|
38
38
|
[self.class.get_corrigendum_class.new(
|
39
|
-
|
40
|
-
|
39
|
+
number: context[:corrigendums][:number],
|
40
|
+
year: context[:corrigendums][:year])]
|
41
41
|
end
|
42
42
|
context
|
43
43
|
end
|
data/lib/pubid/core/version.rb
CHANGED