tc211-termbase 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +1 -1
- data/lib/tc211/termbase/terms_section.rb +23 -3
- data/lib/tc211/termbase/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: '049c87340f58462f36a45c0978834fa683de647e72af78a55c2d555fc7ea09aa'
|
4
|
+
data.tar.gz: 2b2c751263666da6a923c23e806b6c40cac19e341302d0de2a61033b53362894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a74af7f537f2220380174f965fa83f3daedc837d19796c831ad7dcf4125cb3b654dfa9be6e2e8505e70431e0c2739efd2f148fae918506806aab26f79bda67
|
7
|
+
data.tar.gz: ebc860160347076c9a14f1caaef7172e06a5c686d80524b18325ef23fd98782b2135f6643d60d0d9447ee9ff9757e50ec8b8acc961ebbd28178e50b6193863b0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -90,7 +90,16 @@ module Tc211::Termbase
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def structure
|
93
|
-
@structure
|
93
|
+
return @structure if @structure
|
94
|
+
|
95
|
+
header_mapping = parse_header_mapping
|
96
|
+
validate_header_mapping(header_mapping)
|
97
|
+
|
98
|
+
@structure = header_mapping
|
99
|
+
end
|
100
|
+
|
101
|
+
def parse_header_mapping
|
102
|
+
@header_row.inject({}) do |acc, (key, value)|
|
94
103
|
# puts "#{key}, #{value}, #{GLOSSARY_HEADER_TITLES[value]}"
|
95
104
|
|
96
105
|
# convert whitespace to a single space
|
@@ -119,9 +128,20 @@ module Tc211::Termbase
|
|
119
128
|
end
|
120
129
|
|
121
130
|
end
|
131
|
+
end
|
132
|
+
|
133
|
+
class HeaderMappingInvalidError < StandardError; end;
|
122
134
|
|
123
|
-
|
124
|
-
|
135
|
+
# Validate structure
|
136
|
+
# - should not have multiple columns mapping to the same key
|
137
|
+
def validate_header_mapping(header_mapping)
|
138
|
+
header_mapping.group_by do |k, v|
|
139
|
+
v
|
140
|
+
end.each do |k, v|
|
141
|
+
if v.length > 1
|
142
|
+
raise HeaderMappingInvalidError.new("Data key '#{k}' mapping from columns #{v.map(&:first)}; it should only be mapped from one column. Please check the TERM_BODY_COLUMN_MAP constant.")
|
143
|
+
end
|
144
|
+
end
|
125
145
|
end
|
126
146
|
|
127
147
|
def self.match_header(columns)
|