processor 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -0
- data/lib/processor/thread.rb +0 -2
- data/lib/processor/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -34,6 +34,7 @@ Contents
|
|
34
34
|
1. Requirements
|
35
35
|
1. Usage
|
36
36
|
1. Data processors
|
37
|
+
1. Subroutines
|
37
38
|
1. Run modes
|
38
39
|
1. Processor Thread
|
39
40
|
1. Observers
|
@@ -111,6 +112,33 @@ example. See `data/solr_pages_processor.rb`.
|
|
111
112
|
see `data/csv_processor.rb` for running migration from CSV files.
|
112
113
|
|
113
114
|
|
115
|
+
### Subroutines
|
116
|
+
Subroutines are small programs that do exactly one task. It is
|
117
|
+
possible to enhance data processor by passing it to subroutine first.
|
118
|
+
Subroutines are decorators. There are several predefined subroutines:
|
119
|
+
|
120
|
+
1. Name [[code](https://github.com/AlexParamonov/processor/blob/master/lib/processor/subroutine/name.rb), [specs](https://github.com/AlexParamonov/processor/blob/master/spec/processor/subroutine/name_spec.rb)]
|
121
|
+
1. Count [[code](https://github.com/AlexParamonov/processor/blob/master/lib/processor/subroutine/counter.rb), [specs](https://github.com/AlexParamonov/processor/blob/master/spec/processor/subroutine/counter_spec.rb)]
|
122
|
+
1. Recursion [[code](https://github.com/AlexParamonov/processor/blob/master/lib/processor/subroutine/recursion.rb), [specs](https://github.com/AlexParamonov/processor/blob/master/spec/processor/subroutine/recursion_spec.rb)]
|
123
|
+
|
124
|
+
`Subroutine::Name` adds `name` method that returns name of the current
|
125
|
+
data processor. `Subroutine::Count` adds `remaining_records_count` and
|
126
|
+
`processed_records_count` methods. `Subroutine::Recursion` prevents
|
127
|
+
recursion of data processor. It uses `total_records` method and take
|
128
|
+
care about keeping count of `process` method calls in borders.
|
129
|
+
|
130
|
+
Some subroutines are used by parts of `Processor` when needed:
|
131
|
+
`Subroutine::Name` is used in `Observer::Logger`, `Subroutine::Count`
|
132
|
+
is used by `Subroutine::Recursion`
|
133
|
+
|
134
|
+
To use `Subroutine::Recursion`, first wrap a data processor before
|
135
|
+
running it:
|
136
|
+
|
137
|
+
``` ruby
|
138
|
+
user_updater = Processor::Subroutine::Recursion.new(UpdateUserLocationCodes.new)
|
139
|
+
Processor::Thread.new(user_updater).run_successive
|
140
|
+
```
|
141
|
+
|
114
142
|
### Run modes
|
115
143
|
Currently 2 run modes are supported:
|
116
144
|
|
data/lib/processor/thread.rb
CHANGED
data/lib/processor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -152,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
segments:
|
154
154
|
- 0
|
155
|
-
hash:
|
155
|
+
hash: 148591874566411659
|
156
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
157
|
none: false
|
158
158
|
requirements:
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
segments:
|
163
163
|
- 0
|
164
|
-
hash:
|
164
|
+
hash: 148591874566411659
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
167
|
rubygems_version: 1.8.25
|