bulk-processor 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bulk-processor.gemspec +1 -0
- data/lib/bulk_processor/back_end/active_job.rb +6 -1
- data/lib/bulk_processor/back_end/dynosaur.rb +6 -1
- data/lib/bulk_processor/job.rb +1 -1
- data/lib/bulk_processor/payload_serializer.rb +25 -0
- data/lib/bulk_processor/version.rb +1 -1
- data/lib/bulk_processor.rb +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5938f4133413fe9183607008301eda98d5961a3a
|
4
|
+
data.tar.gz: 60f3090d882a96290250a59ccce5d1ff7bd49139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5541b7a3bc23bccd4842fbf7a5439ac40d06a0497ac6cf033368546c59b72f0d7e3d637e6e063597ad726d3ea48928fdbf6631e6d7d647719469336afcfed1cd
|
7
|
+
data.tar.gz: 1538237aafa5c71cb1c8a04f64eb0b921dae8aa4153235ba8386fd01e4a43478c9a7074b7ffc12eb656ef4cd1a1916dbc11b531a55c1c463e87e616c52f27489
|
data/bulk-processor.gemspec
CHANGED
@@ -24,6 +24,7 @@ success or failure report
|
|
24
24
|
spec.add_runtime_dependency 'activejob', '~> 4'
|
25
25
|
spec.add_runtime_dependency 'aws-sdk', '~> 2.1'
|
26
26
|
spec.add_runtime_dependency 'dynosaur', '~> 0.2.1'
|
27
|
+
spec.add_runtime_dependency 'rack', '~> 1.5'
|
27
28
|
|
28
29
|
spec.add_development_dependency 'bundler'
|
29
30
|
spec.add_development_dependency 'pry-byebug', '~> 3'
|
@@ -9,7 +9,12 @@ class BulkProcessor
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def start
|
12
|
-
Job.perform_later(
|
12
|
+
Job.perform_later(
|
13
|
+
processor_class.name,
|
14
|
+
PayloadSerializer.serialize(payload),
|
15
|
+
file_class.name,
|
16
|
+
key
|
17
|
+
)
|
13
18
|
end
|
14
19
|
|
15
20
|
private
|
@@ -14,7 +14,12 @@ class BulkProcessor
|
|
14
14
|
def start
|
15
15
|
args = {
|
16
16
|
task: 'bulk_processor:start',
|
17
|
-
args: [
|
17
|
+
args: [
|
18
|
+
processor_class.name,
|
19
|
+
PayloadSerializer.serialize(payload),
|
20
|
+
file_class.name,
|
21
|
+
key
|
22
|
+
]
|
18
23
|
}
|
19
24
|
::Dynosaur::Process::Heroku.new(args).start
|
20
25
|
end
|
data/lib/bulk_processor/job.rb
CHANGED
@@ -7,7 +7,7 @@ class BulkProcessor
|
|
7
7
|
|
8
8
|
def perform(processor_class, payload, file_class, key)
|
9
9
|
file = file_class.constantize.new(key)
|
10
|
-
payload =
|
10
|
+
payload = PayloadSerializer.deserialize(payload)
|
11
11
|
file.open do |f|
|
12
12
|
csv = CSV.parse(f.read, headers: true)
|
13
13
|
processor = processor_class.constantize.new(csv, payload: payload)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class BulkProcessor
|
5
|
+
# The payload must be serialized to be command line friendly (since Dynosaur
|
6
|
+
# runs a rake task with command-line args)
|
7
|
+
module PayloadSerializer
|
8
|
+
class << self
|
9
|
+
# @param payload [Hash] the client payload to be passed into the processing
|
10
|
+
# job and ultimately the handler
|
11
|
+
# @return [String] a serialized version of the string that can be passed
|
12
|
+
# to any of the back-ends
|
13
|
+
def serialize(payload)
|
14
|
+
URI.encode_www_form(payload)
|
15
|
+
end
|
16
|
+
|
17
|
+
# @param payload [String] a serialized version of the payload
|
18
|
+
# @return [Hash] the original Hash payload (with all keys and values
|
19
|
+
# stringified)
|
20
|
+
def deserialize(string)
|
21
|
+
Rack::Utils.parse_nested_query(string)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/bulk_processor.rb
CHANGED
@@ -3,6 +3,7 @@ require 'bulk_processor/back_end/active_job'
|
|
3
3
|
require 'bulk_processor/back_end/dynosaur'
|
4
4
|
require 'bulk_processor/config'
|
5
5
|
require 'bulk_processor/job'
|
6
|
+
require 'bulk_processor/payload_serializer'
|
6
7
|
require 'bulk_processor/s3_file'
|
7
8
|
require 'bulk_processor/stream_encoder'
|
8
9
|
require 'bulk_processor/validated_csv'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulk-processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Collier, Justin Richard
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +153,7 @@ files:
|
|
139
153
|
- lib/bulk_processor/csv_processor/result.rb
|
140
154
|
- lib/bulk_processor/csv_processor/row_processor.rb
|
141
155
|
- lib/bulk_processor/job.rb
|
156
|
+
- lib/bulk_processor/payload_serializer.rb
|
142
157
|
- lib/bulk_processor/s3_file.rb
|
143
158
|
- lib/bulk_processor/stream_encoder.rb
|
144
159
|
- lib/bulk_processor/tasks.rb
|