lib/eco/cli/config/default/input.rb in eco-helpers-2.3.2 vs lib/eco/cli/config/default/input.rb in eco-helpers-2.3.3
- old
+ new
@@ -53,21 +53,27 @@
format ||= :csv
options.deep_merge!(input: {file: {name: file}})
options.deep_merge!(input: {file: {format: format}})
+ encoding = options.dig(:input, :file, :encoding)
+
case format
when :xml
[file].flatten.each {|f| session.config.files.validate(:xml, f)}
- input = session.entries(file: file, format: format)
+ kargs = {file: file, format: format}
+ kargs.merge!(encoding: encoding) if encoding
+ input = session.entries(**kargs)
when :xls
input = session.entries(file: file, format: format)
when :json
input = [file].flatten.reduce(Eco::API::Organization::People.new([])) do |people, file|
people.merge(JSON.parse(File.read(file)))
end
else # :csv
- input = session.csv_entries(file, check_headers: true)
+ kargs = {check_headers: true}
+ kargs.merge!(encoding: encoding) if encoding
+ input = session.csv_entries(file, **kargs)
end
end
input
end
end