csv_piper 0.1.5 → 0.1.6
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.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/csv_piper/piper.rb +6 -2
- data/lib/csv_piper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1730caf6aa83cafab982b7b85147c925b234f521
|
4
|
+
data.tar.gz: 7168642217a18cd0aa59e9dfa7ff5d00f8760a57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac6e0b802e8517c17ce7cc5ba75d00b925c8914cadafda373288dbc45b7749b165652b70f581997c9ffe21cfd64223a6fef6312748db82a1fc020008ac59c19a
|
7
|
+
data.tar.gz: 280a4d9d57a9be26f39770f10b84ab78360d0c16eb51048e8f2c14b301ddf7ef1350ae5add162096c8c2b50957ec971b7510df2e10bb751d9f9d8c930c5d2889
|
data/README.md
CHANGED
@@ -81,7 +81,7 @@ class EvaluateEquation
|
|
81
81
|
begin
|
82
82
|
transformed[:valid] = eval(transformed[:equation]) == true
|
83
83
|
rescue Exception
|
84
|
-
errors.add(:
|
84
|
+
errors.add(:equation, transformed[:equation] + ' is not valid')
|
85
85
|
end
|
86
86
|
[transformed, errors]
|
87
87
|
end
|
@@ -113,9 +113,11 @@ class PassThrough
|
|
113
113
|
end
|
114
114
|
```
|
115
115
|
|
116
|
-
* `source` is a frozen hash representing the row data out of the csv (with headers as keys)
|
116
|
+
* `source` is a frozen hash representing the row data out of the csv (with headers as keys).
|
117
117
|
* `transformed` is whatever has been passed on by the previous processor. The first processor will receive an empty hash.
|
118
|
-
* `errors` is an instance of `CsvPiper::Errors::Row
|
118
|
+
* `errors` is an instance of `CsvPiper::Errors::Row`. This is really a convenience object for basic error collecting. You could choose to ignore it and implement your own error handling mechanisms.
|
119
|
+
|
120
|
+
If you return `nil` instead of `[transformed, errors]` all further processing of the row will be skipped.
|
119
121
|
|
120
122
|
_Return value_ is what will be passed into _transformed_ and _errors_ of the next processor
|
121
123
|
|
@@ -138,6 +140,8 @@ end
|
|
138
140
|
* `source` is a hash representing the row data out of the csv which may have been modified by a previous pre-processor
|
139
141
|
* `errors` is an instance of `CsvPiper::Errors::Row`
|
140
142
|
|
143
|
+
If you return `nil` instead of `[transformed, errors]` all further processing of the row will be skipped.
|
144
|
+
|
141
145
|
_Return value_ is what will be passed into _source_ and _errors_ of the next pre-processor (and processors). Final pre-processor value of _source_ will be passed to each processor as a frozen hash. Final pre-processor value of _errors_ will be passed to the first processor.
|
142
146
|
|
143
147
|
#### Row Errors
|
data/lib/csv_piper/piper.rb
CHANGED
@@ -43,14 +43,18 @@ module CsvPiper
|
|
43
43
|
|
44
44
|
def process_row(row_index, row)
|
45
45
|
pre_processed_row, row_errors = pre_processors.reduce([row, Errors::Row.new(row_index)]) do |memo, processor|
|
46
|
-
processor.process(*memo)
|
46
|
+
output = processor.process(*memo)
|
47
|
+
return if output.nil?
|
48
|
+
output
|
47
49
|
end
|
48
50
|
|
49
51
|
frozen_row = pre_processed_row.freeze
|
50
52
|
|
51
53
|
processed_data = {}
|
52
54
|
processed_data, row_errors = processors.reduce([processed_data, row_errors]) do |memo, processor|
|
53
|
-
processor.process(frozen_row, *memo)
|
55
|
+
output = processor.process(frozen_row, *memo)
|
56
|
+
return if output.nil?
|
57
|
+
output
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
data/lib/csv_piper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_piper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrod Sibbison
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|