sycsvpro 0.1.2 → 0.1.3

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.
Files changed (78) hide show
  1. data/Gemfile.lock +3 -1
  2. data/README.md +21 -8
  3. data/README.rdoc +3 -2
  4. data/bin/sycsvpro +17 -6
  5. data/lib/sycsvpro/aggregator.rb +16 -5
  6. data/lib/sycsvpro/calculator.rb +19 -5
  7. data/lib/sycsvpro/counter.rb +17 -7
  8. data/lib/sycsvpro/dsl.rb +43 -0
  9. data/lib/sycsvpro/filter.rb +0 -7
  10. data/lib/sycsvpro/sorter.rb +28 -8
  11. data/lib/sycsvpro/version.rb +1 -1
  12. data/spec/sycsvpro/sorter_spec.rb +50 -0
  13. data/sycsvpro.gemspec +1 -0
  14. metadata +18 -66
  15. data/html/Dsl.html +0 -277
  16. data/html/Object.html +0 -187
  17. data/html/README_rdoc.html +0 -187
  18. data/html/Sycsvpro/Aggregator.html +0 -482
  19. data/html/Sycsvpro/Allocator.html +0 -293
  20. data/html/Sycsvpro/Analyzer.html +0 -239
  21. data/html/Sycsvpro/Calculator.html +0 -407
  22. data/html/Sycsvpro/Collector.html +0 -281
  23. data/html/Sycsvpro/ColumnFilter.html +0 -170
  24. data/html/Sycsvpro/ColumnTypeFilter.html +0 -191
  25. data/html/Sycsvpro/Counter.html +0 -492
  26. data/html/Sycsvpro/Extractor.html +0 -269
  27. data/html/Sycsvpro/Filter.html +0 -411
  28. data/html/Sycsvpro/Header.html +0 -239
  29. data/html/Sycsvpro/Inserter.html +0 -275
  30. data/html/Sycsvpro/Mapper.html +0 -288
  31. data/html/Sycsvpro/Profiler.html +0 -234
  32. data/html/Sycsvpro/RowFilter.html +0 -175
  33. data/html/Sycsvpro/ScriptCreator.html +0 -235
  34. data/html/Sycsvpro/ScriptList.html +0 -281
  35. data/html/Sycsvpro/Sorter.html +0 -346
  36. data/html/Sycsvpro.html +0 -155
  37. data/html/created.rid +0 -24
  38. data/html/fonts/Lato-Light.ttf +0 -0
  39. data/html/fonts/Lato-LightItalic.ttf +0 -0
  40. data/html/fonts/Lato-Regular.ttf +0 -0
  41. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  42. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  43. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  44. data/html/fonts.css +0 -167
  45. data/html/images/add.png +0 -0
  46. data/html/images/arrow_up.png +0 -0
  47. data/html/images/brick.png +0 -0
  48. data/html/images/brick_link.png +0 -0
  49. data/html/images/bug.png +0 -0
  50. data/html/images/bullet_black.png +0 -0
  51. data/html/images/bullet_toggle_minus.png +0 -0
  52. data/html/images/bullet_toggle_plus.png +0 -0
  53. data/html/images/date.png +0 -0
  54. data/html/images/delete.png +0 -0
  55. data/html/images/find.png +0 -0
  56. data/html/images/loadingAnimation.gif +0 -0
  57. data/html/images/macFFBgHack.png +0 -0
  58. data/html/images/package.png +0 -0
  59. data/html/images/page_green.png +0 -0
  60. data/html/images/page_white_text.png +0 -0
  61. data/html/images/page_white_width.png +0 -0
  62. data/html/images/plugin.png +0 -0
  63. data/html/images/ruby.png +0 -0
  64. data/html/images/tag_blue.png +0 -0
  65. data/html/images/tag_green.png +0 -0
  66. data/html/images/transparent.png +0 -0
  67. data/html/images/wrench.png +0 -0
  68. data/html/images/wrench_orange.png +0 -0
  69. data/html/images/zoom.png +0 -0
  70. data/html/index.html +0 -225
  71. data/html/js/darkfish.js +0 -140
  72. data/html/js/jquery.js +0 -18
  73. data/html/js/navigation.js +0 -142
  74. data/html/js/search.js +0 -109
  75. data/html/js/search_index.js +0 -1
  76. data/html/js/searcher.js +0 -228
  77. data/html/rdoc.css +0 -580
  78. data/html/table_of_contents.html +0 -347
@@ -1,281 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Sycsvpro::ScriptList - 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::ScriptList">
87
- <h1 id="class-Sycsvpro::ScriptList" class="class">
88
- class Sycsvpro::ScriptList
89
- </h1>
90
-
91
- <section class="description">
92
-
93
- <p>Lists the contents of the script directory. Optionally listing a specific
94
- script file and also optionally the methods and associated description of
95
- the methods</p>
96
-
97
- </section>
98
-
99
-
100
-
101
-
102
- <section id="5Buntitled-5D" class="documentation-section">
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
- <section class="attribute-method-details" class="method-section">
111
- <header>
112
- <h3>Attributes</h3>
113
- </header>
114
-
115
-
116
- <div id="attribute-i-list" class="method-detail">
117
- <div class="method-heading attribute-method-heading">
118
- <span class="method-name">list</span><span
119
- class="attribute-access-type">[R]</span>
120
- </div>
121
-
122
- <div class="method-description">
123
-
124
- <p>Hash holding the list of scripts</p>
125
-
126
- </div>
127
- </div>
128
-
129
- <div id="attribute-i-script_dir" class="method-detail">
130
- <div class="method-heading attribute-method-heading">
131
- <span class="method-name">script_dir</span><span
132
- class="attribute-access-type">[R]</span>
133
- </div>
134
-
135
- <div class="method-description">
136
-
137
- <p>Directory that holds the scripts</p>
138
-
139
- </div>
140
- </div>
141
-
142
- <div id="attribute-i-script_file" class="method-detail">
143
- <div class="method-heading attribute-method-heading">
144
- <span class="method-name">script_file</span><span
145
- class="attribute-access-type">[R]</span>
146
- </div>
147
-
148
- <div class="method-description">
149
-
150
- <p>Script file of interest</p>
151
-
152
- </div>
153
- </div>
154
-
155
- <div id="attribute-i-show_methods" class="method-detail">
156
- <div class="method-heading attribute-method-heading">
157
- <span class="method-name">show_methods</span><span
158
- class="attribute-access-type">[R]</span>
159
- </div>
160
-
161
- <div class="method-description">
162
-
163
- <p>Switch indicating whether to show methods</p>
164
-
165
- </div>
166
- </div>
167
-
168
- </section>
169
-
170
-
171
-
172
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
173
- <header>
174
- <h3>Public Class Methods</h3>
175
- </header>
176
-
177
-
178
- <div id="method-c-new" class="method-detail ">
179
-
180
- <div class="method-heading">
181
- <span class="method-name">new</span><span
182
- class="method-args">(options={})</span>
183
-
184
- <span class="method-click-advice">click to toggle source</span>
185
-
186
- </div>
187
-
188
-
189
- <div class="method-description">
190
-
191
- <p>Creates a new <a href="ScriptList.html">ScriptList</a>. Takes params <a
192
- href="ScriptList.html#attribute-i-script_dir">#script_dir</a>, <a
193
- href="ScriptList.html#attribute-i-script_file">#script_file</a> and <a
194
- href="ScriptList.html#attribute-i-show_methods">#show_methods</a></p>
195
-
196
-
197
-
198
-
199
- <div class="method-source-code" id="new-source">
200
- <pre><span class="ruby-comment"># File lib/sycsvpro/script_list.rb, line 18</span>
201
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
202
- <span class="ruby-ivar">@script_dir</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:dir</span>]
203
- <span class="ruby-ivar">@script_type</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:type</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;script&#39;</span>
204
- <span class="ruby-ivar">@script_type</span>.<span class="ruby-identifier">downcase!</span>
205
- <span class="ruby-ivar">@script_file</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:script</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;*.rb&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@script_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;script&#39;</span>
206
- <span class="ruby-ivar">@script_file</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:script</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;*.ins&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@script_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;insert&#39;</span>
207
- <span class="ruby-ivar">@show_methods</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:show_methods</span>] <span class="ruby-keyword">if</span> <span class="ruby-ivar">@script_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;script&#39;</span>
208
- <span class="ruby-ivar">@show_methods</span> = <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@script_type</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;insert&#39;</span>
209
- <span class="ruby-ivar">@list</span> = {}
210
- <span class="ruby-keyword">end</span></pre>
211
- </div>
212
-
213
- </div>
214
-
215
-
216
-
217
-
218
- </div>
219
-
220
-
221
- </section>
222
-
223
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
224
- <header>
225
- <h3>Public Instance Methods</h3>
226
- </header>
227
-
228
-
229
- <div id="method-i-execute" class="method-detail ">
230
-
231
- <div class="method-heading">
232
- <span class="method-name">execute</span><span
233
- class="method-args">()</span>
234
-
235
- <span class="method-click-advice">click to toggle source</span>
236
-
237
- </div>
238
-
239
-
240
- <div class="method-description">
241
-
242
- <p>Retrieves the information about scripts and methods from the script
243
- directory</p>
244
-
245
-
246
-
247
-
248
- <div class="method-source-code" id="execute-source">
249
- <pre><span class="ruby-comment"># File lib/sycsvpro/script_list.rb, line 30</span>
250
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
251
- <span class="ruby-identifier">scripts</span> = <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@script_dir</span>, <span class="ruby-ivar">@script_file</span>))
252
- <span class="ruby-identifier">scripts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">script</span><span class="ruby-operator">|</span>
253
- <span class="ruby-identifier">list</span>[<span class="ruby-identifier">script</span>] = []
254
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">show_methods</span>
255
- <span class="ruby-identifier">list</span>[<span class="ruby-identifier">script</span>] = <span class="ruby-identifier">retrieve_methods</span>(<span class="ruby-identifier">script</span>)
256
- <span class="ruby-keyword">end</span>
257
- <span class="ruby-keyword">end</span>
258
- <span class="ruby-identifier">list</span>
259
- <span class="ruby-keyword">end</span></pre>
260
- </div>
261
-
262
- </div>
263
-
264
-
265
-
266
-
267
- </div>
268
-
269
-
270
- </section>
271
-
272
- </section>
273
- </main>
274
-
275
-
276
- <footer id="validator-badges" role="contentinfo">
277
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
278
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
279
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
280
- </footer>
281
-
@@ -1,346 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
-
7
- <title>class Sycsvpro::Sorter - 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
- <div id="includes-section" class="nav-section">
69
- <h3>Included Modules</h3>
70
-
71
- <ul class="link-list">
72
-
73
-
74
- <li><a class="include" href="../Dsl.html">Dsl</a>
75
-
76
-
77
- </ul>
78
- </div>
79
-
80
-
81
- <!-- Method Quickref -->
82
- <div id="method-list-section" class="nav-section">
83
- <h3>Methods</h3>
84
-
85
- <ul class="link-list" role="directory">
86
-
87
- <li ><a href="#method-c-new">::new</a>
88
-
89
- <li ><a href="#method-i-execute">#execute</a>
90
-
91
- </ul>
92
- </div>
93
-
94
- </div>
95
- </nav>
96
-
97
- <main role="main" aria-labelledby="class-Sycsvpro::Sorter">
98
- <h1 id="class-Sycsvpro::Sorter" class="class">
99
- class Sycsvpro::Sorter
100
- </h1>
101
-
102
- <section class="description">
103
-
104
- <p>Sorts an input file based on a column sort filter</p>
105
-
106
- </section>
107
-
108
-
109
-
110
-
111
- <section id="5Buntitled-5D" class="documentation-section">
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
- <section class="attribute-method-details" class="method-section">
120
- <header>
121
- <h3>Attributes</h3>
122
- </header>
123
-
124
-
125
- <div id="attribute-i-col_type_filter" class="method-detail">
126
- <div class="method-heading attribute-method-heading">
127
- <span class="method-name">col_type_filter</span><span
128
- class="attribute-access-type">[R]</span>
129
- </div>
130
-
131
- <div class="method-description">
132
-
133
- <p>column type filter</p>
134
-
135
- </div>
136
- </div>
137
-
138
- <div id="attribute-i-desc" class="method-detail">
139
- <div class="method-heading attribute-method-heading">
140
- <span class="method-name">desc</span><span
141
- class="attribute-access-type">[R]</span>
142
- </div>
143
-
144
- <div class="method-description">
145
-
146
- <p>sort order descending or ascending</p>
147
-
148
- </div>
149
- </div>
150
-
151
- <div id="attribute-i-headerless" class="method-detail">
152
- <div class="method-heading attribute-method-heading">
153
- <span class="method-name">headerless</span><span
154
- class="attribute-access-type">[R]</span>
155
- </div>
156
-
157
- <div class="method-description">
158
-
159
- <p>file doesn&#39;t contain a header</p>
160
-
161
- </div>
162
- </div>
163
-
164
- <div id="attribute-i-infile" class="method-detail">
165
- <div class="method-heading attribute-method-heading">
166
- <span class="method-name">infile</span><span
167
- class="attribute-access-type">[R]</span>
168
- </div>
169
-
170
- <div class="method-description">
171
-
172
- <p>file of the data to sort</p>
173
-
174
- </div>
175
- </div>
176
-
177
- <div id="attribute-i-outfile" class="method-detail">
178
- <div class="method-heading attribute-method-heading">
179
- <span class="method-name">outfile</span><span
180
- class="attribute-access-type">[R]</span>
181
- </div>
182
-
183
- <div class="method-description">
184
-
185
- <p>file to write the sorted data to</p>
186
-
187
- </div>
188
- </div>
189
-
190
- <div id="attribute-i-row_filter" class="method-detail">
191
- <div class="method-heading attribute-method-heading">
192
- <span class="method-name">row_filter</span><span
193
- class="attribute-access-type">[R]</span>
194
- </div>
195
-
196
- <div class="method-description">
197
-
198
- <p>row filter</p>
199
-
200
- </div>
201
- </div>
202
-
203
- <div id="attribute-i-sorted_rows" class="method-detail">
204
- <div class="method-heading attribute-method-heading">
205
- <span class="method-name">sorted_rows</span><span
206
- class="attribute-access-type">[R]</span>
207
- </div>
208
-
209
- <div class="method-description">
210
-
211
- <p>sorted rows</p>
212
-
213
- </div>
214
- </div>
215
-
216
- </section>
217
-
218
-
219
-
220
- <section id="public-class-5Buntitled-5D-method-details" class="method-section">
221
- <header>
222
- <h3>Public Class Methods</h3>
223
- </header>
224
-
225
-
226
- <div id="method-c-new" class="method-detail ">
227
-
228
- <div class="method-heading">
229
- <span class="method-name">new</span><span
230
- class="method-args">(options={})</span>
231
-
232
- <span class="method-click-advice">click to toggle source</span>
233
-
234
- </div>
235
-
236
-
237
- <div class="method-description">
238
-
239
- <p>Creates a <a href="Sorter.html">Sorter</a> and takes as options infile,
240
- outfile, rows, cols including types and a date format for the date columns
241
- to sort (optional).</p>
242
-
243
-
244
-
245
-
246
- <div class="method-source-code" id="new-source">
247
- <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 30</span>
248
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={})
249
- <span class="ruby-ivar">@infile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:infile</span>]
250
- <span class="ruby-ivar">@outfile</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:outfile</span>]
251
- <span class="ruby-ivar">@headerless</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:headerless</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword">false</span>
252
- <span class="ruby-ivar">@desc</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:desc</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword">false</span>
253
- <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>])
254
- <span class="ruby-ivar">@col_type_filter</span> = <span class="ruby-constant">ColumnTypeFilter</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>])
255
- <span class="ruby-ivar">@sorted_rows</span> = []
256
- <span class="ruby-keyword">end</span></pre>
257
- </div>
258
-
259
- </div>
260
-
261
-
262
-
263
-
264
- </div>
265
-
266
-
267
- </section>
268
-
269
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
270
- <header>
271
- <h3>Public Instance Methods</h3>
272
- </header>
273
-
274
-
275
- <div id="method-i-execute" class="method-detail ">
276
-
277
- <div class="method-heading">
278
- <span class="method-name">execute</span><span
279
- class="method-args">()</span>
280
-
281
- <span class="method-click-advice">click to toggle source</span>
282
-
283
- </div>
284
-
285
-
286
- <div class="method-description">
287
-
288
- <p>Sorts the data of the infile</p>
289
-
290
-
291
-
292
-
293
- <div class="method-source-code" id="execute-source">
294
- <pre><span class="ruby-comment"># File lib/sycsvpro/sorter.rb, line 41</span>
295
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>
296
- <span class="ruby-identifier">rows</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">infile</span>)
297
-
298
- <span class="ruby-keyword">unless</span> <span class="ruby-identifier">headerless</span>
299
- <span class="ruby-identifier">header</span> = <span class="ruby-string">&quot;&quot;</span>
300
- <span class="ruby-identifier">header</span> = <span class="ruby-identifier">rows</span>.<span class="ruby-identifier">shift</span> <span class="ruby-keyword">while</span> <span class="ruby-identifier">header</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">empty?</span>
301
- <span class="ruby-keyword">end</span>
302
-
303
- <span class="ruby-identifier">rows</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>
304
- <span class="ruby-identifier">filtered</span> = <span class="ruby-identifier">col_type_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">row</span><span class="ruby-operator">:</span> <span class="ruby-identifier">index</span>))
305
- <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">filtered</span>.<span class="ruby-identifier">nil?</span>
306
- <span class="ruby-identifier">sorted_rows</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">filtered</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">index</span>)
307
- <span class="ruby-keyword">end</span>
308
-
309
- <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">outfile</span>, <span class="ruby-string">&#39;w&#39;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">out</span><span class="ruby-operator">|</span>
310
- <span class="ruby-keyword">unless</span> <span class="ruby-identifier">headerless</span>
311
- <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">header</span>
312
- <span class="ruby-keyword">end</span>
313
-
314
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">desc</span>
315
- <span class="ruby-identifier">sorted_rows</span>.<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">sort</span>.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
316
- <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">unstring</span>(<span class="ruby-identifier">rows</span>[<span class="ruby-identifier">row</span>.<span class="ruby-identifier">last</span>])
317
- <span class="ruby-keyword">end</span>
318
- <span class="ruby-keyword">else</span>
319
- <span class="ruby-identifier">sorted_rows</span>.<span class="ruby-identifier">compact</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">row</span><span class="ruby-operator">|</span>
320
- <span class="ruby-identifier">out</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">unstring</span>(<span class="ruby-identifier">rows</span>[<span class="ruby-identifier">row</span>.<span class="ruby-identifier">last</span>])
321
- <span class="ruby-keyword">end</span>
322
- <span class="ruby-keyword">end</span>
323
- <span class="ruby-keyword">end</span>
324
- <span class="ruby-keyword">end</span></pre>
325
- </div>
326
-
327
- </div>
328
-
329
-
330
-
331
-
332
- </div>
333
-
334
-
335
- </section>
336
-
337
- </section>
338
- </main>
339
-
340
-
341
- <footer id="validator-badges" role="contentinfo">
342
- <p><a href="http://validator.w3.org/check/referer">Validate</a>
343
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
344
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
345
- </footer>
346
-