processor 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/processor.rb +1 -0
- data/lib/processor/data/active_record_batch_processor.rb +40 -0
- data/lib/processor/version.rb +1 -1
- data/processor.gemspec +0 -1
- data/spec/spec_helper_lite.rb +1 -0
- metadata +18 -32
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MWExYTAxNjk0MDU3MGRiMDc3NmE3NzA0MzNkZjMzMTYxZTEwY2I3OA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7325236eb0afe0d54037330c14e9e92f86e619f1
|
4
|
+
data.tar.gz: 0ba778329bfb0303aad872898514b584becca282
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
N2Y5NzY3MzI4MTZiN2UyMDY0NDgwYzQ1N2E1NDIxNmU2NmM4Y2I0ZmE5YjI1
|
11
|
-
NGU2ZjIwZTU1OWVmNjRmM2FhODY1ODFiOTBmODI5ZWI0MWExNGU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MWQ3MWIyZGIzZGVhYzA1ZWJkYjlhOWM5NzE0MDIzZDRhNjE2NmI0MGE5OTk5
|
14
|
-
N2FhZTBiMzViNDY0MTM1NWMyNGNkZDI1ZTNjZDcxYjA5OTgzMzBjZThkMTNk
|
15
|
-
NzNmOWE2YjdhNDMwZmE1YmM5MjU3N2Q4ZmZiZWRlNjAzM2MwZjI=
|
6
|
+
metadata.gz: bd4daf73250b1600753f79ba0b3b9aa7e962e702b63a13a8ce6c0a43590f5603269e768b4d9166178c0d24b8cc5694e1adbc1b187bea92eb8d10e268267545f2
|
7
|
+
data.tar.gz: 37749c66a998816b215fa66719973e04d4adb3b664a9f66dc521d9f8cffc884b89c9a3bef093f363dda3e76c9842116e5d6aa9cfc7d03cfe6a68c7a259621a78
|
data/lib/processor.rb
CHANGED
@@ -6,6 +6,7 @@ require "processor/data/batch_processor"
|
|
6
6
|
require "processor/data/null_processor"
|
7
7
|
require "processor/data/solr_pages_processor"
|
8
8
|
require "processor/data/csv_processor"
|
9
|
+
require "processor/data/active_record_batch_processor"
|
9
10
|
|
10
11
|
require "processor/observer/logger"
|
11
12
|
require "processor/observer/null_observer"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "null_processor"
|
2
|
+
|
3
|
+
module Processor
|
4
|
+
module Data
|
5
|
+
class ActiveRecordBatchProcessor < NullProcessor
|
6
|
+
attr_reader :source
|
7
|
+
|
8
|
+
def initialize(source:, presenter: -> { Hash.new }, output:, batch_size: 1000)
|
9
|
+
@source = source
|
10
|
+
@presenter = presenter
|
11
|
+
@output = output
|
12
|
+
@batch_size = batch_size
|
13
|
+
end
|
14
|
+
|
15
|
+
def records
|
16
|
+
source.find_each(batch_size: batch_size)
|
17
|
+
end
|
18
|
+
|
19
|
+
def process(record)
|
20
|
+
output.write presenter.call(record)
|
21
|
+
"OK"
|
22
|
+
end
|
23
|
+
|
24
|
+
def record_id(record)
|
25
|
+
record.id
|
26
|
+
end
|
27
|
+
|
28
|
+
def finalize
|
29
|
+
output.close
|
30
|
+
end
|
31
|
+
|
32
|
+
def total_records
|
33
|
+
@total_records ||= source.count
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
attr_reader :presenter, :output, :batch_size
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/processor/version.rb
CHANGED
data/processor.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_development_dependency "rake"
|
23
23
|
gem.add_development_dependency "rspec", "~> 2.6"
|
24
24
|
gem.add_development_dependency "pry" unless Processor::RUNNING_ON_CI
|
25
|
-
gem.add_development_dependency "pry-plus" if "ruby" == RUBY_ENGINE && false == Processor::RUNNING_ON_CI
|
26
25
|
gem.add_development_dependency "coveralls" if Processor::RUNNING_ON_CI
|
27
26
|
end
|
28
27
|
|
data/spec/spec_helper_lite.rb
CHANGED
metadata
CHANGED
@@ -1,72 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Paramonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
|
56
|
-
name: pry-plus
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ! '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
description: ! 'Processor is a tool that helps to iterate over collection and perform
|
55
|
+
description: 'Processor is a tool that helps to iterate over collection and perform
|
70
56
|
complex actions on a result. It is extremely useful in data migrations, report generation,
|
71
57
|
etc. '
|
72
58
|
email:
|
@@ -75,11 +61,11 @@ executables: []
|
|
75
61
|
extensions: []
|
76
62
|
extra_rdoc_files: []
|
77
63
|
files:
|
78
|
-
- .coveralls.yml
|
79
|
-
- .gitignore
|
80
|
-
- .rspec
|
81
|
-
- .rvmrc
|
82
|
-
- .travis.yml
|
64
|
+
- ".coveralls.yml"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rspec"
|
67
|
+
- ".rvmrc"
|
68
|
+
- ".travis.yml"
|
83
69
|
- Gemfile
|
84
70
|
- LICENSE
|
85
71
|
- README.md
|
@@ -89,6 +75,7 @@ files:
|
|
89
75
|
- example/migrator.rb
|
90
76
|
- example/observer/progress_bar.rb
|
91
77
|
- lib/processor.rb
|
78
|
+
- lib/processor/data/active_record_batch_processor.rb
|
92
79
|
- lib/processor/data/array_processor.rb
|
93
80
|
- lib/processor/data/batch_processor.rb
|
94
81
|
- lib/processor/data/csv_processor.rb
|
@@ -138,17 +125,17 @@ require_paths:
|
|
138
125
|
- lib
|
139
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
127
|
requirements:
|
141
|
-
- -
|
128
|
+
- - ">="
|
142
129
|
- !ruby/object:Gem::Version
|
143
130
|
version: '0'
|
144
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
132
|
requirements:
|
146
|
-
- -
|
133
|
+
- - ">="
|
147
134
|
- !ruby/object:Gem::Version
|
148
135
|
version: '0'
|
149
136
|
requirements: []
|
150
137
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.4.5
|
152
139
|
signing_key:
|
153
140
|
specification_version: 4
|
154
141
|
summary: Universal processor for threaded collection iteration, logging and post processing
|
@@ -172,4 +159,3 @@ test_files:
|
|
172
159
|
- spec/processor/thread_spec.rb
|
173
160
|
- spec/spec_helper_lite.rb
|
174
161
|
- spec/support/dummy_file
|
175
|
-
has_rdoc:
|