redis_importer 1.1.3 → 1.1.4

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.
@@ -13,6 +13,7 @@ module RedisImporter
13
13
  self.files = self.collection.files
14
14
  self.errors = []
15
15
  self.commands = []
16
+ self.run_pipeline = true
16
17
  end
17
18
 
18
19
  # Converts each csv file in the collection to objects, which are then saved into the redis store.
@@ -27,11 +28,12 @@ module RedisImporter
27
28
  end
28
29
  end
29
30
 
30
- pipeline if !@prevent_pipeline
31
+ pipeline
31
32
  end
32
33
 
33
34
  private
34
35
 
36
+ attr_accessor :run_pipeline
35
37
  attr_writer :files, :commands, :errors
36
38
 
37
39
  def add_errors(errors)
@@ -58,9 +60,9 @@ module RedisImporter
58
60
  objects.each do |obj|
59
61
  begin
60
62
  self.commands << obj.to_redis
61
- rescue
62
- @prevent_pipeline = true
63
- add_errors($!)
63
+ rescue => details
64
+ run_pipeline = false
65
+ add_errors("#{obj.inspect} could not be serialized to redis: " + details.to_s)
64
66
  end
65
67
  end
66
68
  end
@@ -68,9 +70,9 @@ module RedisImporter
68
70
  def local_storage_path(file)
69
71
  "#{@settings['local_storage_directory']}/#{file.name}"
70
72
  end
71
-
73
+
72
74
  def pipeline
73
- if !self.commands.empty?
75
+ if run_pipeline?
74
76
  pipeline = RedisPipeline::RedisPipeline.new
75
77
  pipeline.add_command(self.commands.flatten)
76
78
  if !pipeline.execute
@@ -80,11 +82,14 @@ module RedisImporter
80
82
  true
81
83
  end
82
84
  else
83
- add_errors("No commands")
84
85
  false
85
86
  end
86
87
  end
87
88
 
89
+ def run_pipeline?
90
+ run_pipeline
91
+ end
92
+
88
93
  def save_remote_file_locally(file)
89
94
  file.save_to(local_storage_path(file))
90
95
  end
@@ -1,3 +1,3 @@
1
1
  module RedisImporter
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: