csv_step_importer 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a36a92f9240a933980983aff9d079724cc44882cd914ed2d6c2b51c1fbb47cca
4
- data.tar.gz: 57dbea48c65e11867605da9621029b5da65d6700ffda0f092dfbe0c00e5b2858
3
+ metadata.gz: 340c82c7b6f4e56a0092d5044971b9a2aa6e66739a045162afc0e12bf5da3345
4
+ data.tar.gz: 8691cb1d2f8402598b62210d20c742e6d1246a97915e2fd5a81bbbe9c5a7736a
5
5
  SHA512:
6
- metadata.gz: 15157867c54bdd4d7868901c353667775f24a9b9ae5a34cc98659184bb52d0119f923cfa4577a4e6385b440da810c2fca4ba03ae2c1bce35cdf07d70045c6b98
7
- data.tar.gz: 94f5eebbdc2fac03edcf0a18d3727bc0681f062a8f2cc631f201a8c2e94a2b97460fdb8370615f8dc262ae7e152de58dec77772a13a36ebe4685fd1cd02a0793
6
+ metadata.gz: 147a95d14716f92967a5059f6202e992b2a9f4a3316cf139cd11d02a669ea449051c2b2a61447e63c66cfd763957041a8c212e5edab72d419ef6628569fae0ed
7
+ data.tar.gz: 771576acb65c952f7837a9c9fed7bbb3444e06918d4a3384e06644a17f664f38450acc8f3ee1124ae87706c32de3813adc3c24637da221291d352dbf86556a41
data/CHANGELOG.md CHANGED
@@ -129,3 +129,8 @@ See lib/csv_step_importer/file.rb for more options
129
129
 
130
130
  - ImportableModel's finder_keys method now defaults to composite_key_columns
131
131
  - ImportableModel's Importer (uses ActiveRecord::Import) now raises an exception if the import fails
132
+
133
+ ## 2018-09-11 Version 0.11.1
134
+ ### Added
135
+ ### Changed
136
+ - Fixed `composite_key_columns` filter functionality
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- csv_step_importer (0.11.0)
4
+ csv_step_importer (0.11.1)
5
5
  activemodel
6
6
  activerecord-import
7
7
  activesupport
data/README.md CHANGED
@@ -7,6 +7,10 @@ It depends on
7
7
  - [zdennis/activerecord-import](https://github.com/zdennis/activerecord-import)
8
8
  - [GitHub - tilo/smarter_csv](https://github.com/tilo/smarter_csv)
9
9
 
10
+ ## Sample Application (Thanks to @vochicong)
11
+
12
+ [vochicong/csv_step_importer_sample](https://github.com/vochicong/csv_step_importer_sample)
13
+
10
14
  ## Installation
11
15
 
12
16
  Add this line to your application's Gemfile:
@@ -6,7 +6,7 @@ module CSVStepImporter
6
6
  class Loader < CSVStepImporter::Node
7
7
  def initialize(file_class: CSVStepImporter::File, chunk_class: CSVStepImporter::Chunk, **attributes)
8
8
  super **attributes.slice(:parent, :children, :env)
9
- add_children attributes[:path] ? file_class.new( **attributes.merge!(chunk_class: chunk_class) ) : chunk_class.new( **attributes )
9
+ add_children attributes[:path] ? file_class.new(**attributes.merge!(chunk_class: chunk_class)) : chunk_class.new(**attributes)
10
10
  end
11
11
  end
12
12
  end
@@ -60,7 +60,7 @@ module CSVStepImporter
60
60
  end
61
61
 
62
62
  # retrieve a dao for a different model using the same CSV row. This is useful e.g. if you use the reflector to get ids of related data
63
- def dao_for model:, pluralize: false
63
+ def dao_for(model:, pluralize: false)
64
64
  row.cache[model.cache_key(pluralize: pluralize)]
65
65
  end
66
66
 
@@ -74,7 +74,7 @@ module CSVStepImporter
74
74
  end
75
75
 
76
76
  # unlink this dao from the row and replace it with a different dao
77
- def unlink! replace_with: nil
77
+ def unlink!(replace_with: nil)
78
78
  cached_daos = row.cache[model.cache_key(pluralize: true)]
79
79
 
80
80
  # remove from cache with pluralized key
@@ -21,8 +21,8 @@ module CSVStepImporter
21
21
  # Configuration
22
22
  #########################################################
23
23
 
24
- def self.cache_key pluralize: false
25
- key = name.underscore.gsub('/', '_')
24
+ def self.cache_key(pluralize: false)
25
+ key = name.underscore.gsub("/", "_")
26
26
  (pluralize ? key.pluralize : key.singularize).to_sym
27
27
  end
28
28
 
@@ -79,14 +79,14 @@ module CSVStepImporter
79
79
  def filter_daos!
80
80
  unique_daos = {}
81
81
 
82
- daos.delete_if do |dao|
83
- hash = dao.value.slice(composite_key_columns).hash
84
- should_delete = (unique_daos[hash] ||= dao) == dao
82
+ daos.keep_if do |dao|
83
+ hash = dao.value.slice(*composite_key_columns).hash
84
+ keep = (unique_daos[hash] ||= dao) == dao
85
85
 
86
86
  # unlink to be deleted dao and add a link to
87
- dao.unlink! replace_with: unique_daos[hash] unless should_delete
87
+ dao.unlink! replace_with: unique_daos[hash] unless keep
88
88
 
89
- should_delete
89
+ keep
90
90
  end
91
91
  end
92
92
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSVStepImporter
4
- VERSION = "0.11.0"
4
+ VERSION = "0.11.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csv_step_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian-Manuel Butzke