sycsvpro 0.0.1
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 +7 -0
- data/.gitignore +21 -0
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +20 -0
- data/README.md +188 -0
- data/README.rdoc +44 -0
- data/Rakefile +44 -0
- data/bin/sycsvpro +208 -0
- data/features/step_definitions/sycsvpro_steps.rb +6 -0
- data/features/support/env.rb +15 -0
- data/features/sycsvpro.feature +8 -0
- data/html/Dsl.html +201 -0
- data/html/Object.html +116 -0
- data/html/README_rdoc.html +178 -0
- data/html/Sycsvpro/Analyzer.html +239 -0
- data/html/Sycsvpro/Calculator.html +354 -0
- data/html/Sycsvpro/Collector.html +281 -0
- data/html/Sycsvpro/ColumnFilter.html +165 -0
- data/html/Sycsvpro/Counter.html +397 -0
- data/html/Sycsvpro/Extractor.html +269 -0
- data/html/Sycsvpro/Filter.html +349 -0
- data/html/Sycsvpro/Header.html +228 -0
- data/html/Sycsvpro/Mapper.html +288 -0
- data/html/Sycsvpro/Profiler.html +234 -0
- data/html/Sycsvpro/RowFilter.html +162 -0
- data/html/Sycsvpro.html +141 -0
- data/html/created.rid +17 -0
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/fonts.css +167 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +202 -0
- data/html/js/darkfish.js +140 -0
- data/html/js/jquery.js +18 -0
- data/html/js/navigation.js +142 -0
- data/html/js/search.js +109 -0
- data/html/js/search_index.js +1 -0
- data/html/js/searcher.js +228 -0
- data/html/rdoc.css +580 -0
- data/html/table_of_contents.html +236 -0
- data/lib/sycsvpro/analyzer.rb +40 -0
- data/lib/sycsvpro/calculator.rb +94 -0
- data/lib/sycsvpro/collector.rb +60 -0
- data/lib/sycsvpro/column_filter.rb +23 -0
- data/lib/sycsvpro/counter.rb +74 -0
- data/lib/sycsvpro/dsl.rb +37 -0
- data/lib/sycsvpro/extractor.rb +39 -0
- data/lib/sycsvpro/filter.rb +98 -0
- data/lib/sycsvpro/header.rb +29 -0
- data/lib/sycsvpro/mapper.rb +53 -0
- data/lib/sycsvpro/profiler.rb +26 -0
- data/lib/sycsvpro/row_filter.rb +20 -0
- data/lib/sycsvpro/version.rb +5 -0
- data/lib/sycsvpro.rb +9 -0
- data/spec/sycsvpro/analyze_spec.rb +23 -0
- data/spec/sycsvpro/calculator_spec.rb +45 -0
- data/spec/sycsvpro/collector_spec.rb +27 -0
- data/spec/sycsvpro/counter_spec.rb +51 -0
- data/spec/sycsvpro/extractor_spec.rb +27 -0
- data/spec/sycsvpro/files/mappings +6 -0
- data/spec/sycsvpro/files/profile.rb +42 -0
- data/spec/sycsvpro/mapper_spec.rb +33 -0
- data/spec/sycsvpro/profiler_spec.rb +32 -0
- data/sycsvpro.gemspec +24 -0
- data/sycsvpro.rdoc +29 -0
- metadata +215 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>class Sycsvpro::Counter - Your application title</title>
|
|
8
|
+
|
|
9
|
+
<link href="../fonts.css" rel="stylesheet">
|
|
10
|
+
<link href="../rdoc.css" rel="stylesheet">
|
|
11
|
+
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
var rdoc_rel_prefix = "../";
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script src="../js/jquery.js"></script>
|
|
17
|
+
<script src="../js/navigation.js"></script>
|
|
18
|
+
<script src="../js/search_index.js"></script>
|
|
19
|
+
<script src="../js/search.js"></script>
|
|
20
|
+
<script src="../js/searcher.js"></script>
|
|
21
|
+
<script src="../js/darkfish.js"></script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<body id="top" role="document" class="class">
|
|
25
|
+
<nav role="navigation">
|
|
26
|
+
<div id="project-navigation">
|
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
28
|
+
<h2>
|
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
|
30
|
+
</h2>
|
|
31
|
+
|
|
32
|
+
<div id="table-of-contents-navigation">
|
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
41
|
+
<div id="search-field-wrapper">
|
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
|
49
|
+
aria-busy="false" aria-expanded="false"
|
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
51
|
+
</form>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<div id="class-metadata">
|
|
59
|
+
|
|
60
|
+
<div id="parent-class-section" class="nav-section">
|
|
61
|
+
<h3>Parent</h3>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<p class="link"><a href="../Object.html">Object</a>
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<!-- Method Quickref -->
|
|
71
|
+
<div id="method-list-section" class="nav-section">
|
|
72
|
+
<h3>Methods</h3>
|
|
73
|
+
|
|
74
|
+
<ul class="link-list" role="directory">
|
|
75
|
+
|
|
76
|
+
<li ><a href="#method-c-new">::new</a>
|
|
77
|
+
|
|
78
|
+
<li ><a href="#method-i-execute">#execute</a>
|
|
79
|
+
|
|
80
|
+
<li ><a href="#method-i-process_file">#process_file</a>
|
|
81
|
+
|
|
82
|
+
<li ><a href="#method-i-write_result">#write_result</a>
|
|
83
|
+
|
|
84
|
+
</ul>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
</div>
|
|
88
|
+
</nav>
|
|
89
|
+
|
|
90
|
+
<main role="main" aria-labelledby="class-Sycsvpro::Counter">
|
|
91
|
+
<h1 id="class-Sycsvpro::Counter" class="class">
|
|
92
|
+
class Sycsvpro::Counter
|
|
93
|
+
</h1>
|
|
94
|
+
|
|
95
|
+
<section class="description">
|
|
96
|
+
|
|
97
|
+
<p>Creates a new counter that counts values and uses the values as column
|
|
98
|
+
names and uses the count as the column value</p>
|
|
99
|
+
|
|
100
|
+
</section>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
<section class="attribute-method-details" class="method-section">
|
|
114
|
+
<header>
|
|
115
|
+
<h3>Attributes</h3>
|
|
116
|
+
</header>
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
<div id="attribute-i-col_filter" class="method-detail">
|
|
120
|
+
<div class="method-heading attribute-method-heading">
|
|
121
|
+
<span class="method-name">col_filter</span><span
|
|
122
|
+
class="attribute-access-type">[R]</span>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div class="method-description">
|
|
126
|
+
|
|
127
|
+
<p>filter that is used for columns</p>
|
|
128
|
+
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<div id="attribute-i-customers" class="method-detail">
|
|
133
|
+
<div class="method-heading attribute-method-heading">
|
|
134
|
+
<span class="method-name">customers</span><span
|
|
135
|
+
class="attribute-access-type">[R]</span>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<div class="method-description">
|
|
139
|
+
|
|
140
|
+
<p>values that are assigned to the key column</p>
|
|
141
|
+
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div id="attribute-i-heading" class="method-detail">
|
|
146
|
+
<div class="method-heading attribute-method-heading">
|
|
147
|
+
<span class="method-name">heading</span><span
|
|
148
|
+
class="attribute-access-type">[R]</span>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<div class="method-description">
|
|
152
|
+
|
|
153
|
+
<p>header of the out file</p>
|
|
154
|
+
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
|
|
158
|
+
<div id="attribute-i-infile" class="method-detail">
|
|
159
|
+
<div class="method-heading attribute-method-heading">
|
|
160
|
+
<span class="method-name">infile</span><span
|
|
161
|
+
class="attribute-access-type">[R]</span>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div class="method-description">
|
|
165
|
+
|
|
166
|
+
<p>infile contains the data that is operated on</p>
|
|
167
|
+
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
|
|
171
|
+
<div id="attribute-i-key_column" class="method-detail">
|
|
172
|
+
<div class="method-heading attribute-method-heading">
|
|
173
|
+
<span class="method-name">key_column</span><span
|
|
174
|
+
class="attribute-access-type">[R]</span>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<div class="method-description">
|
|
178
|
+
|
|
179
|
+
<p>values are assigned to the key column</p>
|
|
180
|
+
|
|
181
|
+
</div>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div id="attribute-i-outfile" class="method-detail">
|
|
185
|
+
<div class="method-heading attribute-method-heading">
|
|
186
|
+
<span class="method-name">outfile</span><span
|
|
187
|
+
class="attribute-access-type">[R]</span>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div class="method-description">
|
|
191
|
+
|
|
192
|
+
<p>outfile is the file where the result is written to</p>
|
|
193
|
+
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div id="attribute-i-row_filter" class="method-detail">
|
|
198
|
+
<div class="method-heading attribute-method-heading">
|
|
199
|
+
<span class="method-name">row_filter</span><span
|
|
200
|
+
class="attribute-access-type">[R]</span>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
<div class="method-description">
|
|
204
|
+
|
|
205
|
+
<p>filter that is used for rows</p>
|
|
206
|
+
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
</section>
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
215
|
+
<header>
|
|
216
|
+
<h3>Public Class Methods</h3>
|
|
217
|
+
</header>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
<div id="method-c-new" class="method-detail ">
|
|
221
|
+
|
|
222
|
+
<div class="method-heading">
|
|
223
|
+
<span class="method-name">new</span><span
|
|
224
|
+
class="method-args">(options={})</span>
|
|
225
|
+
|
|
226
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<div class="method-description">
|
|
232
|
+
|
|
233
|
+
<p>Creates a new counter</p>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
<div class="method-source-code" id="new-source">
|
|
239
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 27</span>
|
|
240
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
|
|
241
|
+
<span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
|
|
242
|
+
<span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
|
|
243
|
+
<span class="ruby-ivar">@key_column</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>].<span class="ruby-identifier">to_i</span>
|
|
244
|
+
<span class="ruby-ivar">@row_filter</span> = <span class="ruby-constant">RowFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:rows</span>])
|
|
245
|
+
<span class="ruby-ivar">@col_filter</span> = <span class="ruby-constant">ColumnFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:cols</span>], <span class="ruby-identifier">df</span><span class="ruby-operator">:</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:df</span>])
|
|
246
|
+
<span class="ruby-ivar">@customers</span> = {}
|
|
247
|
+
<span class="ruby-ivar">@heading</span> = []
|
|
248
|
+
<span class="ruby-keyword">end</span></pre>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
</div>
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
</section>
|
|
260
|
+
|
|
261
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
262
|
+
<header>
|
|
263
|
+
<h3>Public Instance Methods</h3>
|
|
264
|
+
</header>
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
<div id="method-i-execute" class="method-detail ">
|
|
268
|
+
|
|
269
|
+
<div class="method-heading">
|
|
270
|
+
<span class="method-name">execute</span><span
|
|
271
|
+
class="method-args">()</span>
|
|
272
|
+
|
|
273
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
274
|
+
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
<div class="method-description">
|
|
279
|
+
|
|
280
|
+
<p>Executes the counter</p>
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
<div class="method-source-code" id="execute-source">
|
|
286
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 38</span>
|
|
287
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
|
|
288
|
+
<span class="ruby-identifier">process_file</span>
|
|
289
|
+
<span class="ruby-identifier">write_result</span>
|
|
290
|
+
<span class="ruby-keyword">end</span></pre>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
</div>
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
<div id="method-i-process_file" class="method-detail ">
|
|
302
|
+
|
|
303
|
+
<div class="method-heading">
|
|
304
|
+
<span class="method-name">process_file</span><span
|
|
305
|
+
class="method-args">()</span>
|
|
306
|
+
|
|
307
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
308
|
+
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
<div class="method-description">
|
|
313
|
+
|
|
314
|
+
<p>Processes the counting on the in file</p>
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
<div class="method-source-code" id="process_file-source">
|
|
320
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 44</span>
|
|
321
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">process_file</span>
|
|
322
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">infile</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
|
323
|
+
<span class="ruby-identifier">result</span> = <span class="ruby-identifier">col_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>, <span class="ruby-identifier">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
|
|
324
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">empty?</span>
|
|
325
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>)[<span class="ruby-identifier">key_column</span>]
|
|
326
|
+
<span class="ruby-identifier">customer</span> = <span class="ruby-identifier">customers</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">customers</span>[<span class="ruby-identifier">key</span>] = { <span class="ruby-identifier">name</span><span class="ruby-operator">:</span> <span class="ruby-identifier">key</span>, <span class="ruby-identifier">products</span><span class="ruby-operator">:</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>) }
|
|
327
|
+
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</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-operator">|</span>
|
|
328
|
+
<span class="ruby-identifier">heading</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">column</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">column</span>).<span class="ruby-identifier">nil?</span>
|
|
329
|
+
<span class="ruby-identifier">customer</span>[<span class="ruby-value">:products</span>][<span class="ruby-identifier">column</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
|
330
|
+
<span class="ruby-keyword">end</span>
|
|
331
|
+
<span class="ruby-keyword">end</span>
|
|
332
|
+
<span class="ruby-keyword">end</span>
|
|
333
|
+
<span class="ruby-keyword">end</span></pre>
|
|
334
|
+
</div>
|
|
335
|
+
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
</div>
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
<div id="method-i-write_result" class="method-detail ">
|
|
345
|
+
|
|
346
|
+
<div class="method-heading">
|
|
347
|
+
<span class="method-name">write_result</span><span
|
|
348
|
+
class="method-args">()</span>
|
|
349
|
+
|
|
350
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
351
|
+
|
|
352
|
+
</div>
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
<div class="method-description">
|
|
356
|
+
|
|
357
|
+
<p>Writes the results</p>
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
<div class="method-source-code" id="write_result-source">
|
|
363
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/counter.rb, line 59</span>
|
|
364
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">write_result</span>
|
|
365
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>, <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
|
|
366
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> ([<span class="ruby-string">"customer"</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">heading</span>.<span class="ruby-identifier">sort</span>).<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
|
367
|
+
<span class="ruby-identifier">customers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
|
368
|
+
<span class="ruby-identifier">line</span> = [<span class="ruby-identifier">k</span>]
|
|
369
|
+
<span class="ruby-identifier">heading</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
|
|
370
|
+
<span class="ruby-identifier">line</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:products</span>][<span class="ruby-identifier">h</span>]
|
|
371
|
+
<span class="ruby-keyword">end</span>
|
|
372
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">';'</span>)
|
|
373
|
+
<span class="ruby-keyword">end</span>
|
|
374
|
+
<span class="ruby-keyword">end</span>
|
|
375
|
+
<span class="ruby-keyword">end</span></pre>
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
</div>
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
</div>
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
</section>
|
|
387
|
+
|
|
388
|
+
</section>
|
|
389
|
+
</main>
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
<footer id="validator-badges" role="contentinfo">
|
|
393
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
394
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
|
395
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
396
|
+
</footer>
|
|
397
|
+
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
|
|
7
|
+
<title>class Sycsvpro::Extractor - Your application title</title>
|
|
8
|
+
|
|
9
|
+
<link href="../fonts.css" rel="stylesheet">
|
|
10
|
+
<link href="../rdoc.css" rel="stylesheet">
|
|
11
|
+
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
var rdoc_rel_prefix = "../";
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script src="../js/jquery.js"></script>
|
|
17
|
+
<script src="../js/navigation.js"></script>
|
|
18
|
+
<script src="../js/search_index.js"></script>
|
|
19
|
+
<script src="../js/search.js"></script>
|
|
20
|
+
<script src="../js/searcher.js"></script>
|
|
21
|
+
<script src="../js/darkfish.js"></script>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
<body id="top" role="document" class="class">
|
|
25
|
+
<nav role="navigation">
|
|
26
|
+
<div id="project-navigation">
|
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
|
28
|
+
<h2>
|
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
|
30
|
+
</h2>
|
|
31
|
+
|
|
32
|
+
<div id="table-of-contents-navigation">
|
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
|
41
|
+
<div id="search-field-wrapper">
|
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
|
49
|
+
aria-busy="false" aria-expanded="false"
|
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
|
51
|
+
</form>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<div id="class-metadata">
|
|
59
|
+
|
|
60
|
+
<div id="parent-class-section" class="nav-section">
|
|
61
|
+
<h3>Parent</h3>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<p class="link"><a href="../Object.html">Object</a>
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<!-- Method Quickref -->
|
|
71
|
+
<div id="method-list-section" class="nav-section">
|
|
72
|
+
<h3>Methods</h3>
|
|
73
|
+
|
|
74
|
+
<ul class="link-list" role="directory">
|
|
75
|
+
|
|
76
|
+
<li ><a href="#method-c-new">::new</a>
|
|
77
|
+
|
|
78
|
+
<li ><a href="#method-i-execute">#execute</a>
|
|
79
|
+
|
|
80
|
+
</ul>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
</div>
|
|
84
|
+
</nav>
|
|
85
|
+
|
|
86
|
+
<main role="main" aria-labelledby="class-Sycsvpro::Extractor">
|
|
87
|
+
<h1 id="class-Sycsvpro::Extractor" class="class">
|
|
88
|
+
class Sycsvpro::Extractor
|
|
89
|
+
</h1>
|
|
90
|
+
|
|
91
|
+
<section class="description">
|
|
92
|
+
|
|
93
|
+
<p>Extracts rows and columns from a csv file</p>
|
|
94
|
+
|
|
95
|
+
</section>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
<section class="attribute-method-details" class="method-section">
|
|
109
|
+
<header>
|
|
110
|
+
<h3>Attributes</h3>
|
|
111
|
+
</header>
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<div id="attribute-i-col_filter" class="method-detail">
|
|
115
|
+
<div class="method-heading attribute-method-heading">
|
|
116
|
+
<span class="method-name">col_filter</span><span
|
|
117
|
+
class="attribute-access-type">[R]</span>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div class="method-description">
|
|
121
|
+
|
|
122
|
+
<p>filter that is used for columns</p>
|
|
123
|
+
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<div id="attribute-i-in_file" class="method-detail">
|
|
128
|
+
<div class="method-heading attribute-method-heading">
|
|
129
|
+
<span class="method-name">in_file</span><span
|
|
130
|
+
class="attribute-access-type">[R]</span>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<div class="method-description">
|
|
134
|
+
|
|
135
|
+
<p>infile contains the data that is operated on</p>
|
|
136
|
+
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div id="attribute-i-out_file" class="method-detail">
|
|
141
|
+
<div class="method-heading attribute-method-heading">
|
|
142
|
+
<span class="method-name">out_file</span><span
|
|
143
|
+
class="attribute-access-type">[R]</span>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<div class="method-description">
|
|
147
|
+
|
|
148
|
+
<p>outfile is the file where the result is written to</p>
|
|
149
|
+
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<div id="attribute-i-row_filter" class="method-detail">
|
|
154
|
+
<div class="method-heading attribute-method-heading">
|
|
155
|
+
<span class="method-name">row_filter</span><span
|
|
156
|
+
class="attribute-access-type">[R]</span>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div class="method-description">
|
|
160
|
+
|
|
161
|
+
<p>filter that is used for rows</p>
|
|
162
|
+
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
</section>
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
|
171
|
+
<header>
|
|
172
|
+
<h3>Public Class Methods</h3>
|
|
173
|
+
</header>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
<div id="method-c-new" class="method-detail ">
|
|
177
|
+
|
|
178
|
+
<div class="method-heading">
|
|
179
|
+
<span class="method-name">new</span><span
|
|
180
|
+
class="method-args">(options={})</span>
|
|
181
|
+
|
|
182
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
183
|
+
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<div class="method-description">
|
|
188
|
+
|
|
189
|
+
<p>Creates a new extractor</p>
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
<div class="method-source-code" id="new-source">
|
|
195
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/extractor.rb, line 20</span>
|
|
196
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
|
|
197
|
+
<span class="ruby-ivar">@in_file</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
|
|
198
|
+
<span class="ruby-ivar">@out_file</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
|
|
199
|
+
<span class="ruby-ivar">@row_filter</span> = <span class="ruby-constant">RowFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:rows</span>])
|
|
200
|
+
<span class="ruby-ivar">@col_filter</span> = <span class="ruby-constant">ColumnFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:cols</span>])
|
|
201
|
+
<span class="ruby-keyword">end</span></pre>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
</section>
|
|
213
|
+
|
|
214
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
|
215
|
+
<header>
|
|
216
|
+
<h3>Public Instance Methods</h3>
|
|
217
|
+
</header>
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
<div id="method-i-execute" class="method-detail ">
|
|
221
|
+
|
|
222
|
+
<div class="method-heading">
|
|
223
|
+
<span class="method-name">execute</span><span
|
|
224
|
+
class="method-args">()</span>
|
|
225
|
+
|
|
226
|
+
<span class="method-click-advice">click to toggle source</span>
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<div class="method-description">
|
|
232
|
+
|
|
233
|
+
<p>Executes the extractor</p>
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
<div class="method-source-code" id="execute-source">
|
|
239
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/extractor.rb, line 28</span>
|
|
240
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
|
|
241
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">out_file</span>, <span class="ruby-string">'w'</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span>
|
|
242
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">in_file</span>, <span class="ruby-string">'r'</span>).<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span>, <span class="ruby-identifier">index</span><span class="ruby-operator">|</span>
|
|
243
|
+
<span class="ruby-identifier">extraction</span> = <span class="ruby-identifier">col_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>, <span class="ruby-identifier">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
|
|
244
|
+
<span class="ruby-identifier">o</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">extraction</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">extraction</span>.<span class="ruby-identifier">nil?</span>
|
|
245
|
+
<span class="ruby-keyword">end</span>
|
|
246
|
+
<span class="ruby-keyword">end</span>
|
|
247
|
+
<span class="ruby-keyword">end</span></pre>
|
|
248
|
+
</div>
|
|
249
|
+
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
</section>
|
|
259
|
+
|
|
260
|
+
</section>
|
|
261
|
+
</main>
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
<footer id="validator-badges" role="contentinfo">
|
|
265
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
|
266
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
|
267
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
|
268
|
+
</footer>
|
|
269
|
+
|