ntq_excelsior 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ntq_excelsior/importer.rb +6 -4
- data/lib/ntq_excelsior/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: 2534fffa978dea103d8390ddd1cd836af2f893a014420e5c40d533ecfbb36a74
|
4
|
+
data.tar.gz: e12b3fbe2bc7936ee524c2d5840192f3a052b66ae4efbfe40a04f740374c7168
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3875d165c478e19f7e7ced68842df945078d257c8af9e5dc0e6eb6b42ac47d558b814889dfe5c775f6f349e6382d083709fbdfa6b5c578fe45155e7166bdf905
|
7
|
+
data.tar.gz: 7bcbc5f75d39f5444c53039dbd2e3c8968b3a8ef39f756529474cf9d1656d9ef13f1376fe593373732e668d067af1625ee8a2f2938a1d7b5b3a9d59d5befd0bd
|
data/Gemfile.lock
CHANGED
@@ -54,7 +54,7 @@ module NtqExcelsior
|
|
54
54
|
return @required_headers if @required_headers
|
55
55
|
|
56
56
|
@required_columns = self.class.schema.select { |_field, column_config| !column_config.is_a?(Hash) || !column_config.key?(:required) || column_config[:required] }
|
57
|
-
@required_headers = @required_columns.values.map { |column| get_column_header(column) }.map { |header|
|
57
|
+
@required_headers = @required_columns.values.map { |column| get_column_header(column) }.map { |header| transform_header_to_regexp(header) }
|
58
58
|
if self.class.primary_key && !@required_columns.keys.include?(self.class.primary_key)
|
59
59
|
@required_headers.unshift(Regexp.new(self.class.primary_key.to_s, "i"))
|
60
60
|
end
|
@@ -69,12 +69,14 @@ module NtqExcelsior
|
|
69
69
|
missing_headers = []
|
70
70
|
|
71
71
|
e.message.slice(1..-1).chop.split(",").map(&:strip).each do |header_missing|
|
72
|
-
header_missing_regex =
|
72
|
+
header_missing_regex = transform_header_to_regexp(header_missing, true)
|
73
73
|
header_found = @required_columns.values.find do |column|
|
74
|
-
|
74
|
+
transform_header_to_regexp(get_column_header(column)) == header_missing_regex
|
75
75
|
end
|
76
76
|
if header_found && header_found.is_a?(Hash) && header_found[:humanized_header].present?
|
77
77
|
missing_headers << header_found[:humanized_header]
|
78
|
+
elsif header_found&.is_a?(String)
|
79
|
+
missing_headers << header_found
|
78
80
|
else
|
79
81
|
missing_headers << header_missing
|
80
82
|
end
|
@@ -224,7 +226,7 @@ module NtqExcelsior
|
|
224
226
|
column[:header]
|
225
227
|
end
|
226
228
|
|
227
|
-
def
|
229
|
+
def transform_header_to_regexp(header, gsub_enclosure = false)
|
228
230
|
return header unless header.is_a?(String)
|
229
231
|
|
230
232
|
if gsub_enclosure && header.scan(/^\/[\^]?([^(\$\/)]+)[\$]?\/[i]?$/i) && $1
|