imp_exp 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b590fb77458ecbbde482ccc594ac06b3480551b6f32ad6361c9e34b30cd4c49b
4
- data.tar.gz: 5ac34f8c6a50ec3a2d1571ffa83ccb9a07241c1822ab4860b217d3980c941961
3
+ metadata.gz: 5f28ed3841e2f2cef56566da34d4994ba911680f3524d5568cb0a2211dab2d0c
4
+ data.tar.gz: e7f954cf9859c05aabe70b21c0d8cb6db9623e96e0ba269bb348b39f0bc2905b
5
5
  SHA512:
6
- metadata.gz: 1551c0ad5706897955e9be29229686b9b1c65b0307654114c23dea08ce62771e90bbdcbcc5df867012b0ed9e8774caffded874cc5d4da6ed62ecc450e9c14162
7
- data.tar.gz: b677f5e62d8e066bc1254efdfc00faa15f39266ddb95945d2e800f5178b912a25e87cc14ff7a80d0d4ae9a789b7ae5d4908cd23eb7ace35dede73161c011c4da
6
+ metadata.gz: 96e48f2adb43f7eeb7a49d5a367c9eb4aeaf5f2ac0fd6eb377fd092521b0ce4bc1a7eac3d783236668297d6889508251cacb9684accbcdb24d8878667affcf62
7
+ data.tar.gz: 84bdf4afd2c4a37285347394523ac0354bfd791f21ed661727bc03737bc36601df9f3f14c6b58eda374fc7bf563e200b4a4548eb6e7c0f421d630d7a79b172da
@@ -82,8 +82,7 @@ module ImpExp
82
82
  end
83
83
 
84
84
  begin
85
- if record.save(context: :import)
86
- model.after_save(record)
85
+ if model.save(record)
87
86
  @imported[model.model_name] += 1
88
87
  next
89
88
  end
@@ -145,7 +144,7 @@ module ImpExp
145
144
 
146
145
  full_file_path = File.join(files_directory_path, file_path.strip)
147
146
  begin
148
- file = File.open(full_file_path)
147
+ file = File.open(full_file_path) # rubocop:disable Style/FileOpen
149
148
  record.send(file_attribute_name).attach(io: file, filename: File.basename(file_path))
150
149
  rescue Errno::ENOENT
151
150
  error_msg = I18n.t('imp_exp.importer.file_not_found', file_path: file_path)
@@ -42,6 +42,8 @@ module ImpExp
42
42
  end
43
43
 
44
44
  { format_errors: format_errors, data_validation_errors: data_validation_errors }.merge(import_result)
45
+ rescue Xsv::DuplicateHeaders
46
+ { format_errors: { name: :duplicated_headers } }
45
47
  end
46
48
 
47
49
  private
@@ -143,7 +143,9 @@ module ImpExp
143
143
  "#{active_storage_file.name}-#{active_storage_file.record.code}#{file_extension(active_storage_file)}"
144
144
  end
145
145
 
146
- def after_save(_record); end
146
+ def save(record)
147
+ record.save(context: :import)
148
+ end
147
149
 
148
150
  private
149
151
 
@@ -26,7 +26,7 @@ module ImpExp
26
26
  return [ImpExp::Serializers::Errors::WrongFormat.new("#{relation_name} error | #{message}")]
27
27
  end
28
28
 
29
- unless data.is_a?(Array) && data.all? { |datum| datum.is_a?(Hash) }
29
+ unless data.is_a?(Array) && data.all?(Hash)
30
30
  return [ImpExp::Serializers::Errors::WrongFormat.new("#{relation_name} should be an array of hashes")]
31
31
  end
32
32
 
@@ -1,6 +1,7 @@
1
1
  en:
2
2
  imp_exp:
3
3
  importer:
4
+ duplicated_headers: "A duplicate header in a sheet of the import file prevents the file from being imported"
4
5
  invalid_columns: "The %{model_name} sheet does not contain the expected columns. Expected columns: %{expected_columns} Columns in the file: %{in_file_columns}."
5
6
  invalid_sheets: "The file does not contain the expected sheets. Expected sheets: %{expected_sheets} Sheets in the file: %{in_file_sheets}."
6
7
  record_not_found: "%{model_name} with %{conditions} conditions has not been found."
@@ -1,6 +1,7 @@
1
1
  fr:
2
2
  imp_exp:
3
3
  importer:
4
+ duplicated_headers: "Un doublon d'en-tête de colonne dans une feuille du fichier d'import empêche l'import de fonctionner."
4
5
  invalid_columns: "La feuille %{model_name} ne contient pas les colonnes attendues. Colonnes attendues : %{expected_columns}. Colonnes dans le fichier : %{in_file_columns}."
5
6
  invalid_sheets: "Le fichier ne contient pas les feuilles attendues. Feuilles attendues : %{expected_sheets}. Feuilles dans le fichier : %{in_file_sheets}."
6
7
  record_not_found: "%{model_name} avec les conditions %{conditions} n'a pas été trouvé."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImpExp
4
- VERSION = "1.1.2"
4
+ VERSION = "1.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imp_exp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dev team Nerya
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 4.0.3
142
+ rubygems_version: 4.0.10
143
143
  specification_version: 4
144
144
  summary: Import data from xlsx into a rails app and export data to xlsx from a rails
145
145
  app