pubid-core 1.8.3 → 1.8.5
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/transformer.rb +23 -0
- data/lib/pubid/core/version.rb +1 -1
- data/lib/pubid-core.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d899ad0149355f47d28e9cbb6d840b3678fe5f69147ffa7e659b557ad182e9e
|
4
|
+
data.tar.gz: 88493b5808fb4c51441b46b208ba8c32c5d13dedff1035b7ed19c80511869663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bfcbf3c67033e5c6b858459b9f2e74cc2e4d172377a10dbbf92d4498a568f1d8967c0b2044211e4e8fd42c8875d77c83acaac35fdb1a3e27df9beb853fdaa6d
|
7
|
+
data.tar.gz: 77253a629edfce98fbb5ae3505a80f7b6d4e2a51148ffb6cc9a9c9c0bbeff758aab615d27801069563f99d5a5f6c2c53cf3fa0f7ac3128c634796f27160f894d
|
@@ -41,6 +41,29 @@ module Pubid::Core
|
|
41
41
|
end
|
42
42
|
context
|
43
43
|
end
|
44
|
+
|
45
|
+
rule(roman_numerals: simple(:roman_numerals)) do |context|
|
46
|
+
roman_to_int(context[:roman_numerals])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
ROMAN_TO_INT = {
|
51
|
+
"I" => 1,
|
52
|
+
"V" => 5,
|
53
|
+
"X" => 10,
|
54
|
+
"L" => 50,
|
55
|
+
"C" => 100,
|
56
|
+
"D" => 500,
|
57
|
+
"M" => 1000,
|
58
|
+
}
|
59
|
+
|
60
|
+
def roman_to_int(roman)
|
61
|
+
sum = ROMAN_TO_INT[roman.to_s[0]]
|
62
|
+
roman.to_s.chars.each_cons(2) do |c1, c2|
|
63
|
+
sum += ROMAN_TO_INT[c2]
|
64
|
+
sum -= ROMAN_TO_INT[c1] * 2 if ROMAN_TO_INT[c1] < ROMAN_TO_INT[c2]
|
65
|
+
end
|
66
|
+
sum
|
44
67
|
end
|
45
68
|
end
|
46
69
|
end
|
data/lib/pubid/core/version.rb
CHANGED
data/lib/pubid-core.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module Pubid
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Pubid
|
4
|
+
module Core
|
5
|
+
def self.configuration
|
6
|
+
@configuration ||= Configuration.new
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
def self.configure
|
10
|
+
yield(configuration)
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
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.8.
|
4
|
+
version: 1.8.5
|
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
|
+
date: 2023-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|