smerp-common 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.release_history.yml +4 -0
- data/Gemfile.lock +6 -4
- data/lib/smerp/common/numeral_conversion.rb +105 -0
- data/lib/smerp/common/version.rb +1 -1
- data/lib/smerp/common.rb +1 -0
- data/smerp-common.gemspec +2 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83dc65597aaba0fda6e5bea3bcb03d47839e55e914bf17d955431ef4dd54ea9e
|
4
|
+
data.tar.gz: d3486bb091b0b7eb3afe217d43895f76a9bbb1e25dcb1a182724fd74b9534c2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7d539336ef9409276d2acaa48229e67643c986b6361ad224f8874c345a8f5822a647f95e43dee0de3551f2d0ddd16ba301fcd9aefaa12a2e6d554db8e9ed41
|
7
|
+
data.tar.gz: bf9ee3433202a01a455df7886128638e5b96c99d6c6f7dadc8e2dc0fad0a1b45bc2d1387f9105ca2e2d4fec2b8976644825bea4d46497c81f22dd3b0f6fe3dd5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
smerp-common (0.1.
|
4
|
+
smerp-common (0.1.1)
|
5
|
+
roman-numerals
|
5
6
|
teLogger
|
6
7
|
toolrack
|
7
8
|
|
@@ -9,7 +10,7 @@ GEM
|
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
12
|
base58 (0.2.3)
|
12
|
-
devops_assist (0.3.
|
13
|
+
devops_assist (0.3.1)
|
13
14
|
git_cli
|
14
15
|
git_cli_prompt
|
15
16
|
gvcs
|
@@ -31,19 +32,20 @@ GEM
|
|
31
32
|
tty-color (~> 0.5)
|
32
33
|
ptools (1.4.2)
|
33
34
|
rake (13.0.6)
|
35
|
+
roman-numerals (0.3.0)
|
34
36
|
rspec (3.11.0)
|
35
37
|
rspec-core (~> 3.11.0)
|
36
38
|
rspec-expectations (~> 3.11.0)
|
37
39
|
rspec-mocks (~> 3.11.0)
|
38
40
|
rspec-core (3.11.0)
|
39
41
|
rspec-support (~> 3.11.0)
|
40
|
-
rspec-expectations (3.11.
|
42
|
+
rspec-expectations (3.11.1)
|
41
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
44
|
rspec-support (~> 3.11.0)
|
43
45
|
rspec-mocks (3.11.1)
|
44
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
47
|
rspec-support (~> 3.11.0)
|
46
|
-
rspec-support (3.11.
|
48
|
+
rspec-support (3.11.1)
|
47
49
|
teLogger (0.2.0)
|
48
50
|
toolrack (0.19.1)
|
49
51
|
base58
|
@@ -0,0 +1,105 @@
|
|
1
|
+
|
2
|
+
require 'roman-numerals'
|
3
|
+
|
4
|
+
module Smerp
|
5
|
+
module Common
|
6
|
+
|
7
|
+
class NumeralToStringConversionException < StandardError; end
|
8
|
+
|
9
|
+
# expect to integrate into integer class
|
10
|
+
module NumeralToStringConversion
|
11
|
+
|
12
|
+
def int_to_roman
|
13
|
+
RomanNumerals.to_roman(self.to_i)
|
14
|
+
end
|
15
|
+
alias_method :int_to_roman_upcase, :int_to_roman
|
16
|
+
|
17
|
+
def int_to_roman_downcase
|
18
|
+
int_to_roman.downcase
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def int_to_alpha
|
23
|
+
|
24
|
+
input = self.to_i
|
25
|
+
ins = []
|
26
|
+
|
27
|
+
input = input * -1 if input < 0
|
28
|
+
input = 1 if input == 0
|
29
|
+
|
30
|
+
if input > 26
|
31
|
+
l = input / 26
|
32
|
+
(0...l).each do |ll|
|
33
|
+
ins << 26
|
34
|
+
end
|
35
|
+
|
36
|
+
ins << input-(26*l)
|
37
|
+
else
|
38
|
+
ins << input
|
39
|
+
end
|
40
|
+
|
41
|
+
base = 65 # 'A'
|
42
|
+
v = self.to_i
|
43
|
+
|
44
|
+
res = []
|
45
|
+
ins.each do |input|
|
46
|
+
val = base + input - 1
|
47
|
+
res << val.chr
|
48
|
+
end
|
49
|
+
|
50
|
+
res.join
|
51
|
+
|
52
|
+
end
|
53
|
+
alias_method :int_to_alpha_upcase, :int_to_alpha
|
54
|
+
|
55
|
+
def int_to_alpha_downcase
|
56
|
+
int_to_alpha.downcase
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# expected to be integrated into String class
|
62
|
+
module StringToNumeralConversion
|
63
|
+
|
64
|
+
def roman_to_int
|
65
|
+
RomanNumerals.to_decimal(self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def alpha_to_int
|
69
|
+
|
70
|
+
smallAlpha = ('a'..'z')
|
71
|
+
capAlpha = ('A'..'Z')
|
72
|
+
smallAlphaBase = 'a'.ord
|
73
|
+
capAlphaBase = 'A'.ord
|
74
|
+
|
75
|
+
res = 0
|
76
|
+
input = self.chars
|
77
|
+
input.each do |c|
|
78
|
+
if smallAlpha.include?(c)
|
79
|
+
v = c.ord - smallAlphaBase + 1
|
80
|
+
res += v
|
81
|
+
elsif capAlpha.include?(c)
|
82
|
+
v = c.ord - capAlphaBase + 1
|
83
|
+
res += v
|
84
|
+
else
|
85
|
+
res += 0
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
res
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
class Integer
|
99
|
+
include Smerp::Common::NumeralToStringConversion
|
100
|
+
end
|
101
|
+
|
102
|
+
class String
|
103
|
+
include Smerp::Common::StringToNumeralConversion
|
104
|
+
end
|
105
|
+
|
data/lib/smerp/common/version.rb
CHANGED
data/lib/smerp/common.rb
CHANGED
data/smerp-common.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smerp-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: teLogger
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: roman-numerals
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: devops_assist
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +73,7 @@ executables: []
|
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
76
|
+
- ".release_history.yml"
|
62
77
|
- ".rspec"
|
63
78
|
- Gemfile
|
64
79
|
- Gemfile.lock
|
@@ -69,6 +84,7 @@ files:
|
|
69
84
|
- lib/smerp/common.rb
|
70
85
|
- lib/smerp/common/currency_conversion.rb
|
71
86
|
- lib/smerp/common/fin_utils.rb
|
87
|
+
- lib/smerp/common/numeral_conversion.rb
|
72
88
|
- lib/smerp/common/version.rb
|
73
89
|
- smerp-common.gemspec
|
74
90
|
homepage: ''
|