sycsvpro 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/html/Sycsvpro/Filter.html +43 -2
- data/html/Sycsvpro/RowFilter.html +2 -1
- data/html/created.rid +4 -4
- data/html/js/search_index.js +1 -1
- data/html/table_of_contents.html +29 -24
- data/lib/sycsvpro/filter.rb +11 -1
- data/lib/sycsvpro/row_filter.rb +2 -1
- data/lib/sycsvpro/version.rb +1 -1
- data/spec/sycsvpro/analyze_spec.rb +1 -1
- data/spec/sycsvpro/collector_spec.rb +1 -1
- data/spec/sycsvpro/counter_spec.rb +2 -1
- data/spec/sycsvpro/extractor_spec.rb +14 -0
- data/spec/sycsvpro/mapper_spec.rb +2 -1
- data/spec/sycsvpro/profiler_spec.rb +2 -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: cb699d3d7d012d38933471d8d5f52d9f5a114ca8
|
4
|
+
data.tar.gz: b1e29aeaeb827ce59fcbee98e492f184025d6e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e76f1f7f1de7cd90b77b5a78f1b9dbda877c9292cd6bd592f3677cf305738339aee9e1fc5d57df0fb39c74d75ea53948cefe9876031667c2598ce7309c18f3df
|
7
|
+
data.tar.gz: f3c0bf8e9d2eaae8a76ffd7420be5e7c10bc929019d7edf7c44ff9e191f1e8042cdc87512aff3f20efb93a5b5c8e523a39fccb8aebd09e3ea62971790791b092
|
data/Gemfile.lock
CHANGED
data/html/Sycsvpro/Filter.html
CHANGED
@@ -75,6 +75,8 @@
|
|
75
75
|
|
76
76
|
<li ><a href="#method-c-new">::new</a>
|
77
77
|
|
78
|
+
<li ><a href="#method-i-has_filter-3F">#has_filter?</a>
|
79
|
+
|
78
80
|
<li class="calls-super" ><a href="#method-i-method_missing">#method_missing</a>
|
79
81
|
|
80
82
|
<li ><a href="#method-i-pivot_each_column">#pivot_each_column</a>
|
@@ -223,6 +225,40 @@ to override the process method</p>
|
|
223
225
|
</header>
|
224
226
|
|
225
227
|
|
228
|
+
<div id="method-i-has_filter-3F" class="method-detail ">
|
229
|
+
|
230
|
+
<div class="method-heading">
|
231
|
+
<span class="method-name">has_filter?</span><span
|
232
|
+
class="method-args">()</span>
|
233
|
+
|
234
|
+
<span class="method-click-advice">click to toggle source</span>
|
235
|
+
|
236
|
+
</div>
|
237
|
+
|
238
|
+
|
239
|
+
<div class="method-description">
|
240
|
+
|
241
|
+
<p>Checks whether a filter has been set. Returns true if filter has been set
|
242
|
+
otherwise false</p>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<div class="method-source-code" id="has_filter-3F-source">
|
248
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 57</span>
|
249
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">has_filter?</span>
|
250
|
+
<span class="ruby-keyword">return</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">filter</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">empty?</span>)
|
251
|
+
<span class="ruby-keyword">end</span></pre>
|
252
|
+
</div>
|
253
|
+
|
254
|
+
</div>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</div>
|
260
|
+
|
261
|
+
|
226
262
|
<div id="method-i-method_missing" class="method-detail ">
|
227
263
|
|
228
264
|
<div class="method-heading">
|
@@ -271,7 +307,7 @@ to override the process method</p>
|
|
271
307
|
|
272
308
|
<div class="method-heading">
|
273
309
|
<span class="method-name">pivot_each_column</span><span
|
274
|
-
class="method-args">(values=[]) { |column,
|
310
|
+
class="method-args">(values=[]) { |column, match| ... }</span>
|
275
311
|
|
276
312
|
<span class="method-click-advice">click to toggle source</span>
|
277
313
|
|
@@ -289,7 +325,12 @@ to override the process method</p>
|
|
289
325
|
<pre><span class="ruby-comment"># File lib/sycsvpro/filter.rb, line 45</span>
|
290
326
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pivot_each_column</span>(<span class="ruby-identifier">values</span>=[])
|
291
327
|
<span class="ruby-identifier">pivot</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">column</span>, <span class="ruby-identifier">parameters</span><span class="ruby-operator">|</span>
|
292
|
-
<span class="ruby-
|
328
|
+
<span class="ruby-identifier">match</span> = <span class="ruby-keyword">false</span>
|
329
|
+
<span class="ruby-keyword">begin</span>
|
330
|
+
<span class="ruby-identifier">match</span> = <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">parameters</span>[<span class="ruby-value">:operation</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-string">'[value]'</span>, <span class="ruby-identifier">values</span>[<span class="ruby-identifier">parameters</span>[<span class="ruby-value">:col</span>].<span class="ruby-identifier">to_i</span>]))
|
331
|
+
<span class="ruby-keyword">rescue</span>
|
332
|
+
<span class="ruby-keyword">end</span>
|
333
|
+
<span class="ruby-keyword">yield</span> <span class="ruby-identifier">column</span>, <span class="ruby-identifier">match</span>
|
293
334
|
<span class="ruby-keyword">end</span>
|
294
335
|
<span class="ruby-keyword">end</span></pre>
|
295
336
|
</div>
|
@@ -132,7 +132,8 @@
|
|
132
132
|
<div class="method-source-code" id="process-source">
|
133
133
|
<pre><span class="ruby-comment"># File lib/sycsvpro/row_filter.rb, line 10</span>
|
134
134
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process</span>(<span class="ruby-identifier">object</span>, <span class="ruby-identifier">options</span>={})
|
135
|
-
<span class="ruby-
|
135
|
+
<span class="ruby-keyword">return</span> <span class="ruby-identifier">object</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">has_filter?</span>
|
136
|
+
<span class="ruby-identifier">filtered</span> = <span class="ruby-operator">!</span><span class="ruby-identifier">filter</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:row</span>]).<span class="ruby-identifier">nil?</span>
|
136
137
|
<span class="ruby-identifier">pattern</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
|
137
138
|
<span class="ruby-identifier">filtered</span> = (<span class="ruby-identifier">filtered</span> <span class="ruby-keyword">or</span> <span class="ruby-operator">!</span>(<span class="ruby-identifier">object</span> <span class="ruby-operator">=~</span> <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">p</span>)).<span class="ruby-identifier">nil?</span>)
|
138
139
|
<span class="ruby-keyword">end</span>
|
data/html/created.rid
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Mon, 17 Feb 2014 21:03:10 +0100
|
2
2
|
README.rdoc Sun, 16 Feb 2014 22:01:46 +0100
|
3
3
|
lib/sycsvpro.rb Sun, 16 Feb 2014 21:33:36 +0100
|
4
4
|
lib/sycsvpro/analyzer.rb Sun, 16 Feb 2014 21:08:55 +0100
|
@@ -8,10 +8,10 @@ lib/sycsvpro/column_filter.rb Sun, 16 Feb 2014 21:10:11 +0100
|
|
8
8
|
lib/sycsvpro/counter.rb Sun, 16 Feb 2014 21:38:32 +0100
|
9
9
|
lib/sycsvpro/dsl.rb Sun, 16 Feb 2014 21:20:01 +0100
|
10
10
|
lib/sycsvpro/extractor.rb Sun, 16 Feb 2014 21:06:42 +0100
|
11
|
-
lib/sycsvpro/filter.rb
|
11
|
+
lib/sycsvpro/filter.rb Mon, 17 Feb 2014 21:02:21 +0100
|
12
12
|
lib/sycsvpro/header.rb Sun, 16 Feb 2014 21:30:06 +0100
|
13
13
|
lib/sycsvpro/mapper.rb Sun, 16 Feb 2014 21:04:46 +0100
|
14
14
|
lib/sycsvpro/profiler.rb Sun, 16 Feb 2014 21:31:39 +0100
|
15
|
-
lib/sycsvpro/row_filter.rb
|
16
|
-
lib/sycsvpro/version.rb
|
15
|
+
lib/sycsvpro/row_filter.rb Mon, 17 Feb 2014 19:48:06 +0100
|
16
|
+
lib/sycsvpro/version.rb Mon, 17 Feb 2014 20:31:15 +0100
|
17
17
|
bin/sycsvpro Sun, 16 Feb 2014 18:17:16 +0100
|
data/html/js/search_index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var search_data = {"index":{"searchIndex":["dsl","object","sycsvpro","analyzer","calculator","collector","columnfilter","counter","extractor","filter","header","mapper","profiler","rowfilter","execute()","execute()","execute()","execute()","execute()","execute()","method_missing()","method_missing()","new()","new()","new()","new()","new()","new()","new()","new()","new()","pivot_each_column()","process()","process()","process()","process()","process_file()","result()","rows()","write_result()","write_to()","readme"],"longSearchIndex":["dsl","object","sycsvpro","sycsvpro::analyzer","sycsvpro::calculator","sycsvpro::collector","sycsvpro::columnfilter","sycsvpro::counter","sycsvpro::extractor","sycsvpro::filter","sycsvpro::header","sycsvpro::mapper","sycsvpro::profiler","sycsvpro::rowfilter","sycsvpro::calculator#execute()","sycsvpro::collector#execute()","sycsvpro::counter#execute()","sycsvpro::extractor#execute()","sycsvpro::mapper#execute()","sycsvpro::profiler#execute()","sycsvpro::calculator#method_missing()","sycsvpro::filter#method_missing()","sycsvpro::analyzer::new()","sycsvpro::calculator::new()","sycsvpro::collector::new()","sycsvpro::counter::new()","sycsvpro::extractor::new()","sycsvpro::filter::new()","sycsvpro::header::new()","sycsvpro::mapper::new()","sycsvpro::profiler::new()","sycsvpro::filter#pivot_each_column()","sycsvpro::columnfilter#process()","sycsvpro::filter#process()","sycsvpro::header#process()","sycsvpro::rowfilter#process()","sycsvpro::counter#process_file()","sycsvpro::analyzer#result()","dsl#rows()","sycsvpro::counter#write_result()","dsl#write_to()",""],"info":[["Dsl","","Dsl.html","","<p>Methods to be used in customer specific script files\n"],["Object","","Object.html","",""],["Sycsvpro","","Sycsvpro.html","","<p>Operating csv files\n<p>Operating csv files\n<p>Operating csv files\n"],["Sycsvpro::Analyzer","","Sycsvpro/Analyzer.html","","<p>Analyzes the file structure\n"],["Sycsvpro::Calculator","","Sycsvpro/Calculator.html","","<p>Processes arithmetic operations on columns of a csv file. A column value\nhas to be a number. Possible …\n"],["Sycsvpro::Collector","","Sycsvpro/Collector.html","","<p>Collects values from rows and groups them in categories\n"],["Sycsvpro::ColumnFilter","","Sycsvpro/ColumnFilter.html","","<p>Creates a new column filter\n"],["Sycsvpro::Counter","","Sycsvpro/Counter.html","","<p>Creates a new counter that counts values and uses the values as column\nnames and uses the count as the …\n"],["Sycsvpro::Extractor","","Sycsvpro/Extractor.html","","<p>Extracts rows and columns from a csv file\n"],["Sycsvpro::Filter","","Sycsvpro/Filter.html","","<p>Creates a new filter that can be extended by sub-classes. A sub-class needs\nto override the process method …\n"],["Sycsvpro::Header","","Sycsvpro/Header.html","","<p>Creates a header\n"],["Sycsvpro::Mapper","","Sycsvpro/Mapper.html","","<p>Map values to new values described in a mapping file\n"],["Sycsvpro::Profiler","","Sycsvpro/Profiler.html","","<p>A profiler takes a Ruby script and executes the provided method in the\nscript\n"],["Sycsvpro::RowFilter","","Sycsvpro/RowFilter.html","","<p>Filters rows based on provided patterns\n"],["execute","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-execute","()","<p>Executes the calculator\n"],["execute","Sycsvpro::Collector","Sycsvpro/Collector.html#method-i-execute","()","<p>Execute the collector\n"],["execute","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-execute","()","<p>Executes the counter\n"],["execute","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-i-execute","()","<p>Executes the extractor\n"],["execute","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-i-execute","()","<p>Executes the mapper\n"],["execute","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-i-execute","(method)","<p>Executes the provided method in the Ruby script\n"],["method_missing","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-method_missing","(id, *args, &block)","<p>Retrieves the values from a row as the result of a arithmetic operation\n"],["method_missing","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-method_missing","(id, *args, &block)","<p>Creates the filters based on the given patterns\n"],["new","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-c-new","(file)","<p>Creates a new analyzer\n"],["new","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-c-new","(options={})","<p>Creates a new Calculator. Options expects :infile, :outfile, :rows and\n:columns. Optionally a header …\n"],["new","Sycsvpro::Collector","Sycsvpro/Collector.html#method-c-new","(options={})","<p>Creates a new Collector\n"],["new","Sycsvpro::Counter","Sycsvpro/Counter.html#method-c-new","(options={})","<p>Creates a new counter\n"],["new","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-c-new","(options={})","<p>Creates a new extractor\n"],["new","Sycsvpro::Filter","Sycsvpro/Filter.html#method-c-new","(values, options={})","<p>Creates a new filter\n"],["new","Sycsvpro::Header","Sycsvpro/Header.html#method-c-new","(header)","<p>Create a new header\n"],["new","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-c-new","(options={})","<p>Creates new mapper\n"],["new","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-c-new","(pro_file)","<p>Creates a new profiler\n"],["pivot_each_column","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-pivot_each_column","(values=[])","<p>Yields the column value and whether the filter matches the column\n"],["process","Sycsvpro::ColumnFilter","Sycsvpro/ColumnFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the values that respect the filter\n"],["process","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-process","(object, options={})","<p>Processes the filter. Needs to be overridden by the sub-class\n"],["process","Sycsvpro::Header","Sycsvpro/Header.html#method-i-process","(line)","<p>Returns the header\n"],["process","Sycsvpro::RowFilter","Sycsvpro/RowFilter.html#method-i-process","(object, options={})","<p>Processes the filter on the given row\n"],["process_file","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-process_file","()","<p>Processes the counting on the in file\n"],["result","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-i-result","()","<p>Analyzes the file and returns the result\n"],["rows","Dsl","Dsl.html#method-i-rows","(options={})","<p>Retrieves rows and columns from the file and returns them to the block\nprovided by the caller\n"],["write_result","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-write_result","()","<p>Writes the results\n"],["write_to","Dsl","Dsl.html#method-i-write_to","(file)","<p>writes values provided by a block to the given file\n"],["README","","README_rdoc.html","","<p>sycsvpro\n<p>Author — Pierre Sugar (pierre@sugaryourcoffee.de)\n<p>Copyright — Copyright © 2014 by Pierre Sugar\n"]]}}
|
1
|
+
var search_data = {"index":{"searchIndex":["dsl","object","sycsvpro","analyzer","calculator","collector","columnfilter","counter","extractor","filter","header","mapper","profiler","rowfilter","execute()","execute()","execute()","execute()","execute()","execute()","has_filter?()","method_missing()","method_missing()","new()","new()","new()","new()","new()","new()","new()","new()","new()","pivot_each_column()","process()","process()","process()","process()","process_file()","result()","rows()","write_result()","write_to()","readme"],"longSearchIndex":["dsl","object","sycsvpro","sycsvpro::analyzer","sycsvpro::calculator","sycsvpro::collector","sycsvpro::columnfilter","sycsvpro::counter","sycsvpro::extractor","sycsvpro::filter","sycsvpro::header","sycsvpro::mapper","sycsvpro::profiler","sycsvpro::rowfilter","sycsvpro::calculator#execute()","sycsvpro::collector#execute()","sycsvpro::counter#execute()","sycsvpro::extractor#execute()","sycsvpro::mapper#execute()","sycsvpro::profiler#execute()","sycsvpro::filter#has_filter?()","sycsvpro::calculator#method_missing()","sycsvpro::filter#method_missing()","sycsvpro::analyzer::new()","sycsvpro::calculator::new()","sycsvpro::collector::new()","sycsvpro::counter::new()","sycsvpro::extractor::new()","sycsvpro::filter::new()","sycsvpro::header::new()","sycsvpro::mapper::new()","sycsvpro::profiler::new()","sycsvpro::filter#pivot_each_column()","sycsvpro::columnfilter#process()","sycsvpro::filter#process()","sycsvpro::header#process()","sycsvpro::rowfilter#process()","sycsvpro::counter#process_file()","sycsvpro::analyzer#result()","dsl#rows()","sycsvpro::counter#write_result()","dsl#write_to()",""],"info":[["Dsl","","Dsl.html","","<p>Methods to be used in customer specific script files\n"],["Object","","Object.html","",""],["Sycsvpro","","Sycsvpro.html","","<p>Operating csv files\n<p>Operating csv files\n<p>Operating csv files\n"],["Sycsvpro::Analyzer","","Sycsvpro/Analyzer.html","","<p>Analyzes the file structure\n"],["Sycsvpro::Calculator","","Sycsvpro/Calculator.html","","<p>Processes arithmetic operations on columns of a csv file. A column value\nhas to be a number. Possible …\n"],["Sycsvpro::Collector","","Sycsvpro/Collector.html","","<p>Collects values from rows and groups them in categories\n"],["Sycsvpro::ColumnFilter","","Sycsvpro/ColumnFilter.html","","<p>Creates a new column filter\n"],["Sycsvpro::Counter","","Sycsvpro/Counter.html","","<p>Creates a new counter that counts values and uses the values as column\nnames and uses the count as the …\n"],["Sycsvpro::Extractor","","Sycsvpro/Extractor.html","","<p>Extracts rows and columns from a csv file\n"],["Sycsvpro::Filter","","Sycsvpro/Filter.html","","<p>Creates a new filter that can be extended by sub-classes. A sub-class needs\nto override the process method …\n"],["Sycsvpro::Header","","Sycsvpro/Header.html","","<p>Creates a header\n"],["Sycsvpro::Mapper","","Sycsvpro/Mapper.html","","<p>Map values to new values described in a mapping file\n"],["Sycsvpro::Profiler","","Sycsvpro/Profiler.html","","<p>A profiler takes a Ruby script and executes the provided method in the\nscript\n"],["Sycsvpro::RowFilter","","Sycsvpro/RowFilter.html","","<p>Filters rows based on provided patterns\n"],["execute","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-execute","()","<p>Executes the calculator\n"],["execute","Sycsvpro::Collector","Sycsvpro/Collector.html#method-i-execute","()","<p>Execute the collector\n"],["execute","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-execute","()","<p>Executes the counter\n"],["execute","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-i-execute","()","<p>Executes the extractor\n"],["execute","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-i-execute","()","<p>Executes the mapper\n"],["execute","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-i-execute","(method)","<p>Executes the provided method in the Ruby script\n"],["has_filter?","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-has_filter-3F","()","<p>Checks whether a filter has been set. Returns true if filter has been set\notherwise false\n"],["method_missing","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-i-method_missing","(id, *args, &block)","<p>Retrieves the values from a row as the result of a arithmetic operation\n"],["method_missing","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-method_missing","(id, *args, &block)","<p>Creates the filters based on the given patterns\n"],["new","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-c-new","(file)","<p>Creates a new analyzer\n"],["new","Sycsvpro::Calculator","Sycsvpro/Calculator.html#method-c-new","(options={})","<p>Creates a new Calculator. Options expects :infile, :outfile, :rows and\n:columns. Optionally a header …\n"],["new","Sycsvpro::Collector","Sycsvpro/Collector.html#method-c-new","(options={})","<p>Creates a new Collector\n"],["new","Sycsvpro::Counter","Sycsvpro/Counter.html#method-c-new","(options={})","<p>Creates a new counter\n"],["new","Sycsvpro::Extractor","Sycsvpro/Extractor.html#method-c-new","(options={})","<p>Creates a new extractor\n"],["new","Sycsvpro::Filter","Sycsvpro/Filter.html#method-c-new","(values, options={})","<p>Creates a new filter\n"],["new","Sycsvpro::Header","Sycsvpro/Header.html#method-c-new","(header)","<p>Create a new header\n"],["new","Sycsvpro::Mapper","Sycsvpro/Mapper.html#method-c-new","(options={})","<p>Creates new mapper\n"],["new","Sycsvpro::Profiler","Sycsvpro/Profiler.html#method-c-new","(pro_file)","<p>Creates a new profiler\n"],["pivot_each_column","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-pivot_each_column","(values=[])","<p>Yields the column value and whether the filter matches the column\n"],["process","Sycsvpro::ColumnFilter","Sycsvpro/ColumnFilter.html#method-i-process","(object, options={})","<p>Processes the filter and returns the values that respect the filter\n"],["process","Sycsvpro::Filter","Sycsvpro/Filter.html#method-i-process","(object, options={})","<p>Processes the filter. Needs to be overridden by the sub-class\n"],["process","Sycsvpro::Header","Sycsvpro/Header.html#method-i-process","(line)","<p>Returns the header\n"],["process","Sycsvpro::RowFilter","Sycsvpro/RowFilter.html#method-i-process","(object, options={})","<p>Processes the filter on the given row\n"],["process_file","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-process_file","()","<p>Processes the counting on the in file\n"],["result","Sycsvpro::Analyzer","Sycsvpro/Analyzer.html#method-i-result","()","<p>Analyzes the file and returns the result\n"],["rows","Dsl","Dsl.html#method-i-rows","(options={})","<p>Retrieves rows and columns from the file and returns them to the block\nprovided by the caller\n"],["write_result","Sycsvpro::Counter","Sycsvpro/Counter.html#method-i-write_result","()","<p>Writes the results\n"],["write_to","Dsl","Dsl.html#method-i-write_to","(file)","<p>writes values provided by a block to the given file\n"],["README","","README_rdoc.html","","<p>sycsvpro\n<p>Author — Pierre Sugar (pierre@sugaryourcoffee.de)\n<p>Copyright — Copyright © 2014 by Pierre Sugar\n"]]}}
|
data/html/table_of_contents.html
CHANGED
@@ -96,9 +96,9 @@
|
|
96
96
|
<span class="container">Sycsvpro::Analyzer</span>
|
97
97
|
|
98
98
|
<li class="method">
|
99
|
-
<a href="Sycsvpro/
|
99
|
+
<a href="Sycsvpro/Profiler.html#method-c-new">::new</a>
|
100
100
|
—
|
101
|
-
<span class="container">Sycsvpro::
|
101
|
+
<span class="container">Sycsvpro::Profiler</span>
|
102
102
|
|
103
103
|
<li class="method">
|
104
104
|
<a href="Sycsvpro/Calculator.html#method-c-new">::new</a>
|
@@ -106,9 +106,9 @@
|
|
106
106
|
<span class="container">Sycsvpro::Calculator</span>
|
107
107
|
|
108
108
|
<li class="method">
|
109
|
-
<a href="Sycsvpro/
|
109
|
+
<a href="Sycsvpro/Mapper.html#method-c-new">::new</a>
|
110
110
|
—
|
111
|
-
<span class="container">Sycsvpro::
|
111
|
+
<span class="container">Sycsvpro::Mapper</span>
|
112
112
|
|
113
113
|
<li class="method">
|
114
114
|
<a href="Sycsvpro/Header.html#method-c-new">::new</a>
|
@@ -121,14 +121,14 @@
|
|
121
121
|
<span class="container">Sycsvpro::Collector</span>
|
122
122
|
|
123
123
|
<li class="method">
|
124
|
-
<a href="Sycsvpro/
|
124
|
+
<a href="Sycsvpro/Counter.html#method-c-new">::new</a>
|
125
125
|
—
|
126
|
-
<span class="container">Sycsvpro::
|
126
|
+
<span class="container">Sycsvpro::Counter</span>
|
127
127
|
|
128
128
|
<li class="method">
|
129
|
-
<a href="Sycsvpro/
|
129
|
+
<a href="Sycsvpro/Extractor.html#method-c-new">::new</a>
|
130
130
|
—
|
131
|
-
<span class="container">Sycsvpro::
|
131
|
+
<span class="container">Sycsvpro::Extractor</span>
|
132
132
|
|
133
133
|
<li class="method">
|
134
134
|
<a href="Sycsvpro/Filter.html#method-c-new">::new</a>
|
@@ -140,16 +140,6 @@
|
|
140
140
|
—
|
141
141
|
<span class="container">Sycsvpro::Counter</span>
|
142
142
|
|
143
|
-
<li class="method">
|
144
|
-
<a href="Sycsvpro/Collector.html#method-i-execute">#execute</a>
|
145
|
-
—
|
146
|
-
<span class="container">Sycsvpro::Collector</span>
|
147
|
-
|
148
|
-
<li class="method">
|
149
|
-
<a href="Sycsvpro/Calculator.html#method-i-execute">#execute</a>
|
150
|
-
—
|
151
|
-
<span class="container">Sycsvpro::Calculator</span>
|
152
|
-
|
153
143
|
<li class="method">
|
154
144
|
<a href="Sycsvpro/Profiler.html#method-i-execute">#execute</a>
|
155
145
|
—
|
@@ -160,13 +150,23 @@
|
|
160
150
|
—
|
161
151
|
<span class="container">Sycsvpro::Mapper</span>
|
162
152
|
|
153
|
+
<li class="method">
|
154
|
+
<a href="Sycsvpro/Calculator.html#method-i-execute">#execute</a>
|
155
|
+
—
|
156
|
+
<span class="container">Sycsvpro::Calculator</span>
|
157
|
+
|
163
158
|
<li class="method">
|
164
159
|
<a href="Sycsvpro/Extractor.html#method-i-execute">#execute</a>
|
165
160
|
—
|
166
161
|
<span class="container">Sycsvpro::Extractor</span>
|
167
162
|
|
168
163
|
<li class="method">
|
169
|
-
<a href="Sycsvpro/
|
164
|
+
<a href="Sycsvpro/Collector.html#method-i-execute">#execute</a>
|
165
|
+
—
|
166
|
+
<span class="container">Sycsvpro::Collector</span>
|
167
|
+
|
168
|
+
<li class="method">
|
169
|
+
<a href="Sycsvpro/Filter.html#method-i-has_filter-3F">#has_filter?</a>
|
170
170
|
—
|
171
171
|
<span class="container">Sycsvpro::Filter</span>
|
172
172
|
|
@@ -176,14 +176,14 @@
|
|
176
176
|
<span class="container">Sycsvpro::Calculator</span>
|
177
177
|
|
178
178
|
<li class="method">
|
179
|
-
<a href="Sycsvpro/Filter.html#method-i-
|
179
|
+
<a href="Sycsvpro/Filter.html#method-i-method_missing">#method_missing</a>
|
180
180
|
—
|
181
181
|
<span class="container">Sycsvpro::Filter</span>
|
182
182
|
|
183
183
|
<li class="method">
|
184
|
-
<a href="Sycsvpro/
|
184
|
+
<a href="Sycsvpro/Filter.html#method-i-pivot_each_column">#pivot_each_column</a>
|
185
185
|
—
|
186
|
-
<span class="container">Sycsvpro::
|
186
|
+
<span class="container">Sycsvpro::Filter</span>
|
187
187
|
|
188
188
|
<li class="method">
|
189
189
|
<a href="Sycsvpro/Filter.html#method-i-process">#process</a>
|
@@ -191,15 +191,20 @@
|
|
191
191
|
<span class="container">Sycsvpro::Filter</span>
|
192
192
|
|
193
193
|
<li class="method">
|
194
|
-
<a href="Sycsvpro/
|
194
|
+
<a href="Sycsvpro/Header.html#method-i-process">#process</a>
|
195
195
|
—
|
196
|
-
<span class="container">Sycsvpro::
|
196
|
+
<span class="container">Sycsvpro::Header</span>
|
197
197
|
|
198
198
|
<li class="method">
|
199
199
|
<a href="Sycsvpro/ColumnFilter.html#method-i-process">#process</a>
|
200
200
|
—
|
201
201
|
<span class="container">Sycsvpro::ColumnFilter</span>
|
202
202
|
|
203
|
+
<li class="method">
|
204
|
+
<a href="Sycsvpro/RowFilter.html#method-i-process">#process</a>
|
205
|
+
—
|
206
|
+
<span class="container">Sycsvpro::RowFilter</span>
|
207
|
+
|
203
208
|
<li class="method">
|
204
209
|
<a href="Sycsvpro/Counter.html#method-i-process_file">#process_file</a>
|
205
210
|
—
|
data/lib/sycsvpro/filter.rb
CHANGED
@@ -44,10 +44,20 @@ module Sycsvpro
|
|
44
44
|
# Yields the column value and whether the filter matches the column
|
45
45
|
def pivot_each_column(values=[])
|
46
46
|
pivot.each do |column, parameters|
|
47
|
-
|
47
|
+
match = false
|
48
|
+
begin
|
49
|
+
match = eval(parameters[:operation].gsub('[value]', values[parameters[:col].to_i]))
|
50
|
+
rescue
|
51
|
+
end
|
52
|
+
yield column, match
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
56
|
+
# Checks whether a filter has been set. Returns true if filter has been set otherwise false
|
57
|
+
def has_filter?
|
58
|
+
return !(filter.empty? and pattern.empty?)
|
59
|
+
end
|
60
|
+
|
51
61
|
private
|
52
62
|
|
53
63
|
# Creates a filter based on the provided rows and columns
|
data/lib/sycsvpro/row_filter.rb
CHANGED
@@ -8,7 +8,8 @@ module Sycsvpro
|
|
8
8
|
|
9
9
|
# Processes the filter on the given row
|
10
10
|
def process(object, options={})
|
11
|
-
|
11
|
+
return object unless has_filter?
|
12
|
+
filtered = !filter.flatten.uniq.index(options[:row]).nil?
|
12
13
|
pattern.each do |p|
|
13
14
|
filtered = (filtered or !(object =~ Regexp.new(p)).nil?)
|
14
15
|
end
|
data/lib/sycsvpro/version.rb
CHANGED
@@ -14,7 +14,7 @@ module Sycsvpro
|
|
14
14
|
result.cols.should =~ ['customer', 'contract-number', 'expires-on', 'machine',
|
15
15
|
'product1', 'product2']
|
16
16
|
result.col_count.should eq 6
|
17
|
-
result.row_count.should eq
|
17
|
+
result.row_count.should eq 6
|
18
18
|
result.sample_row.should eq "Fink;1234;20.12.2015;f1;con123;dri222"
|
19
19
|
end
|
20
20
|
|
@@ -14,7 +14,7 @@ module Sycsvpro
|
|
14
14
|
cols: "customer:0+products:4,5", rows: "1-20")
|
15
15
|
collector.execute
|
16
16
|
|
17
|
-
result = ['[customer]', 'Fink', 'Gent', 'Haas', 'Rank',
|
17
|
+
result = ['[customer]', 'Fink', 'Gent', 'Haas', 'Klig', 'Rank',
|
18
18
|
'[products]', 'con123', 'con332', 'con333',
|
19
19
|
'dri111', 'dri222', 'dri321']
|
20
20
|
File.open(@out_file).each_with_index do |line, index|
|
@@ -22,6 +22,20 @@ module Sycsvpro
|
|
22
22
|
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should extract rows based on regex" do
|
26
|
+
extractor = Extractor.new(infile: @in_file, outfile: @out_file, rows: "/dri3.*/")
|
27
|
+
|
28
|
+
extractor.execute
|
29
|
+
|
30
|
+
result = [ "Fink;3342;30.12.2016;f2;con333;dri321",
|
31
|
+
"Rank;3232;1.5.2013;r1;con332;dri321" ]
|
32
|
+
|
33
|
+
File.open(@out_file).each_with_index do |line, index|
|
34
|
+
line.chomp.should eq result[index]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
25
39
|
end
|
26
40
|
|
27
41
|
end
|
@@ -20,7 +20,8 @@ module Sycsvpro
|
|
20
20
|
"Haas;3322;1.10.2011;h1;control332;drive111",
|
21
21
|
"Gent;4323;1.3.2014;g1;control123;drive111",
|
22
22
|
"Fink;3342;30.12.2016;f2;control333;drive321",
|
23
|
-
"Rank;3232;1.5.2013;r1;control332;drive321"
|
23
|
+
"Rank;3232;1.5.2013;r1;control332;drive321",
|
24
|
+
"Klig;4432;;k1;control332;drive222" ]
|
24
25
|
|
25
26
|
File.open(@out_file).each_with_index do |line, index|
|
26
27
|
line.chomp.should eq result[index]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sycsvpro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Sugar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|