All notable changes to this project will be documented in this file.
after_build
block is only called once (#47 by @fxgallego and #52 @pnomolos)after_build
andafter_save
blocks don't leak between runtime definitions (#47 by @fxgallego and #52 @pnomolos)
- You can customize the encoding with the
encoding
option. Default isUTF-8
. (#38 by @egg-chicken)
- Empty cells are now empty strings. You don't have to check for a nil value when applying a transformation anymore.
# Prior to 0.3, an empty cell turns into `nil`
column :email, to: ->(email) { email.downcase unless email.nil? }
# From 0.3, an empty cell turns into `""`
column :email, to: ->(email) { email.downcase }
- You can now skip an import in the
after_build
callback:
UserImport.new(file: csv_file) do
# Skip existing records
after_build do |user|
skip! if user.persisted?
end
end
after_save
callback.
progress_bar = ProgressBar.new
UserImport.new(file: my_file) do
after_save do |user|
progress_bar.increment
end
end
- You can define a composite identifier made of multiple columns.
# Update records with matching company_id AND employee_id
identifier :company_id, :employee_id
- You can set a custom
quote_char
at runtime. (#26 by @shvetsovdm)
UserImport.new(file: csv_file, quote_char: "'")
- You can now change the configuration at runtime. Example:
UserImport.new(file: csv_file) do
after_build do |user|
user.import_by_user = current_user
end
end
-
Add
after_build
hooks to perform arbitrary operations on a model before saving it. -
identifier
does not have to be a required attribute anymore. That enables you to useid
as an identifier and import new entries without having to provide anid
run!
was not returning a report object when the header was invalid.
- When calling
run!
on an import with invalid header we update the report object instead of raising an exception.
- Initial Release