sycsvpro 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/sycsvpro +30 -0
- data/html/Sycsvpro/Allocator.html +293 -0
- data/html/Sycsvpro.html +2 -0
- data/html/created.rid +4 -3
- data/html/index.html +2 -0
- data/html/js/search_index.js +1 -1
- data/html/table_of_contents.html +39 -26
- data/lib/sycsvpro/allocator.rb +47 -0
- data/lib/sycsvpro/version.rb +1 -1
- data/lib/sycsvpro.rb +1 -0
- data/spec/sycsvpro/allocator_spec.rb +56 -0
- 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 +4 -3
- data/spec/sycsvpro/mapper_spec.rb +3 -2
- data/spec/sycsvpro/profiler_spec.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 738f8fd1604b67445b553bb91b955b47ee3731b6
|
4
|
+
data.tar.gz: e69dc77c8139f8c80dd7f69d92eccc94f5181e03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa434e1a18c780427d5a7ca3afdd955a2202b458b821a281db35782718bfad2bf1d2d624fc1f32f5cde95cc6a0e85f371a3387e9520de59983ed1f5be4567924
|
7
|
+
data.tar.gz: 2c26c5c1b652ef58ac376e369094f2bb40311ea0424ff60ff5489c0767c2de952c0b4b8f50aa68813b3a625df976c605353e5723594d42649f551bff2e3fd6bb
|
data/bin/sycsvpro
CHANGED
@@ -86,11 +86,38 @@ command :collect do |c|
|
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
+
desc 'Allocate specified columns from the file to a key value'
|
90
|
+
command :allocate do |c|
|
91
|
+
c.desc 'Rows to consider'
|
92
|
+
c.arg_name '1,2,10-30|REGEXP'
|
93
|
+
c.flag [:r, :row], :must_match => /\d+(?:,\d+|-\d+|,\/.*\/)*|\/.*\/(?:,\/.*\/|\d+)*/
|
94
|
+
|
95
|
+
c.desc 'Key to allocate columns to'
|
96
|
+
c.arg_name '0'
|
97
|
+
c.flag [:k, :key], :must_match => /\d+/
|
98
|
+
|
99
|
+
c.desc 'Columns to allocate'
|
100
|
+
c.arg_name '1,2,10-30'
|
101
|
+
c.flag [:c, :col], :must_match => /\d+(?:,\d+|-\d+)*/
|
102
|
+
|
103
|
+
c.action do |global_options,options,args|
|
104
|
+
help_now! "You need to provide a file to read data from '-f FILE'" if global_options[:f].nil?
|
105
|
+
help_now! "You need to provide a result file '-o OUT_FILE'" if global_options[:o].nil?
|
106
|
+
|
107
|
+
puts "Allocating ..."
|
108
|
+
allocator = Sycsvpro::Allocator.new(infile: global_options[:f], outfile: global_options[:o],
|
109
|
+
key: options[:k], rows: options[:r], cols: options[:c])
|
110
|
+
allocator.execute
|
111
|
+
puts "allocation done"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
89
115
|
desc 'Executes the code provided in a file'
|
90
116
|
arg_name 'PRO_FILE METHOD'
|
91
117
|
command :execute do |c|
|
92
118
|
c.action do |global_options,options,args|
|
93
119
|
help_now! "You need to provide a script FILE and a METHOD to call" if args.size < 2
|
120
|
+
puts "Executing..."
|
94
121
|
profiler = Sycsvpro::Profiler.new(args[0])
|
95
122
|
profiler.execute(args[1])
|
96
123
|
puts "execute done"
|
@@ -123,6 +150,7 @@ command :count do |c|
|
|
123
150
|
help_now! "You need to provide a file to count data from '-f FILE'" if global_options[:f].nil?
|
124
151
|
help_now! "You need to provide a result file '-o OUT_FILE'" if global_options[:o].nil?
|
125
152
|
|
153
|
+
puts "Counting..."
|
126
154
|
counter = Sycsvpro::Counter.new(infile: global_options[:f], outfile: global_options[:o],
|
127
155
|
key: options[:k], rows: options[:r], cols: options[:c],
|
128
156
|
df: options[:df])
|
@@ -147,6 +175,7 @@ command :map do |c|
|
|
147
175
|
help_now! "You need to provide a result file '-o OUT_FILE'" if global_options[:o].nil?
|
148
176
|
help_now! "You need to provide a mapping file" if args.size == 0
|
149
177
|
|
178
|
+
puts "Mapping..."
|
150
179
|
mapper = Sycsvpro::Mapper.new(infile: global_options[:f], outfile: global_options[:o],
|
151
180
|
mapping: args[0], rows: options[:r], cols: options[:c])
|
152
181
|
mapper.execute
|
@@ -177,6 +206,7 @@ command :calc do |c|
|
|
177
206
|
help_now! "You need to provide a result file '-o OUT_FILE'" if global_options[:o].nil?
|
178
207
|
help_now! "You need to provide the column flag" if options[:c].nil?
|
179
208
|
|
209
|
+
puts "Calculating..."
|
180
210
|
calculator = Sycsvpro::Calculator.new(infile: global_options[:f], outfile: global_options[:o],
|
181
211
|
header: options[:h], rows: options[:r], cols: options[:c])
|
182
212
|
calculator.execute
|
@@ -0,0 +1,293 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Sycsvpro::Allocator - 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::Allocator">
|
87
|
+
<h1 id="class-Sycsvpro::Allocator" class="class">
|
88
|
+
class Sycsvpro::Allocator
|
89
|
+
</h1>
|
90
|
+
|
91
|
+
<section class="description">
|
92
|
+
|
93
|
+
<p>Allocates columns to a key column</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><a href="Filter.html">Filter</a> for columns to allocate</p>
|
123
|
+
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<div id="attribute-i-infile" class="method-detail">
|
128
|
+
<div class="method-heading attribute-method-heading">
|
129
|
+
<span class="method-name">infile</span><span
|
130
|
+
class="attribute-access-type">[R]</span>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="method-description">
|
134
|
+
|
135
|
+
<p>File from that values are read</p>
|
136
|
+
|
137
|
+
</div>
|
138
|
+
</div>
|
139
|
+
|
140
|
+
<div id="attribute-i-key_filter" class="method-detail">
|
141
|
+
<div class="method-heading attribute-method-heading">
|
142
|
+
<span class="method-name">key_filter</span><span
|
143
|
+
class="attribute-access-type">[R]</span>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
<div class="method-description">
|
147
|
+
|
148
|
+
<p><a href="Filter.html">Filter</a> for the key column that the values are
|
149
|
+
allocated at</p>
|
150
|
+
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
|
154
|
+
<div id="attribute-i-outfile" class="method-detail">
|
155
|
+
<div class="method-heading attribute-method-heading">
|
156
|
+
<span class="method-name">outfile</span><span
|
157
|
+
class="attribute-access-type">[R]</span>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
|
162
|
+
<p>File to that result of allocation is written</p>
|
163
|
+
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
<div id="attribute-i-row_filter" class="method-detail">
|
168
|
+
<div class="method-heading attribute-method-heading">
|
169
|
+
<span class="method-name">row_filter</span><span
|
170
|
+
class="attribute-access-type">[R]</span>
|
171
|
+
</div>
|
172
|
+
|
173
|
+
<div class="method-description">
|
174
|
+
|
175
|
+
<p><a href="Filter.html">Filter</a> for rows to consider</p>
|
176
|
+
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
</section>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
185
|
+
<header>
|
186
|
+
<h3>Public Class Methods</h3>
|
187
|
+
</header>
|
188
|
+
|
189
|
+
|
190
|
+
<div id="method-c-new" class="method-detail ">
|
191
|
+
|
192
|
+
<div class="method-heading">
|
193
|
+
<span class="method-name">new</span><span
|
194
|
+
class="method-args">(options={})</span>
|
195
|
+
|
196
|
+
<span class="method-click-advice">click to toggle source</span>
|
197
|
+
|
198
|
+
</div>
|
199
|
+
|
200
|
+
|
201
|
+
<div class="method-description">
|
202
|
+
|
203
|
+
<p>Creates a new allocator. Options are infile, outfile, key, rows and columns
|
204
|
+
to allocate to key</p>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<div class="method-source-code" id="new-source">
|
210
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/allocator.rb, line 19</span>
|
211
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
|
212
|
+
<span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
|
213
|
+
<span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
|
214
|
+
<span class="ruby-ivar">@key_filter</span> = <span class="ruby-constant">ColumnFilter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:key</span>])
|
215
|
+
<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>])
|
216
|
+
<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>])
|
217
|
+
<span class="ruby-keyword">end</span></pre>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
</div>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
</div>
|
226
|
+
|
227
|
+
|
228
|
+
</section>
|
229
|
+
|
230
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
231
|
+
<header>
|
232
|
+
<h3>Public Instance Methods</h3>
|
233
|
+
</header>
|
234
|
+
|
235
|
+
|
236
|
+
<div id="method-i-execute" class="method-detail ">
|
237
|
+
|
238
|
+
<div class="method-heading">
|
239
|
+
<span class="method-name">execute</span><span
|
240
|
+
class="method-args">()</span>
|
241
|
+
|
242
|
+
<span class="method-click-advice">click to toggle source</span>
|
243
|
+
|
244
|
+
</div>
|
245
|
+
|
246
|
+
|
247
|
+
<div class="method-description">
|
248
|
+
|
249
|
+
<p>Executes the allocator and assigns column values to the key</p>
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<div class="method-source-code" id="execute-source">
|
255
|
+
<pre><span class="ruby-comment"># File lib/sycsvpro/allocator.rb, line 28</span>
|
256
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
|
257
|
+
<span class="ruby-identifier">allocation</span> = {}
|
258
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</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>
|
259
|
+
<span class="ruby-identifier">row</span> = <span class="ruby-identifier">row_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>)
|
260
|
+
<span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">row</span>.<span class="ruby-identifier">nil?</span>
|
261
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">key_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row</span>)
|
262
|
+
<span class="ruby-identifier">allocation</span>[<span class="ruby-identifier">key</span>] = [] <span class="ruby-keyword">if</span> <span class="ruby-identifier">allocation</span>[<span class="ruby-identifier">key</span>].<span class="ruby-identifier">nil?</span>
|
263
|
+
<span class="ruby-identifier">allocation</span>[<span class="ruby-identifier">key</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">col_filter</span>.<span class="ruby-identifier">process</span>(<span class="ruby-identifier">row</span>).<span class="ruby-identifier">split</span>(<span class="ruby-string">';'</span>)
|
264
|
+
<span class="ruby-keyword">end</span>
|
265
|
+
|
266
|
+
<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>
|
267
|
+
<span class="ruby-identifier">allocation</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">values</span><span class="ruby-operator">|</span>
|
268
|
+
<span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{key};#{values.flatten.uniq.sort.join(';')}"</span>
|
269
|
+
<span class="ruby-keyword">end</span>
|
270
|
+
<span class="ruby-keyword">end</span>
|
271
|
+
<span class="ruby-keyword">end</span></pre>
|
272
|
+
</div>
|
273
|
+
|
274
|
+
</div>
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
</div>
|
280
|
+
|
281
|
+
|
282
|
+
</section>
|
283
|
+
|
284
|
+
</section>
|
285
|
+
</main>
|
286
|
+
|
287
|
+
|
288
|
+
<footer id="validator-badges" role="contentinfo">
|
289
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
290
|
+
<p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
|
291
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
292
|
+
</footer>
|
293
|
+
|
data/html/Sycsvpro.html
CHANGED
data/html/created.rid
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
Wed, 19 Feb 2014 21:12:37 +0100
|
2
2
|
README.rdoc Sun, 16 Feb 2014 22:01:46 +0100
|
3
|
-
lib/sycsvpro.rb
|
3
|
+
lib/sycsvpro.rb Wed, 19 Feb 2014 18:42:14 +0100
|
4
|
+
lib/sycsvpro/allocator.rb Wed, 19 Feb 2014 20:34:28 +0100
|
4
5
|
lib/sycsvpro/analyzer.rb Tue, 18 Feb 2014 19:57:28 +0100
|
5
6
|
lib/sycsvpro/calculator.rb Tue, 18 Feb 2014 19:53:34 +0100
|
6
7
|
lib/sycsvpro/collector.rb Sun, 16 Feb 2014 20:59:27 +0100
|
@@ -14,4 +15,4 @@ lib/sycsvpro/mapper.rb Tue, 18 Feb 2014 19:45:47 +0100
|
|
14
15
|
lib/sycsvpro/profiler.rb Sun, 16 Feb 2014 21:31:39 +0100
|
15
16
|
lib/sycsvpro/row_filter.rb Tue, 18 Feb 2014 19:45:25 +0100
|
16
17
|
lib/sycsvpro/version.rb Tue, 18 Feb 2014 20:01:04 +0100
|
17
|
-
bin/sycsvpro
|
18
|
+
bin/sycsvpro Wed, 19 Feb 2014 20:59:05 +0100
|
data/html/index.html
CHANGED
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()","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()","unstring()","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()","dsl#unstring()","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"],["unstring","Dsl","Dsl.html#method-i-unstring","(line)","<p>Remove leading and trailing “ and spaces as well as reducing more than 2\nspaces between words from …\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","allocator","analyzer","calculator","collector","columnfilter","counter","extractor","filter","header","mapper","profiler","rowfilter","execute()","execute()","execute()","execute()","execute()","execute()","execute()","has_filter?()","method_missing()","method_missing()","new()","new()","new()","new()","new()","new()","new()","new()","new()","new()","pivot_each_column()","process()","process()","process()","process()","process_file()","result()","rows()","unstring()","write_result()","write_to()","readme"],"longSearchIndex":["dsl","object","sycsvpro","sycsvpro::allocator","sycsvpro::analyzer","sycsvpro::calculator","sycsvpro::collector","sycsvpro::columnfilter","sycsvpro::counter","sycsvpro::extractor","sycsvpro::filter","sycsvpro::header","sycsvpro::mapper","sycsvpro::profiler","sycsvpro::rowfilter","sycsvpro::allocator#execute()","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::allocator::new()","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()","dsl#unstring()","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::Allocator","","Sycsvpro/Allocator.html","","<p>Allocates columns to a key column\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::Allocator","Sycsvpro/Allocator.html#method-i-execute","()","<p>Executes the allocator and assigns column values to the key\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::Allocator","Sycsvpro/Allocator.html#method-c-new","(options={})","<p>Creates a new allocator. Options are infile, outfile, key, rows and columns\nto allocate to key\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"],["unstring","Dsl","Dsl.html#method-i-unstring","(line)","<p>Remove leading and trailing “ and spaces as well as reducing more than 2\nspaces between words from …\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
@@ -52,6 +52,9 @@
|
|
52
52
|
<li class="module">
|
53
53
|
<a href="Sycsvpro.html">Sycsvpro</a>
|
54
54
|
</li>
|
55
|
+
<li class="class">
|
56
|
+
<a href="Sycsvpro/Allocator.html">Sycsvpro::Allocator</a>
|
57
|
+
</li>
|
55
58
|
<li class="class">
|
56
59
|
<a href="Sycsvpro/Analyzer.html">Sycsvpro::Analyzer</a>
|
57
60
|
</li>
|
@@ -90,15 +93,25 @@
|
|
90
93
|
<h2 id="methods">Methods</h2>
|
91
94
|
<ul>
|
92
95
|
|
96
|
+
<li class="method">
|
97
|
+
<a href="Sycsvpro/Allocator.html#method-c-new">::new</a>
|
98
|
+
—
|
99
|
+
<span class="container">Sycsvpro::Allocator</span>
|
100
|
+
|
101
|
+
<li class="method">
|
102
|
+
<a href="Sycsvpro/Extractor.html#method-c-new">::new</a>
|
103
|
+
—
|
104
|
+
<span class="container">Sycsvpro::Extractor</span>
|
105
|
+
|
93
106
|
<li class="method">
|
94
107
|
<a href="Sycsvpro/Analyzer.html#method-c-new">::new</a>
|
95
108
|
—
|
96
109
|
<span class="container">Sycsvpro::Analyzer</span>
|
97
110
|
|
98
111
|
<li class="method">
|
99
|
-
<a href="Sycsvpro/
|
112
|
+
<a href="Sycsvpro/Header.html#method-c-new">::new</a>
|
100
113
|
—
|
101
|
-
<span class="container">Sycsvpro::
|
114
|
+
<span class="container">Sycsvpro::Header</span>
|
102
115
|
|
103
116
|
<li class="method">
|
104
117
|
<a href="Sycsvpro/Calculator.html#method-c-new">::new</a>
|
@@ -106,14 +119,14 @@
|
|
106
119
|
<span class="container">Sycsvpro::Calculator</span>
|
107
120
|
|
108
121
|
<li class="method">
|
109
|
-
<a href="Sycsvpro/
|
122
|
+
<a href="Sycsvpro/Profiler.html#method-c-new">::new</a>
|
110
123
|
—
|
111
|
-
<span class="container">Sycsvpro::
|
124
|
+
<span class="container">Sycsvpro::Profiler</span>
|
112
125
|
|
113
126
|
<li class="method">
|
114
|
-
<a href="Sycsvpro/
|
127
|
+
<a href="Sycsvpro/Mapper.html#method-c-new">::new</a>
|
115
128
|
—
|
116
|
-
<span class="container">Sycsvpro::
|
129
|
+
<span class="container">Sycsvpro::Mapper</span>
|
117
130
|
|
118
131
|
<li class="method">
|
119
132
|
<a href="Sycsvpro/Collector.html#method-c-new">::new</a>
|
@@ -126,29 +139,34 @@
|
|
126
139
|
<span class="container">Sycsvpro::Counter</span>
|
127
140
|
|
128
141
|
<li class="method">
|
129
|
-
<a href="Sycsvpro/
|
142
|
+
<a href="Sycsvpro/Filter.html#method-c-new">::new</a>
|
130
143
|
—
|
131
|
-
<span class="container">Sycsvpro::
|
144
|
+
<span class="container">Sycsvpro::Filter</span>
|
132
145
|
|
133
146
|
<li class="method">
|
134
|
-
<a href="Sycsvpro/
|
147
|
+
<a href="Sycsvpro/Mapper.html#method-i-execute">#execute</a>
|
135
148
|
—
|
136
|
-
<span class="container">Sycsvpro::
|
149
|
+
<span class="container">Sycsvpro::Mapper</span>
|
137
150
|
|
138
151
|
<li class="method">
|
139
152
|
<a href="Sycsvpro/Counter.html#method-i-execute">#execute</a>
|
140
153
|
—
|
141
154
|
<span class="container">Sycsvpro::Counter</span>
|
142
155
|
|
156
|
+
<li class="method">
|
157
|
+
<a href="Sycsvpro/Calculator.html#method-i-execute">#execute</a>
|
158
|
+
—
|
159
|
+
<span class="container">Sycsvpro::Calculator</span>
|
160
|
+
|
143
161
|
<li class="method">
|
144
162
|
<a href="Sycsvpro/Profiler.html#method-i-execute">#execute</a>
|
145
163
|
—
|
146
164
|
<span class="container">Sycsvpro::Profiler</span>
|
147
165
|
|
148
166
|
<li class="method">
|
149
|
-
<a href="Sycsvpro/
|
167
|
+
<a href="Sycsvpro/Allocator.html#method-i-execute">#execute</a>
|
150
168
|
—
|
151
|
-
<span class="container">Sycsvpro::
|
169
|
+
<span class="container">Sycsvpro::Allocator</span>
|
152
170
|
|
153
171
|
<li class="method">
|
154
172
|
<a href="Sycsvpro/Collector.html#method-i-execute">#execute</a>
|
@@ -161,12 +179,12 @@
|
|
161
179
|
<span class="container">Sycsvpro::Extractor</span>
|
162
180
|
|
163
181
|
<li class="method">
|
164
|
-
<a href="Sycsvpro/
|
182
|
+
<a href="Sycsvpro/Filter.html#method-i-has_filter-3F">#has_filter?</a>
|
165
183
|
—
|
166
|
-
<span class="container">Sycsvpro::
|
184
|
+
<span class="container">Sycsvpro::Filter</span>
|
167
185
|
|
168
186
|
<li class="method">
|
169
|
-
<a href="Sycsvpro/Filter.html#method-i-
|
187
|
+
<a href="Sycsvpro/Filter.html#method-i-method_missing">#method_missing</a>
|
170
188
|
—
|
171
189
|
<span class="container">Sycsvpro::Filter</span>
|
172
190
|
|
@@ -176,12 +194,12 @@
|
|
176
194
|
<span class="container">Sycsvpro::Calculator</span>
|
177
195
|
|
178
196
|
<li class="method">
|
179
|
-
<a href="Sycsvpro/Filter.html#method-i-
|
197
|
+
<a href="Sycsvpro/Filter.html#method-i-pivot_each_column">#pivot_each_column</a>
|
180
198
|
—
|
181
199
|
<span class="container">Sycsvpro::Filter</span>
|
182
200
|
|
183
201
|
<li class="method">
|
184
|
-
<a href="Sycsvpro/Filter.html#method-i-
|
202
|
+
<a href="Sycsvpro/Filter.html#method-i-process">#process</a>
|
185
203
|
—
|
186
204
|
<span class="container">Sycsvpro::Filter</span>
|
187
205
|
|
@@ -191,19 +209,14 @@
|
|
191
209
|
<span class="container">Sycsvpro::Header</span>
|
192
210
|
|
193
211
|
<li class="method">
|
194
|
-
<a href="Sycsvpro/
|
195
|
-
—
|
196
|
-
<span class="container">Sycsvpro::ColumnFilter</span>
|
197
|
-
|
198
|
-
<li class="method">
|
199
|
-
<a href="Sycsvpro/Filter.html#method-i-process">#process</a>
|
212
|
+
<a href="Sycsvpro/RowFilter.html#method-i-process">#process</a>
|
200
213
|
—
|
201
|
-
<span class="container">Sycsvpro::
|
214
|
+
<span class="container">Sycsvpro::RowFilter</span>
|
202
215
|
|
203
216
|
<li class="method">
|
204
|
-
<a href="Sycsvpro/
|
217
|
+
<a href="Sycsvpro/ColumnFilter.html#method-i-process">#process</a>
|
205
218
|
—
|
206
|
-
<span class="container">Sycsvpro::
|
219
|
+
<span class="container">Sycsvpro::ColumnFilter</span>
|
207
220
|
|
208
221
|
<li class="method">
|
209
222
|
<a href="Sycsvpro/Counter.html#method-i-process_file">#process_file</a>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Operating csv files
|
2
|
+
module Sycsvpro
|
3
|
+
|
4
|
+
# Allocates columns to a key column
|
5
|
+
class Allocator
|
6
|
+
|
7
|
+
# File from that values are read
|
8
|
+
attr_reader :infile
|
9
|
+
# File to that result of allocation is written
|
10
|
+
attr_reader :outfile
|
11
|
+
# Filter for rows to consider
|
12
|
+
attr_reader :row_filter
|
13
|
+
# Filter for columns to allocate
|
14
|
+
attr_reader :col_filter
|
15
|
+
# Filter for the key column that the values are allocated at
|
16
|
+
attr_reader :key_filter
|
17
|
+
|
18
|
+
# Creates a new allocator. Options are infile, outfile, key, rows and columns to allocate to key
|
19
|
+
def initialize(options={})
|
20
|
+
@infile = options[:infile]
|
21
|
+
@outfile = options[:outfile]
|
22
|
+
@key_filter = ColumnFilter.new(options[:key])
|
23
|
+
@row_filter = RowFilter.new(options[:rows])
|
24
|
+
@col_filter = ColumnFilter.new(options[:cols])
|
25
|
+
end
|
26
|
+
|
27
|
+
# Executes the allocator and assigns column values to the key
|
28
|
+
def execute
|
29
|
+
allocation = {}
|
30
|
+
File.open(infile).each_with_index do |line, index|
|
31
|
+
row = row_filter.process(line, row: index)
|
32
|
+
next if row.nil?
|
33
|
+
key = key_filter.process(row)
|
34
|
+
allocation[key] = [] if allocation[key].nil?
|
35
|
+
allocation[key] << col_filter.process(row).split(';')
|
36
|
+
end
|
37
|
+
|
38
|
+
File.open(outfile, 'w') do |out|
|
39
|
+
allocation.each do |key, values|
|
40
|
+
out.puts "#{key};#{values.flatten.uniq.sort.join(';')}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
data/lib/sycsvpro/version.rb
CHANGED
data/lib/sycsvpro.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'sycsvpro/allocator'
|
2
|
+
|
3
|
+
module Sycsvpro
|
4
|
+
|
5
|
+
describe Allocator do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@in_file = File.join(File.dirname(__FILE__), "files/in.csv")
|
9
|
+
@out_file = File.join(File.dirname(__FILE__), "files/out.csv")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allocate one value to a key" do
|
13
|
+
key = "1"
|
14
|
+
rows = "1-10"
|
15
|
+
cols = "0"
|
16
|
+
allocator = Allocator.new(infile: @in_file, outfile: @out_file,
|
17
|
+
key: key, rows: rows, cols: cols)
|
18
|
+
|
19
|
+
allocator.execute
|
20
|
+
|
21
|
+
result = [ "1234;Fink;fink",
|
22
|
+
"3322;Haas",
|
23
|
+
"4323;Gent",
|
24
|
+
"3232;Rank",
|
25
|
+
"4432;Klig" ]
|
26
|
+
|
27
|
+
File.open(@out_file).each_with_index do |line, index|
|
28
|
+
line.chomp.should eq result[index]
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should allocate multiple values to a key" do
|
34
|
+
key = "0"
|
35
|
+
rows = "1-10"
|
36
|
+
cols = "4-5"
|
37
|
+
allocator = Allocator.new(infile: @in_file, outfile: @out_file,
|
38
|
+
key: key, rows: rows, cols: cols)
|
39
|
+
|
40
|
+
allocator.execute
|
41
|
+
|
42
|
+
result = [ "Fink;con123;con333;dri222;dri321",
|
43
|
+
"Haas;con332;dri111",
|
44
|
+
"Gent;con123;dri111",
|
45
|
+
"Rank;con332;dri321",
|
46
|
+
"Klig;con332;dri222",
|
47
|
+
"fink;con332;dri321" ]
|
48
|
+
|
49
|
+
File.open(@out_file).each_with_index do |line, index|
|
50
|
+
line.chomp.should eq result[index]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -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 7
|
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', 'Klig', 'Rank',
|
17
|
+
result = ['[customer]', 'Fink', 'Gent', 'Haas', 'Klig', 'Rank', 'fink',
|
18
18
|
'[products]', 'con123', 'con332', 'con333',
|
19
19
|
'dri111', 'dri222', 'dri321']
|
20
20
|
File.open(@out_file).each_with_index do |line, index|
|
@@ -14,7 +14,7 @@ module Sycsvpro
|
|
14
14
|
|
15
15
|
extractor.execute
|
16
16
|
|
17
|
-
result = ["3322;h1", "4323;g1", "
|
17
|
+
result = ["3322;h1", "4323;g1", "1234;f2"]
|
18
18
|
|
19
19
|
File.open(@out_file).each_with_index do |line, index|
|
20
20
|
line.chomp.should eq result[index]
|
@@ -27,8 +27,9 @@ module Sycsvpro
|
|
27
27
|
|
28
28
|
extractor.execute
|
29
29
|
|
30
|
-
result = [ "Fink;
|
31
|
-
"Rank;3232;1.5.2013;r1;con332;dri321"
|
30
|
+
result = [ "Fink;1234;30.12.2016;f2;con333;dri321",
|
31
|
+
"Rank;3232;1.5.2013;r1;con332;dri321",
|
32
|
+
"fink;1234;;f3;con332;dri321" ]
|
32
33
|
|
33
34
|
File.open(@out_file).each_with_index do |line, index|
|
34
35
|
line.chomp.should eq result[index]
|
@@ -19,9 +19,10 @@ module Sycsvpro
|
|
19
19
|
"Fink;1234;20.12.2015;f1;control123;drive222",
|
20
20
|
"Haas;3322;1.10.2011;h1;control332;drive111",
|
21
21
|
"Gent;4323;1.3.2014;g1;control123;drive111",
|
22
|
-
"Fink;
|
22
|
+
"Fink;1234;30.12.2016;f2;control333;drive321",
|
23
23
|
"Rank;3232;1.5.2013;r1;control332;drive321",
|
24
|
-
"Klig;4432;;k1;control332;drive222"
|
24
|
+
"Klig;4432;;k1;control332;drive222",
|
25
|
+
"fink;1234;;f3;control332;drive321" ]
|
25
26
|
|
26
27
|
File.open(@out_file).each_with_index do |line, index|
|
27
28
|
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.4
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- html/Object.html
|
106
106
|
- html/README_rdoc.html
|
107
107
|
- html/Sycsvpro.html
|
108
|
+
- html/Sycsvpro/Allocator.html
|
108
109
|
- html/Sycsvpro/Analyzer.html
|
109
110
|
- html/Sycsvpro/Calculator.html
|
110
111
|
- html/Sycsvpro/Collector.html
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- html/rdoc.css
|
160
161
|
- html/table_of_contents.html
|
161
162
|
- lib/sycsvpro.rb
|
163
|
+
- lib/sycsvpro/allocator.rb
|
162
164
|
- lib/sycsvpro/analyzer.rb
|
163
165
|
- lib/sycsvpro/calculator.rb
|
164
166
|
- lib/sycsvpro/collector.rb
|
@@ -172,6 +174,7 @@ files:
|
|
172
174
|
- lib/sycsvpro/profiler.rb
|
173
175
|
- lib/sycsvpro/row_filter.rb
|
174
176
|
- lib/sycsvpro/version.rb
|
177
|
+
- spec/sycsvpro/allocator_spec.rb
|
175
178
|
- spec/sycsvpro/analyze_spec.rb
|
176
179
|
- spec/sycsvpro/calculator_spec.rb
|
177
180
|
- spec/sycsvpro/collector_spec.rb
|