cotcube-helpers 0.1.9 → 0.1.9.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/CHANGELOG.md +4 -0
- data/VERSION +1 -1
- data/lib/cotcube-helpers.rb +3 -1
- data/lib/cotcube-helpers/get_id_set.rb +43 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb81f4056cbca5f2a1630a3ddc3a63070bcf00030b78cad54163e9fca057aaaa
|
4
|
+
data.tar.gz: 80cfdd92008406204cabb9add25987d49c1c3ba28b32db5c935e743e1d276470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bedbd01706f4f4896acf7dc7258371c31ace12f81b8c65c6f0c057129b824d1b3087f806fe48bd8a38d0a2894c1028ec5113fa6a1f9abbd2036ea156a86ca266
|
7
|
+
data.tar.gz: c17bbb49e51ced51f8ef8edefa6a781dc54598fb8ed7912df41434b6702096567f495f0cd0c873efbe020e36132e9402ac9f336e4607b151d1a34ae4600a2c3f
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.9
|
1
|
+
0.1.9.1
|
data/lib/cotcube-helpers.rb
CHANGED
@@ -21,7 +21,8 @@ require_relative 'cotcube-helpers/input'
|
|
21
21
|
require_relative 'cotcube-helpers/reduce'
|
22
22
|
require_relative 'cotcube-helpers/constants'
|
23
23
|
require_relative 'cotcube-helpers/symbols'
|
24
|
-
require_relative 'cotcube-
|
24
|
+
require_relative 'cotcube-helpers/init'
|
25
|
+
require_relative 'cotcube-helpers/get_id_set'
|
25
26
|
|
26
27
|
module Cotcube
|
27
28
|
module Helpers
|
@@ -31,6 +32,7 @@ module Cotcube
|
|
31
32
|
:simple_series_stats,
|
32
33
|
:keystroke,
|
33
34
|
:symbols,
|
35
|
+
:get_id_set,
|
34
36
|
:init
|
35
37
|
|
36
38
|
# please not that module_functions of source provided in private files must be published there
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cotcube
|
4
|
+
module Helpers
|
5
|
+
|
6
|
+
def get_id_set(symbol: nil, id: nil, contract: nil, config: init)
|
7
|
+
contract = contract.to_s.upcase if contract.is_a? Symbol
|
8
|
+
id = id.to_s.upcase if id.is_a? Symbol
|
9
|
+
symbol = symbol.to_s.upcase if symbol.is_a? Symbol
|
10
|
+
|
11
|
+
if contract.is_a?(String) && (contract.length == 5)
|
12
|
+
c_symbol = contract[0..1]
|
13
|
+
if (not symbol.nil?) && (symbol != c_symbol)
|
14
|
+
raise ArgumentError,
|
15
|
+
"Mismatch between given symbol #{symbol} and contract #{contract}"
|
16
|
+
end
|
17
|
+
|
18
|
+
symbol = c_symbol
|
19
|
+
end
|
20
|
+
|
21
|
+
unless symbol.nil?
|
22
|
+
sym = symbols.select { |s| s[:symbol] == symbol.to_s.upcase }.first
|
23
|
+
if sym.nil? || sym[:id].nil?
|
24
|
+
raise ArgumentError,
|
25
|
+
"Could not find match in #{config[:symbols_file]} for given symbol #{symbol}"
|
26
|
+
end
|
27
|
+
raise ArgumentError, "Mismatching symbol #{symbol} and given id #{id}" if (not id.nil?) && (sym[:id] != id)
|
28
|
+
|
29
|
+
return sym
|
30
|
+
end
|
31
|
+
unless id.nil?
|
32
|
+
sym = symbols.select { |s| s[:id] == id.to_s }.first
|
33
|
+
if sym.nil? || sym[:id].nil?
|
34
|
+
raise ArgumentError,
|
35
|
+
"Could not find match in #{config[:symbols_file]} for given id #{id}"
|
36
|
+
end
|
37
|
+
return sym
|
38
|
+
end
|
39
|
+
raise ArgumentError, 'Need :id, :symbol or valid :contract '
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cotcube-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.9
|
4
|
+
version: 0.1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin L. Tischendorf
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/cotcube-helpers/constants.rb
|
100
100
|
- lib/cotcube-helpers/datetime_ext.rb
|
101
101
|
- lib/cotcube-helpers/enum_ext.rb
|
102
|
+
- lib/cotcube-helpers/get_id_set.rb
|
102
103
|
- lib/cotcube-helpers/hash_ext.rb
|
103
104
|
- lib/cotcube-helpers/init.rb
|
104
105
|
- lib/cotcube-helpers/input.rb
|