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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fc62e629fdd3da242cf3e2f03c0e59d74ba3ad2305df1ab3156abefc4d907a2
4
- data.tar.gz: 6eed583e02b27ef472714224c4531a90278bf1f18ac9ded069b2a7c62f09dc36
3
+ metadata.gz: 7d899ad0149355f47d28e9cbb6d840b3678fe5f69147ffa7e659b557ad182e9e
4
+ data.tar.gz: 88493b5808fb4c51441b46b208ba8c32c5d13dedff1035b7ed19c80511869663
5
5
  SHA512:
6
- metadata.gz: cbf792e4dabc21d7cd2524e82e2976d8833854a9379dc9c526f14d6087639117b0585c8c96aeff5abbf87453ebf8327218bc05658278479b169966a9ab84214c
7
- data.tar.gz: b823f8be116ec916600c493f5a4b4c72d7c12f5c7e547ec05a1e87ca840f30f2496a47ec021f77c3b1ee5ab65186b20fe3355687882659c9e03ff9683068a741
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
@@ -1,5 +1,5 @@
1
1
  module Pubid
2
2
  module Core
3
- VERSION = "1.8.3".freeze
3
+ VERSION = "1.8.5".freeze
4
4
  end
5
5
  end
data/lib/pubid-core.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Pubid::Core
4
- def self.configuration
5
- @configuration ||= Configuration.new
6
- end
3
+ module Pubid
4
+ module Core
5
+ def self.configuration
6
+ @configuration ||= Configuration.new
7
+ end
7
8
 
8
- def self.configure
9
- yield(configuration)
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.3
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-06-28 00:00:00.000000000 Z
11
+ date: 2023-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake