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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78f4de44ae17599fe675a8309f1fe6a5509e7573
4
- data.tar.gz: 457ea3be103e375d63f1381d9fd313edee9b5f62
3
+ metadata.gz: 1730caf6aa83cafab982b7b85147c925b234f521
4
+ data.tar.gz: 7168642217a18cd0aa59e9dfa7ff5d00f8760a57
5
5
  SHA512:
6
- metadata.gz: bcaf281ec4903d7b2f8858d42208679f146fd3bb1d65e75a406d87a8f60bea8c0f69416b3b4a8944ec2c65057c95c673a1dced66f58fa9e608a5a672b290ca3a
7
- data.tar.gz: dde6626276fc85fc710c90706b1eb0ed015420fd0ef3d4a5121040361166cf18e1d00d01cea7aa9032c5e2f6f1b44953c1230f76f9c9e43e4fbaa5f9d2e80819
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(:msg, transformed[:equation] + ' is not a valid equation')
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module CsvPiper
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-18 00:00:00.000000000 Z
11
+ date: 2015-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler