vizi_translator 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/README.rdoc +56 -54
  2. data/README.rdoc.old +56 -0
  3. data/doc/classes/Vizi/Translator.html +200 -0
  4. data/doc/classes/Vizi/Translator.src/M000002.html +18 -0
  5. data/doc/classes/Vizi/Translator.src/M000003.html +18 -0
  6. data/doc/classes/Vizi/Translator.src/M000004.html +40 -0
  7. data/doc/classes/Vizi/UnSupportedLanguage.html +150 -0
  8. data/doc/classes/Vizi/UnSupportedLanguage.src/M000001.html +18 -0
  9. data/doc/classes/Vizi.html +122 -0
  10. data/doc/created.rid +1 -4
  11. data/doc/files/lib/vizi/vizi_translator_rb.html +126 -0
  12. data/doc/files/lib/vizi_translator_rb.html +114 -0
  13. data/doc/files/testit_rb.html +127 -0
  14. data/doc/fr_class_index.html +29 -0
  15. data/doc/fr_file_index.html +29 -0
  16. data/doc/fr_method_index.html +30 -0
  17. data/doc/index.html +24 -68
  18. data/doc/rdoc-style.css +208 -0
  19. data/testit.rb +2 -2
  20. data/vizi_translator-0.2.0.gem +0 -0
  21. data/vizi_translator.gemspec +1 -1
  22. metadata +20 -60
  23. data/doc/Object.html +0 -200
  24. data/doc/ParserTest.html +0 -268
  25. data/doc/README_rdoc.html +0 -128
  26. data/doc/Rakefile.html +0 -148
  27. data/doc/Visit.html +0 -487
  28. data/doc/VisitList.html +0 -385
  29. data/doc/Vizi/LogFormat.html +0 -377
  30. data/doc/Vizi/LogParser.html +0 -551
  31. data/doc/Vizi/Translator.html +0 -302
  32. data/doc/Vizi/UnSupportedLanguage.html +0 -212
  33. data/doc/Vizi/Visit.html +0 -487
  34. data/doc/Vizi/VisitList.html +0 -386
  35. data/doc/Vizi.html +0 -159
  36. data/doc/ViziLogFormat.html +0 -382
  37. data/doc/ViziLogParser.html +0 -551
  38. data/doc/docs/Whois_Documentation.doc +0 -0
  39. data/doc/formats/apache-custom-log.pdf +0 -0
  40. data/doc/formats/apache.rtf +0 -238
  41. data/doc/formats/format-descriptions.xls +0 -0
  42. data/doc/formats/w3c-extended.pdf +0 -0
  43. data/doc/formats/w3c-extended.rtf +0 -135
  44. data/doc/images/brick.png +0 -0
  45. data/doc/images/brick_link.png +0 -0
  46. data/doc/images/bug.png +0 -0
  47. data/doc/images/bullet_black.png +0 -0
  48. data/doc/images/bullet_toggle_minus.png +0 -0
  49. data/doc/images/bullet_toggle_plus.png +0 -0
  50. data/doc/images/date.png +0 -0
  51. data/doc/images/find.png +0 -0
  52. data/doc/images/loadingAnimation.gif +0 -0
  53. data/doc/images/macFFBgHack.png +0 -0
  54. data/doc/images/package.png +0 -0
  55. data/doc/images/page_green.png +0 -0
  56. data/doc/images/page_white_text.png +0 -0
  57. data/doc/images/page_white_width.png +0 -0
  58. data/doc/images/plugin.png +0 -0
  59. data/doc/images/ruby.png +0 -0
  60. data/doc/images/tag_green.png +0 -0
  61. data/doc/images/wrench.png +0 -0
  62. data/doc/images/wrench_orange.png +0 -0
  63. data/doc/images/zoom.png +0 -0
  64. data/doc/js/darkfish.js +0 -116
  65. data/doc/js/jquery.js +0 -32
  66. data/doc/js/quicksearch.js +0 -114
  67. data/doc/js/thickbox-compressed.js +0 -10
  68. data/doc/lib/vizi/parser_rb.html +0 -63
  69. data/doc/lib/vizi/vizi_tracker_rb.html +0 -63
  70. data/doc/lib/vizi/vizi_translator.html +0 -104
  71. data/doc/lib/vizi/vizi_translator_rb.html +0 -69
  72. data/doc/lib/vizi_log_parser_rb.html +0 -56
  73. data/doc/lib/vizi_tracker_rb.html +0 -56
  74. data/doc/lib/vizi_translator_rb.html +0 -54
  75. data/doc/rdoc.css +0 -759
  76. data/doc/test/parser_test_rb.html +0 -54
  77. data/doc/test/test_helper_rb.html +0 -56
  78. data/doc/testit_rb.html +0 -63
@@ -1,551 +0,0 @@
1
- <?xml version="1.0" encoding="IBM437"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
7
-
8
- <title>Class: Vizi::LogParser</title>
9
-
10
- <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
-
12
- <script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
13
- <script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
14
- <script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
15
- <script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
16
-
17
- </head>
18
- <body id="top" class="class">
19
-
20
- <div id="metadata">
21
- <div id="home-metadata">
22
- <div id="home-section" class="section">
23
- <h3 class="section-header">
24
- <a href="../index.html">Home</a>
25
- <a href="../index.html#classes">Classes</a>
26
- <a href="../index.html#methods">Methods</a>
27
- </h3>
28
- </div>
29
- </div>
30
-
31
- <div id="file-metadata">
32
- <div id="file-list-section" class="section">
33
- <h3 class="section-header">In Files</h3>
34
- <div class="section-body">
35
- <ul>
36
-
37
- <li><a href="../lib/vizi/vizi_tracker_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
38
- class="thickbox" title="lib/vizi/vizi_tracker.rb">lib/vizi/vizi_tracker.rb</a></li>
39
-
40
- </ul>
41
- </div>
42
- </div>
43
-
44
-
45
- </div>
46
-
47
- <div id="class-metadata">
48
-
49
- <!-- Parent Class -->
50
- <div id="parent-class-section" class="section">
51
- <h3 class="section-header">Parent</h3>
52
-
53
- <p class="link"><a href="../Object.html">Object</a></p>
54
-
55
- </div>
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
- <!-- Method Quickref -->
64
- <div id="method-list-section" class="section">
65
- <h3 class="section-header">Methods</h3>
66
- <ul class="link-list">
67
-
68
- <li><a href="#method-c-new">::new</a></li>
69
-
70
- <li><a href="#method-i-build_format">#build_format</a></li>
71
-
72
- <li><a href="#method-i-check_format">#check_format</a></li>
73
-
74
- <li><a href="#method-i-initialize_known_formats">#initialize_known_formats</a></li>
75
-
76
- <li><a href="#method-i-match_partial">#match_partial</a></li>
77
-
78
- <li><a href="#method-i-parse_line">#parse_line</a></li>
79
-
80
- </ul>
81
- </div>
82
-
83
-
84
-
85
- </div>
86
-
87
- <div id="project-metadata">
88
-
89
-
90
- <div id="fileindex-section" class="section project-section">
91
- <h3 class="section-header">Files</h3>
92
- <ul>
93
-
94
- <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
95
-
96
- <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
97
-
98
- </ul>
99
- </div>
100
-
101
-
102
- <div id="classindex-section" class="section project-section">
103
- <h3 class="section-header">Class/Module Index
104
- <span class="search-toggle"><img src="../images/find.png"
105
- height="16" width="16" alt="[+]"
106
- title="show/hide quicksearch" /></span></h3>
107
- <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
108
- <fieldset>
109
- <legend>Quicksearch</legend>
110
- <input type="text" name="quicksearch" value=""
111
- class="quicksearch-field" />
112
- </fieldset>
113
- </form>
114
-
115
- <ul class="link-list">
116
-
117
- <li><a href="../Vizi.html">Vizi</a></li>
118
-
119
- <li><a href="../Vizi/LogFormat.html">Vizi::LogFormat</a></li>
120
-
121
- <li><a href="../Vizi/LogParser.html">Vizi::LogParser</a></li>
122
-
123
- <li><a href="../Vizi/Visit.html">Vizi::Visit</a></li>
124
-
125
- <li><a href="../Vizi/VisitList.html">Vizi::VisitList</a></li>
126
-
127
- <li><a href="../Object.html">Object</a></li>
128
-
129
- <li><a href="../ParserTest.html">ParserTest</a></li>
130
-
131
- </ul>
132
- <div id="no-class-search-results" style="display: none;">No matching classes.</div>
133
- </div>
134
-
135
-
136
- </div>
137
- </div>
138
-
139
- <div id="documentation">
140
- <h1 class="class">Vizi::LogParser</h1>
141
-
142
- <div id="description" class="description">
143
-
144
- <p>This class handles the parsing of each line in the log file</p>
145
-
146
- </div><!-- description -->
147
-
148
-
149
- <div id="5Buntitled-5D" class="documentation-section">
150
-
151
-
152
-
153
-
154
-
155
- <!-- Constants -->
156
- <div id="constants-list" class="section">
157
- <h3 class="section-header">Constants</h3>
158
- <dl>
159
-
160
- <dt><a name="FIELDNAMES">FIELDNAMES</a></dt>
161
-
162
- <dd class="description"></dd>
163
-
164
-
165
- <dt><a name="LOG_FORMATS">LOG_FORMATS</a></dt>
166
-
167
- <dd class="description"></dd>
168
-
169
-
170
- </dl>
171
- </div>
172
-
173
-
174
-
175
- <!-- Attributes -->
176
- <div id="attribute-method-details" class="method-section section">
177
- <h3 class="section-header">Attributes</h3>
178
-
179
-
180
- <div id="known_formats-attribute-method" class="method-detail">
181
- <a name="known_formats"></a>
182
-
183
- <div class="method-heading attribute-method-heading">
184
- <span class="method-name">known_formats</span><span
185
- class="attribute-access-type">[R]</span>
186
- </div>
187
-
188
- <div class="method-description">
189
-
190
-
191
-
192
- </div>
193
- </div>
194
-
195
- </div><!-- attribute-method-details -->
196
-
197
-
198
- <!-- Methods -->
199
-
200
- <div id="public-class-method-details" class="method-section section">
201
- <h3 class="section-header">Public Class Methods</h3>
202
-
203
-
204
- <div id="new-method" class="method-detail ">
205
- <a name="method-c-new"></a>
206
-
207
-
208
- <div class="method-heading">
209
- <span class="method-name">new</span><span
210
- class="method-args">(drop_ips, spider_ips, spider_names, page_extensions, homepage, accept_only_homepage, hostname, drop_refers_by_hostname)</span>
211
- <span class="method-click-advice">click to toggle source</span>
212
- </div>
213
-
214
-
215
- <div class="method-description">
216
-
217
- <p>@@log = ActiveRecord::Base.logger</p>
218
-
219
-
220
-
221
- <div class="method-source-code" id="new-source">
222
- <pre>
223
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 117</span>
224
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">drop_ips</span>, <span class="ruby-identifier">spider_ips</span>, <span class="ruby-identifier">spider_names</span>, <span class="ruby-identifier">page_extensions</span>, <span class="ruby-identifier">homepage</span>, <span class="ruby-identifier">accept_only_homepage</span>, <span class="ruby-identifier">hostname</span>, <span class="ruby-identifier">drop_refers_by_hostname</span>)
225
- <span class="ruby-ivar">@drops</span> = <span class="ruby-identifier">drop_ips</span>
226
- <span class="ruby-ivar">@sips</span> = <span class="ruby-identifier">spider_ips</span>
227
- <span class="ruby-ivar">@snames</span> = <span class="ruby-identifier">spider_names</span>
228
- <span class="ruby-ivar">@page_extensions</span> = <span class="ruby-identifier">page_extensions</span>
229
- <span class="ruby-ivar">@homepage</span> = <span class="ruby-identifier">homepage</span>
230
- <span class="ruby-ivar">@accept_only_homepage</span> = <span class="ruby-identifier">accept_only_homepage</span>
231
- <span class="ruby-ivar">@hostname</span> = <span class="ruby-identifier">hostname</span>
232
- <span class="ruby-ivar">@drop_refers_by_hostname</span> = <span class="ruby-identifier">drop_refers_by_hostname</span>
233
- <span class="ruby-ivar">@log_format</span> = []
234
- <span class="ruby-identifier">initialize_known_formats</span>
235
- <span class="ruby-ivar">@parselog</span> = <span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'./log/parse.log'</span>, <span class="ruby-identifier">shift_age</span> = <span class="ruby-string">'weekly'</span>)
236
- <span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">level</span> = <span class="ruby-constant">Logger</span><span class="ruby-operator">::</span><span class="ruby-constant">WARN</span>
237
- <span class="ruby-keyword">end</span></pre>
238
- </div><!-- new-source -->
239
-
240
- </div>
241
-
242
-
243
-
244
-
245
- </div><!-- new-method -->
246
-
247
-
248
- </div><!-- public-class-method-details -->
249
-
250
- <div id="public-instance-method-details" class="method-section section">
251
- <h3 class="section-header">Public Instance Methods</h3>
252
-
253
-
254
- <div id="build_format-method" class="method-detail ">
255
- <a name="method-i-build_format"></a>
256
-
257
-
258
- <div class="method-heading">
259
- <span class="method-name">build_format</span><span
260
- class="method-args">(line)</span>
261
- <span class="method-click-advice">click to toggle source</span>
262
- </div>
263
-
264
-
265
- <div class="method-description">
266
-
267
-
268
-
269
-
270
-
271
- <div class="method-source-code" id="build_format-source">
272
- <pre>
273
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 150</span>
274
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">build_format</span>(<span class="ruby-identifier">line</span>)
275
- <span class="ruby-identifier">fields</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)
276
- <span class="ruby-identifier">i</span> = <span class="ruby-value">1</span>
277
- <span class="ruby-ivar">@format</span> = <span class="ruby-string">&quot;&quot;</span>
278
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">fields</span>.<span class="ruby-identifier">length</span>
279
- <span class="ruby-ivar">@format</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;%&quot;</span><span class="ruby-operator">+</span><span class="ruby-constant">FIELDNAMES</span>[<span class="ruby-identifier">fields</span>[<span class="ruby-identifier">i</span>]]<span class="ruby-operator">+</span><span class="ruby-string">&quot; &quot;</span>
280
- <span class="ruby-comment"># p log_format
281
- <span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
282
- <span class="ruby-keyword">end</span>
283
- <span class="ruby-keyword">return</span> <span class="ruby-ivar">@format</span>
284
- <span class="ruby-keyword">end</span></pre>
285
- </div><!-- build_format-source -->
286
-
287
- </div>
288
-
289
-
290
-
291
-
292
- </div><!-- build_format-method -->
293
-
294
-
295
- <div id="check_format-method" class="method-detail ">
296
- <a name="method-i-check_format"></a>
297
-
298
-
299
- <div class="method-heading">
300
- <span class="method-name">check_format</span><span
301
- class="method-args">(line)</span>
302
- <span class="method-click-advice">click to toggle source</span>
303
- </div>
304
-
305
-
306
- <div class="method-description">
307
-
308
- <p>Checks which standard the log file (well one line) is Automatically checks
309
- for most complex (longest) regex first..</p>
310
-
311
-
312
-
313
- <div class="method-source-code" id="check_format-source">
314
- <pre>
315
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 143</span>
316
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">check_format</span>(<span class="ruby-identifier">line</span>)
317
- <span class="ruby-ivar">@known_formats</span>.<span class="ruby-identifier">sort_by</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">log_format</span><span class="ruby-operator">|</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>.<span class="ruby-identifier">source</span>.<span class="ruby-identifier">size</span> }.<span class="ruby-identifier">reverse</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">log_format</span><span class="ruby-operator">|</span>
318
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>)
319
- }
320
- <span class="ruby-keyword">return</span> <span class="ruby-value">:unknown</span>
321
- <span class="ruby-keyword">end</span></pre>
322
- </div><!-- check_format-source -->
323
-
324
- </div>
325
-
326
-
327
-
328
-
329
- </div><!-- check_format-method -->
330
-
331
-
332
- <div id="initialize_known_formats-method" class="method-detail ">
333
- <a name="method-i-initialize_known_formats"></a>
334
-
335
-
336
- <div class="method-heading">
337
- <span class="method-name">initialize_known_formats</span><span
338
- class="method-args">()</span>
339
- <span class="method-click-advice">click to toggle source</span>
340
- </div>
341
-
342
-
343
- <div class="method-description">
344
-
345
- <p>processes the format string into symbols and test regex and saves using <a
346
- href="LogFormat.html">LogFormat</a> class</p>
347
-
348
-
349
-
350
- <div class="method-source-code" id="initialize_known_formats-source">
351
- <pre>
352
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 134</span>
353
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize_known_formats</span>
354
- <span class="ruby-ivar">@known_formats</span> = {}
355
- <span class="ruby-constant">LOG_FORMATS</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span><span class="ruby-operator">|</span>
356
- <span class="ruby-ivar">@known_formats</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-constant">Vizi</span><span class="ruby-operator">::</span><span class="ruby-constant">LogFormat</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>)
357
- <span class="ruby-keyword">end</span>
358
- <span class="ruby-keyword">end</span></pre>
359
- </div><!-- initialize_known_formats-source -->
360
-
361
- </div>
362
-
363
-
364
-
365
-
366
- </div><!-- initialize_known_formats-method -->
367
-
368
-
369
- <div id="match_partial-method" class="method-detail ">
370
- <a name="method-i-match_partial"></a>
371
-
372
-
373
- <div class="method-heading">
374
- <span class="method-name">match_partial</span><span
375
- class="method-args">(field, fldarray)</span>
376
- <span class="method-click-advice">click to toggle source</span>
377
- </div>
378
-
379
-
380
- <div class="method-description">
381
-
382
-
383
-
384
-
385
-
386
- <div class="method-source-code" id="match_partial-source">
387
- <pre>
388
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 162</span>
389
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">match_partial</span> (<span class="ruby-identifier">field</span>, <span class="ruby-identifier">fldarray</span>)
390
- <span class="ruby-identifier">hit</span> = <span class="ruby-keyword">nil</span>
391
- <span class="ruby-identifier">hit</span> = <span class="ruby-identifier">fldarray</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">field</span>)
392
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">hit</span>
393
- <span class="ruby-identifier">i</span> = <span class="ruby-value">0</span>
394
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">fldarray</span>.<span class="ruby-identifier">length</span>
395
- <span class="ruby-identifier">hit</span> = <span class="ruby-identifier">field</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">fldarray</span>)
396
- <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">hit</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
397
- <span class="ruby-identifier">i</span> = <span class="ruby-identifier">i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
398
- <span class="ruby-keyword">end</span>
399
- <span class="ruby-keyword">return</span> <span class="ruby-identifier">hit</span>
400
- <span class="ruby-keyword">end</span></pre>
401
- </div><!-- match_partial-source -->
402
-
403
- </div>
404
-
405
-
406
-
407
-
408
- </div><!-- match_partial-method -->
409
-
410
-
411
- <div id="parse_line-method" class="method-detail ">
412
- <a name="method-i-parse_line"></a>
413
-
414
-
415
- <div class="method-heading">
416
- <span class="method-name">parse_line</span><span
417
- class="method-args">(line, logformat)</span>
418
- <span class="method-click-advice">click to toggle source</span>
419
- </div>
420
-
421
-
422
- <div class="method-description">
423
-
424
- <p>apache files ... regex the file to determine logformat name IIS files ...
425
- parse the fields string to determine the file contents</p>
426
-
427
-
428
-
429
- <div class="method-source-code" id="parse_line-source">
430
- <pre>
431
- <span class="ruby-comment"># File lib/vizi/vizi_tracker.rb, line 177</span>
432
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_line</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">logformat</span>)
433
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">logformat</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
434
- <span class="ruby-identifier">log_format</span> = <span class="ruby-identifier">logformat</span> <span class="ruby-comment"># get log_format string
435
- <span class="ruby-ivar">@format_name</span> = <span class="ruby-string">&quot;temp&quot;</span>
436
- <span class="ruby-identifier">data</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)
437
- <span class="ruby-keyword">else</span>
438
- <span class="ruby-ivar">@format_name</span> = <span class="ruby-identifier">check_format</span>(<span class="ruby-identifier">line</span>) <span class="ruby-comment"># look for matching formats, check each time
439
- <span class="ruby-identifier">log_format</span> = <span class="ruby-ivar">@known_formats</span>[<span class="ruby-ivar">@format_name</span>] <span class="ruby-comment"># found a matched format
440
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">!~</span> <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>
441
- <span class="ruby-identifier">data</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_regex</span>).<span class="ruby-identifier">flatten</span>
442
- <span class="ruby-keyword">end</span>
443
- <span class="ruby-identifier">parsed_data</span> = {}
444
- <span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_symbols</span>.<span class="ruby-identifier">size</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
445
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-identifier">log_format</span>.<span class="ruby-identifier">format_symbols</span>[<span class="ruby-identifier">i</span>]] = <span class="ruby-identifier">data</span>[<span class="ruby-identifier">i</span>] <span class="ruby-comment"># load data for each format_symbol
446
- <span class="ruby-keyword">end</span>
447
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>]
448
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>][<span class="ruby-value">1</span><span class="ruby-operator">...</span><span class="ruby-value">-1</span>]
449
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>].<span class="ruby-identifier">sub</span>(<span class="ruby-string">&quot;:&quot;</span>, <span class="ruby-string">&quot; &quot;</span>)
450
- <span class="ruby-keyword">end</span>
451
- <span class="ruby-comment"># Add ip as domain if we don't have a domain (virtual host)
452
- <span class="ruby-comment"># Assumes we always have an ip
453
- <span class="ruby-comment"># parsed_data[:domain] = parsed_data[:ip] unless parsed_data[:domain] ##&lt;&lt;-- don't know this
454
- <span class="ruby-comment"># parsed_data[:format_name] = @format_name
455
-
456
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformatname</span>] = <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span>
457
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-identifier">logformat</span>
458
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">&quot;H&quot;</span> <span class="ruby-comment"># set default visitor type (H)uman
459
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;V&quot;</span> <span class="ruby-comment"># linetype is (V)isitors
460
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;C&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>].<span class="ruby-identifier">nil?</span> <span class="ruby-comment"># reset if a comment line
461
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;w3c_f&quot;</span> <span class="ruby-comment"># IIS file name ... generic
462
- <span class="ruby-ivar">@format</span> = <span class="ruby-identifier">build_format</span>(<span class="ruby-identifier">line</span>) <span class="ruby-comment"># parse fields to get log_format
463
- <span class="ruby-identifier">temp_format</span> = <span class="ruby-constant">Vizi</span><span class="ruby-operator">::</span><span class="ruby-constant">LogFormat</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:temp</span>, <span class="ruby-ivar">@format</span>) <span class="ruby-comment"># create temp format
464
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-identifier">temp_format</span> <span class="ruby-comment"># shuttle the log_format object
465
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformatname</span>] = <span class="ruby-string">&quot;temp&quot;</span> <span class="ruby-comment"># change the name
466
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;F&quot;</span> <span class="ruby-comment"># linetype to (F)ield list
467
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">&quot;-&quot;</span> <span class="ruby-comment"># visitor type not relevant
468
- <span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@format_name</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;w3c_c&quot;</span> <span class="ruby-comment"># IIS file name ... comments
469
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;C&quot;</span> <span class="ruby-comment"># linetype is (C)omment
470
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">&quot;-&quot;</span>
471
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&quot;C&quot;</span>
472
- <span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">warn</span> <span class="ruby-identifier">line</span>
473
- <span class="ruby-ivar">@parselog</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">&quot;Found comment lines embedded in the log file ... resetting to nil&quot;</span>
474
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_logformat</span>] = <span class="ruby-keyword">nil</span>
475
- <span class="ruby-keyword">else</span> <span class="ruby-comment"># parsing the field names
476
-
477
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datestring</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
478
- <span class="ruby-identifier">dt</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datestring</span>]<span class="ruby-operator">+</span><span class="ruby-string">&quot; &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:timestring</span>])
479
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datetime</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">month</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">day</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">hour</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">min</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">sec</span>)
480
- <span class="ruby-keyword">end</span>
481
-
482
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
483
- <span class="ruby-identifier">dt</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:dtstring</span>])
484
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:datetime</span>] = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">gm</span>(<span class="ruby-identifier">dt</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">month</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">day</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">hour</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">min</span>, <span class="ruby-identifier">dt</span>.<span class="ruby-identifier">sec</span>)
485
- <span class="ruby-keyword">end</span>
486
-
487
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:request</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
488
- <span class="ruby-identifier">splitrequest</span> = <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:request</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&quot;/&quot;</span>, <span class="ruby-string">&quot; &quot;</span>).<span class="ruby-identifier">split</span>
489
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>] = <span class="ruby-identifier">splitrequest</span>[<span class="ruby-value">1</span>]
490
- <span class="ruby-keyword">end</span>
491
-
492
- <span class="ruby-comment"># Now classify records based on logger rules ...
493
-
494
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">false</span>
495
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@accept_only_homepage</span>
496
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>].<span class="ruby-identifier">downcase</span>.<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@homepage</span>) <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
497
- <span class="ruby-keyword">else</span>
498
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_pageflag</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">match_partial</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:csuristem</span>], <span class="ruby-ivar">@page_extensions</span>)
499
- <span class="ruby-keyword">end</span>
500
-
501
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;D&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@drops</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>])
502
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">&quot;S&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sips</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:ip</span>])
503
-
504
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:user_agent</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
505
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_visitortype</span>] = <span class="ruby-string">&quot;S&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">match_partial</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:user_agent</span>], <span class="ruby-ivar">@snames</span>)
506
- <span class="ruby-keyword">end</span>
507
-
508
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@drop_refers_by_hostname</span>
509
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;D&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>].<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@hostname</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
510
- <span class="ruby-keyword">end</span>
511
-
512
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
513
- <span class="ruby-identifier">y</span> = (<span class="ruby-regexp">/(search\?\S*?[pq])=(\S*?)(&amp;)/</span>).<span class="ruby-identifier">match</span>(<span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>])
514
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_searchphrase</span>] = <span class="ruby-identifier">y</span>[<span class="ruby-value">2</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">y</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
515
- <span class="ruby-comment">#p parsed_data[:ip] if y != nil
516
- <span class="ruby-comment">#p parsed_data[:p_searchphrase] if y != nil
517
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@drop_refers_by_hostname</span>
518
- <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:p_linetype</span>] = <span class="ruby-string">&quot;D&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parsed_data</span>[<span class="ruby-value">:referer</span>].<span class="ruby-identifier">index</span>(<span class="ruby-ivar">@hostname</span>) <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
519
- <span class="ruby-keyword">end</span>
520
- <span class="ruby-keyword">end</span>
521
-
522
- <span class="ruby-keyword">end</span>
523
- <span class="ruby-comment"># p parsed_data
524
- <span class="ruby-identifier">parsed_data</span>
525
- <span class="ruby-keyword">end</span></pre>
526
- </div><!-- parse_line-source -->
527
-
528
- </div>
529
-
530
-
531
-
532
-
533
- </div><!-- parse_line-method -->
534
-
535
-
536
- </div><!-- public-instance-method-details -->
537
-
538
- </div><!-- 5Buntitled-5D -->
539
-
540
-
541
- </div><!-- documentation -->
542
-
543
- <div id="validator-badges">
544
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
545
- <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
546
- Rdoc Generator</a> 2</small>.</p>
547
- </div>
548
-
549
- </body>
550
- </html>
551
-