Maintenance: Add missing gem 'csv' to gemfile, and only load it when it's actuallly used.
This commit is contained in:
parent
60c9c45c96
commit
ce4ca035d6
4 changed files with 9 additions and 4 deletions
3
Gemfile
3
Gemfile
|
@ -116,6 +116,9 @@ gem 'diffy'
|
||||||
# feature - excel output
|
# feature - excel output
|
||||||
gem 'writeexcel', require: false
|
gem 'writeexcel', require: false
|
||||||
|
|
||||||
|
# feature - csv import/export
|
||||||
|
gem 'csv', require: false
|
||||||
|
|
||||||
# feature - device logging
|
# feature - device logging
|
||||||
gem 'browser'
|
gem 'browser'
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ GEM
|
||||||
crack (0.4.5)
|
crack (0.4.5)
|
||||||
rexml
|
rexml
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
|
csv (3.2.0)
|
||||||
daemons (1.4.1)
|
daemons (1.4.1)
|
||||||
dalli (2.7.11)
|
dalli (2.7.11)
|
||||||
debug_inspector (1.1.0)
|
debug_inspector (1.1.0)
|
||||||
|
@ -667,6 +668,7 @@ DEPENDENCIES
|
||||||
coffeelint
|
coffeelint
|
||||||
composite_primary_keys
|
composite_primary_keys
|
||||||
coveralls
|
coveralls
|
||||||
|
csv
|
||||||
daemons
|
daemons
|
||||||
dalli
|
dalli
|
||||||
delayed_job_active_record
|
delayed_job_active_record
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'csv'
|
|
||||||
|
|
||||||
module CanCsvImport
|
module CanCsvImport
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
@ -59,6 +57,7 @@ returns
|
||||||
raise Exceptions::UnprocessableEntity, "Unable to read file '#{data[:file]}': #{e.inspect}"
|
raise Exceptions::UnprocessableEntity, "Unable to read file '#{data[:file]}': #{e.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'csv' # Only load it when it's really needed to save memory.
|
||||||
header, *rows = ::CSV.parse(data[:string], **data[:parse_params])
|
header, *rows = ::CSV.parse(data[:string], **data[:parse_params])
|
||||||
|
|
||||||
header&.each do |column|
|
header&.each do |column|
|
||||||
|
@ -296,6 +295,8 @@ returns
|
||||||
end
|
end
|
||||||
rows_to_add = []
|
rows_to_add = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require 'csv' # Only load it when it's really needed to save memory.
|
||||||
::CSV.generate(**params) do |csv|
|
::CSV.generate(**params) do |csv|
|
||||||
csv << header
|
csv << header
|
||||||
rows.each do |row|
|
rows.each do |row|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
||||||
|
|
||||||
require 'csv'
|
|
||||||
|
|
||||||
class Translation < ApplicationModel
|
class Translation < ApplicationModel
|
||||||
before_create :set_initial
|
before_create :set_initial
|
||||||
after_create :cache_clear
|
after_create :cache_clear
|
||||||
|
@ -407,6 +405,7 @@ Get source file at https://i18n.zammad.com/api/v1/translations_empty_translation
|
||||||
params = {
|
params = {
|
||||||
col_sep: ',',
|
col_sep: ',',
|
||||||
}
|
}
|
||||||
|
require 'csv' # Only load it when it's really needed to save memory.
|
||||||
rows = ::CSV.parse(content, params)
|
rows = ::CSV.parse(content, params)
|
||||||
rows.shift # remove header
|
rows.shift # remove header
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue