imp_exp 1.0.6 → 1.0.7

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: 26e8634a3041bbe34e2d8488bc6238dfd44544fa862704ef18fd40f5a0544a97
4
- data.tar.gz: 16aae84ac54c68d7c14c988f22ea2d19363f2eacb0c6043b7a495980ced72c90
3
+ metadata.gz: f795bb8e12db3914363f65aa3cb931d9d6bc210688b65eef052acab274060481
4
+ data.tar.gz: b3d8391a78c691492c405dcc72c3c75b4231cdf727c5125f984a8a13bc951553
5
5
  SHA512:
6
- metadata.gz: 062176d6f62d1e9b8043a7e2730499e1e73319a756176e729f86eceec29c1ca13acc86f77928cc8b41f7cad56845d9a5f1fed28b088843694bfd12a19d4d1dbb
7
- data.tar.gz: 811d80f670688704d2fd839bdf26a43d26281e57b88e19fcd72bc0bd418530fe9daad0a3c50014177ba1b9b26fc3cdfca558c3e86938d55b7d665b56afc8c82d
6
+ metadata.gz: 4168507d5656a360c6607484172a0f226b651dfd72e5c568ca765d5fe21e813897832153903ebf75167f39708f5790c3df3c822c3e11a1b53639156ae056b91b
7
+ data.tar.gz: 0ca2f92ec2fd8e378efd7ddafb7049b3b49206cf985a34f5bd6af6ef5c43701cae9d21126e4012bc8c0e307633561195175913471ea9f939ec3efeb9943cf58e
@@ -7,7 +7,7 @@ module ImpExp
7
7
  class Base
8
8
  include Observable
9
9
 
10
- attr_reader :scoping_parent, :models, :logger, :exception_notifier, :errors, :imported
10
+ attr_reader :scoping_parent, :models, :logger, :exception_notifier, :errors, :imported, :skipped
11
11
 
12
12
  ROW_OFFSET = 2
13
13
 
@@ -21,6 +21,7 @@ module ImpExp
21
21
  def call(data, files_directory_path = nil)
22
22
  @errors = []
23
23
  @imported = data.keys.map(&:model_name).index_with { 0 }
24
+ @skipped = data.keys.map(&:model_name).index_with { 0 }
24
25
  logger.info "Starting import #{self.class.name} for #{scoping_parent.model_name.singular} " \
25
26
  "#{scoping_parent.name} (#{scoping_parent.id})"
26
27
  begin
@@ -47,7 +48,7 @@ module ImpExp
47
48
  end
48
49
 
49
50
  def import_result
50
- { imported: imported, import_errors: errors }
51
+ { imported: imported, skipped: skipped, import_errors: errors }
51
52
  end
52
53
 
53
54
  def import_model_data(model, model_data, files_directory_path) # rubocop:disable Metrics/MethodLength
@@ -65,6 +66,11 @@ module ImpExp
65
66
 
66
67
  record = find_or_initialize_record(row.merge(relation_attributes), scoping_parent, model)
67
68
 
69
+ if model.skip_record?(record)
70
+ @skipped[model.model_name] += 1
71
+ next
72
+ end
73
+
68
74
  upsert_no_record_error(row, model, line) && next unless record
69
75
 
70
76
  assign_attributes(record, attrs, model_name, line, row)
@@ -75,6 +81,11 @@ module ImpExp
75
81
 
76
82
  attach_files(record, files_directory_path, model, row, line) if files_directory_path.present?
77
83
 
84
+ if model.skip_record?(record)
85
+ @skipped[model.model_name] += 1
86
+ next
87
+ end
88
+
78
89
  if record.save(context: :import)
79
90
  model.after_save(record)
80
91
  @imported[model.model_name] += 1
@@ -125,6 +125,10 @@ module ImpExp
125
125
  data
126
126
  end
127
127
 
128
+ def skip_record?(_record)
129
+ false
130
+ end
131
+
128
132
  def files(scoping_parent)
129
133
  scoped(scoping_parent).flat_map do |record|
130
134
  record.slice(file_attribute_names).values.select(&:attached?)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ImpExp
4
- VERSION = "1.0.6"
4
+ VERSION = "1.0.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imp_exp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dev team Nerya
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-09-04 00:00:00.000000000 Z
10
+ date: 2025-05-14 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: caxlsx
@@ -123,11 +122,9 @@ files:
123
122
  - lib/imp_exp.rb
124
123
  - lib/imp_exp/version.rb
125
124
  - lib/tasks/imp_exp.rake
126
- homepage:
127
125
  licenses:
128
126
  - MIT
129
127
  metadata: {}
130
- post_install_message:
131
128
  rdoc_options: []
132
129
  require_paths:
133
130
  - lib
@@ -142,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
139
  - !ruby/object:Gem::Version
143
140
  version: '0'
144
141
  requirements: []
145
- rubygems_version: 3.4.19
146
- signing_key:
142
+ rubygems_version: 3.6.2
147
143
  specification_version: 4
148
144
  summary: Import data from xlsx into a rails app and export data to xlsx from a rails
149
145
  app