rubylogparser 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/EXAMPLES.txt CHANGED
@@ -25,10 +25,13 @@ Time) are also printed.
25
25
  lp = RubyLogParser.new
26
26
  lp.open_query('FS', 'Select Top 10 name, size INTO STDOUT from c:/win*.* ORDER BY size DESC', 'CSV', nil)
27
27
 
28
- while hash = lp.read_hash do
28
+ while hash = lp.data_hash(lp.process_array_line(lp.readline)) do
29
29
  p "#{hash['Name'].ljust(60)} #{hash['Size'].rjust(12)}\n"
30
30
  end
31
31
 
32
+ lp.parse_errors_and_stats(lp.read)
33
+
34
+ p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
32
35
  p "Processed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
33
36
  p "Output: " + (lp.elements_output.nil? ? "0" : "#{lp.elements_output}") + "\n"
34
37
  p "Time: " + (lp.execution_time.nil? ? "0" : "#{lp.execution_time}") + " seconds\n"
@@ -62,10 +65,13 @@ In this example, each line of data is read into an array for further processing
62
65
  "
63
66
 
64
67
  lp.open_query('EVT', sql, 'CSV', nil)
65
- while array = lp.read_array_line do
68
+ while array = lp.process_array_line(lp.readline) do
66
69
  p "#{array[0].ljust(35)} #{array[1].rjust(8)}\n"
67
70
  end
71
+
72
+ lp.parse_errors_and_stats(lp.read)
68
73
 
74
+ p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
69
75
  p "Processed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
70
76
  p "Output: " + (lp.elements_output.nil? ? "0" : "#{lp.elements_output}") + "\n"
71
77
  p "Time: " + (lp.execution_time.nil? ? "0" : "#{lp.execution_time}") + " seconds\n"
@@ -99,7 +105,7 @@ printing the query statistics.
99
105
 
100
106
  lp.open_query('REG', sql, 'CSV', {'e' => 100})
101
107
 
102
- while array = lp.read_array_line do
108
+ while array = lp.process_array_line(lp.readline) do
103
109
  p "#{array[0].ljust(80)} #{array[1].rjust(25)}\n"
104
110
  end
105
111
 
data/GUIDE.txt CHANGED
@@ -84,13 +84,14 @@ Next we read the Log Parser output line by line into an array and format the
84
84
  output to be printed to the screen. See the examples/files.rb example for using
85
85
  a hash to retrieve output.
86
86
 
87
- while array = lp.read_array_line do
87
+ while array = lp.process_array_line(lp.readline) do
88
88
  p "#{array[0].ljust(35)} #{array[1].rjust(8)}\n"
89
89
  end
90
90
 
91
91
  Once all output has been processed, the query statistics and any warnings/errors
92
- are available.
92
+ are read from the remaining Log Parser output in the pipe and made available.
93
93
 
94
+ lp.parse_errors_and_stats(lp.read)
94
95
  p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
95
96
  p "Processed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
96
97
  p "Output: " + (lp.elements_output.nil? ? "0" : "#{lp.elements_output}") + "\n"
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.1 / 2008-06-06
2
+
3
+ * Updated to have 100% code coverage (as reported by rcov)
4
+ * Methods refactored to achieve the 100% testing nirvana.
5
+ * Some minor changes in the examples
6
+
1
7
  == 0.1.0 / 2008-01-10
2
8
 
3
9
  * Initial Release (Pilchuck)
@@ -19,11 +19,13 @@ ORDER BY number_of_events desc
19
19
  lp.open_query('EVT', sql, 'CSV', nil)
20
20
 
21
21
  i=1
22
- while array = lp.read_array_line do
22
+ while array = lp.process_array_line(lp.readline) do
23
23
  p "#{i}.".ljust(4) + " #{array[0].ljust(35)} #{array[1].rjust(8)}\n"
24
24
  i += 1
25
25
  end
26
26
 
27
+ lp.parse_errors_and_stats(lp.read)
28
+
27
29
  p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
28
30
  p "\nProcessed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
29
31
  p "Output: " + (lp.elements_output.nil? ? "0" : "#{lp.elements_output}") + "\n"
data/examples/files.rb CHANGED
@@ -6,14 +6,17 @@ require 'rubylogparser.rb'
6
6
  lp = RubyLogParser.new
7
7
 
8
8
  # Note: This query may take several minutes to run
9
- lp.open_query('FS', 'Select Top 10 name, size INTO STDOUT from c:/win*.* ORDER BY size DESC', 'CSV', nil)
9
+ lp.open_query('FS', 'Select Top 10 name, size INTO STDOUT from c:/rubylogparser/*.* ORDER BY size DESC', 'CSV', nil)
10
10
 
11
11
  i=1
12
- while hash = lp.read_hash do
13
- p "#{i}.".ljust(4) + " #{hash['Name'].ljust(60)} #{hash['Size'].rjust(12)}\n"
12
+ while hash = lp.data_hash(lp.process_array_line(lp.readline)) do
13
+ p "#{i}. #{hash['Name'].ljust(60)} #{hash['Size'].rjust(12)}\n"
14
14
  i += 1
15
15
  end
16
16
 
17
+ lp.parse_errors_and_stats(lp.read)
18
+
19
+ p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
17
20
  p "Processed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
18
21
  p "Output: " + (lp.elements_output.nil? ? "0" : "#{lp.elements_output}") + "\n"
19
22
  p "Time: " + (lp.execution_time.nil? ? "0" : "#{lp.execution_time}") + " seconds\n"
@@ -15,4 +15,4 @@ ORDER BY timegenerated DESC
15
15
 
16
16
  lp = RubyLogParser.new
17
17
  lp.open_query('EVT', sql, nil, {'queryInfo' => true})
18
- puts "#{lp.formatted_queryInfo}"
18
+ puts "#{lp.queryInfo}"
data/examples/registry.rb CHANGED
@@ -18,11 +18,13 @@ WHERE LastWriteTime >= SUB(SYSTEM_TIMESTAMP(), TIMESTAMP('0000-01-02', 'yyyy-M
18
18
  lp.open_query('REG', sql, 'CSV', {'e' => 100})
19
19
 
20
20
  i=1
21
- while array = lp.read_array_line do
22
- p "#{i}.".ljust(5) + " #{array[0].ljust(80)} #{array[1].rjust(25)}\n"
21
+ while array = lp.process_array_line(lp.readline) do
22
+ p "#{i}. #{array[0].ljust(80)} #{array[1].rjust(25)}\n"
23
23
  i += 1
24
24
  end
25
25
 
26
+ lp.parse_errors_and_stats(lp.read)
27
+
26
28
  p "Parse errors:\n" + lp.parse_errors.to_s + "\n\n"
27
29
  p "Statistics:\n"
28
30
  p "Processed: " + (lp.elements_processed.nil? ? "0" : "#{lp.elements_processed}") + "\n"
data/lib/rubylogparser.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
  # Author: James A. Clark (jimclark at ieee dot org)
7
7
  #
8
- # Copyright (c) 2007, All Rights Reserved.
8
+ # Copyright (c) 2008, All Rights Reserved.
9
9
  #
10
10
  # This is free software. You may modify and redistribute this freely under
11
11
  # your choice of the GNU General Public License or the Ruby License.
@@ -16,7 +16,7 @@
16
16
  require 'csv'
17
17
 
18
18
  class RubyLogParser
19
- VERSION = "0.1.0"
19
+ VERSION = "0.1.1"
20
20
 
21
21
  # Stores the various options that will be used to build the command line that
22
22
  # the process is eventually started with
@@ -25,6 +25,10 @@ class RubyLogParser
25
25
  # The command line string that IO.popen uses to open the LogParser parser
26
26
  attr_accessor :cmd_string
27
27
 
28
+ # A flag which is nil until remaining log parser output is statistics, errors
29
+ # or other non-data related output
30
+ attr_accessor :error_flag
31
+
28
32
  # The pipe to the IO.popen process to read LogParser output data
29
33
  attr_accessor :logparser_pipe
30
34
 
@@ -55,9 +59,7 @@ class RubyLogParser
55
59
  # Initialize is used to check that the Log Parser executable can be found
56
60
  # and to config the various command line defaults.
57
61
  def initialize(lp_executable = nil)
58
- if self.valid_executable(lp_executable) == false
59
- raise "The LogParser executable file cannot be found."
60
- end
62
+ self.valid_executable(lp_executable)
61
63
  self.set_defaults
62
64
  end
63
65
 
@@ -67,7 +69,7 @@ class RubyLogParser
67
69
  # If an executable path is provided, this is tried instead allowing the user to
68
70
  # pick the desired path if one or more LogParser versions are installed.
69
71
  def valid_executable(lp_executable = nil)
70
- found = false
72
+ @logparser_exe = nil
71
73
  if lp_executable.nil? then
72
74
  file_locations = ['c:\Program Files\IIS Resources\Log Parser 2.2\LogParser.exe', 'c:\Program Files\Log Parser 2.2\LogParser.exe', 'LogParser.exe']
73
75
  else
@@ -76,11 +78,14 @@ class RubyLogParser
76
78
 
77
79
  file_locations.each {|location|
78
80
  if File::executable? location then
79
- found = true
80
81
  @logparser_exe = location
81
82
  end
82
83
  }
83
- return found
84
+ if @logparser_exe.nil?
85
+ raise RuntimeError, "The Log Parser executable could not be found."
86
+ end
87
+
88
+ return @logparser_exe
84
89
  end
85
90
 
86
91
  # LogParser has a variety of switches to control the input, output, SQL and
@@ -163,67 +168,51 @@ class RubyLogParser
163
168
  return @cmd_string
164
169
  end
165
170
 
166
- # LogParser needs a data input source, a SQL selection query, and an output
167
- # location. A hash can also be passed to override default values or provide
168
- # additional command line switches. An interesting exception that needs to be
169
- # handled is LogParser's "-queryInfo" switch which makes LogParser evaluate
170
- # the input parameters and return info on the various column datatypes.
171
- def open_query(input, query, output, options)
172
- @cmd_options['i'] = input
173
- @cmd_options['sql'] = query
174
- @cmd_options['o'] = output
175
- @cmd_string = self.build_command_string(options)
176
-
177
- self.create_process
178
-
179
- if @cmd_options['queryInfo'] == true then
180
- @queryInfo = []
181
- @logparser_pipe.each do |line|
182
- @queryInfo << line
183
- end
184
- elsif @cmd_options['q'] == false then
185
- self.field_definitions
186
- end
187
- end
188
-
189
171
  # The LogParser process is created using IO.popen and then subsequent output
190
172
  # from LogParser is read via a pipe.
191
173
  def create_process
174
+ @logparser_pipe = nil
175
+ msg = nil
192
176
  begin
193
177
  @logparser_pipe = IO.popen(@cmd_string, "rb")
194
178
  rescue Exception => e
195
- puts "Exit status is: #{e.status}"
179
+ msg = e.to_s
180
+ # puts msg # when debugging
196
181
  end
182
+ return @logparser_pipe
197
183
  end
198
184
 
199
- # Reads a single line of output from the LogParser pipe until an EOF is
200
- # detected. LogParser will first output all of the query data and then a "\r\n"
201
- # blank line followed by any errors or query statistics. Hence, once this
202
- # method detects the blank line, all remaining LogParser output is expected
203
- # to be error or statistic related.
185
+ # Return everything that remains in the Log Parser pipe
186
+ def read
187
+ @logparser_pipe.read
188
+ end
189
+
190
+ # Reads a single line of output from the LogParser pipe.
204
191
  def readline
205
- begin
206
- line = @logparser_pipe.readline
207
- if line == "\r\n" then
208
- line_errors_and_stats(line)
209
- else
210
- line.chomp!
211
- return line
212
- end
213
- rescue EOFError
192
+ self.process_line(@logparser_pipe.readline)
193
+ end
194
+
195
+ # When Log Parser outputs the first blank line ("\r\n"), it indicates that
196
+ # the data output is complete and anything that will follow are the errors
197
+ # or query statistics.
198
+ def process_line(line)
199
+ if line == "\r\n" then
200
+ self.error_flag = true # remaining output should now be error
214
201
  return nil
202
+ else
203
+ return line.chomp!
215
204
  end
216
205
  end
217
-
206
+
218
207
  # The first line of output contains the field names (by default). This
219
208
  # information is used to name the various hash keys when data is returned in
220
209
  # a hash.
221
- def field_definitions
210
+ def field_definitions(names_line)
222
211
  @field_names = Array.new
223
- names_line = self.readline
224
212
  if !names_line.nil? then
225
213
  @field_names = names_line.split(/,/)
226
214
  end
215
+ return @field_names
227
216
  end
228
217
 
229
218
  # The output from LogParser is return in comma separated value (CSV) format.
@@ -232,8 +221,7 @@ class RubyLogParser
232
221
  # a field in two. In cases where the actual number of fields returned by split
233
222
  # does not match the expected number, the CSV library is called to try the
234
223
  # split. This usually fixes the problem.
235
- def read_array_line
236
- next_line = self.readline
224
+ def process_array_line(next_line)
237
225
  if !next_line.nil? then
238
226
  array_line = next_line.split(/,/)
239
227
  if array_line.length == @field_names.length then
@@ -243,7 +231,6 @@ class RubyLogParser
243
231
  if row.length == @field_names.length then
244
232
  return row
245
233
  else
246
- line_errors_and_stats(next_line)
247
234
  return nil
248
235
  end
249
236
  }
@@ -252,54 +239,56 @@ class RubyLogParser
252
239
  return nil
253
240
  end
254
241
 
255
- # Once LogParser finishes outputting query data, it then outputs any errors
256
- # followed by query statistics (unless specifically turned off). Errors are
257
- # pushed into the @parse_errors array and statistics are added to the
258
- # appropriate class variables.
259
- def line_errors_and_stats(line_input)
260
- begin
261
- while 1 > 0
262
- case line_input
263
- when /Task completed with parse errors/
264
- @parse_errors = Array.new
265
- until ((line_input = @logparser_pipe.readline) == "\r\n")
266
- @parse_errors.push(line_input)
267
- end
268
- when /Statistics:/
269
- while line = @logparser_pipe.readline
270
- case line
271
- when /Elements processed:\s*([\d,]+)\n*/i
272
- @elements_processed = $1
273
- when /Elements output:\s*([\d,]+)\n*/i
274
- @elements_output = $1
275
- when /Execution time:\s*([\d\.]+) seconds\n*/i
276
- @execution_time = $1
277
- end
278
- end
279
- end
280
- line_input = @logparser_pipe.readline
281
- end
282
- rescue EOFError
283
- return nil
242
+ # Extract statistics and any parse errors from output
243
+ def parse_errors_and_stats(text_input)
244
+ if text_input =~ /Statistics:\r\n(.*)/ then
245
+ @elements_processed = $1 if text_input =~ /^Elements processed:\s*([\d,]+)\r\n/i
246
+ @elements_output = $1 if text_input =~ /^Elements output:\s*([\d,]+)\r\n/i
247
+ @execution_time = $1 if text_input =~ /^Execution time:\s*([\d\.]+) seconds\r\n/i
284
248
  end
249
+
250
+ if text_input =~ /Task completed with parse errors.*?\r\n(.*)/ims then
251
+ @parse_errors = $1
252
+ if @parse_errors =~ /(.*?)Statistics:\r\n/ims then
253
+ @parse_errors = $1
254
+ end
255
+ end
285
256
  end
286
257
 
287
258
  # To return the data in a hash, the data line is first read into an array.
288
259
  # Then the field keys (initially loaded by the field_definitions method when
289
260
  # the LogParser process was created), are matched up with the respective data
290
261
  # values.
291
- def read_hash
292
- data_hash = Hash.new
293
- data_array = read_array_line
294
- if !data_array.nil? then
262
+ def data_hash(data_array)
263
+ data_hash = nil
264
+ if !data_array.nil? then
265
+ data_hash = Hash.new
295
266
  @field_names.each_index {|x|
296
267
  data_hash[@field_names[x]] = data_array[x]
297
268
  }
298
- return data_hash
299
- else
300
- return nil
301
269
  end
270
+ return data_hash
302
271
  end
272
+
273
+ # LogParser needs a data input source, a SQL selection query, and an output
274
+ # location. A hash can also be passed to override default values or provide
275
+ # additional command line switches. An interesting exception that needs to be
276
+ # handled is LogParser's "-queryInfo" switch which makes LogParser evaluate
277
+ # the input parameters and return info on the various column datatypes.
278
+ def open_query(input, query, output, options)
279
+ @cmd_options['i'] = input
280
+ @cmd_options['sql'] = query
281
+ @cmd_options['o'] = output
282
+ @cmd_string = self.build_command_string(options)
283
+
284
+ self.create_process
285
+
286
+ if @cmd_options['queryInfo'] == true then
287
+ @queryInfo = self.read
288
+ elsif @cmd_options['q'] == false then
289
+ self.field_definitions(self.readline)
290
+ end
291
+ end
303
292
 
304
293
  # When data is best processed all at once, this method will return an array
305
294
  # of arrays. The array will have a header row with the field names by default
@@ -311,20 +300,20 @@ class RubyLogParser
311
300
  data_array[i] = @field_names
312
301
  i += 1
313
302
  end
314
- while array = self.read_array_line do
303
+ while array = self.process_array_line(self.readline) do
315
304
  data_array[i] = array
316
305
  i += 1
317
306
  end
318
307
  return data_array
319
308
  end
320
309
 
321
- # A simple convenience method when running LogParser using the -queryInfo
322
- # switch. The resulting output is combined into a single string for easier
323
- # printing.
324
- def formatted_queryInfo
325
- temp = String.new
326
- @queryInfo.each{|line| temp << line}
327
- return temp
328
- end
329
-
330
310
  end
311
+ =begin
312
+ @logparser = RubyLogParser.new
313
+ @logparser.open_query('EVT','SELECT Top 2 SourceName INTO STDOUT From System','CSV',nil)
314
+ temp = @logparser.read_array(true)
315
+ p temp.length
316
+ p "Stat info:"
317
+ p @logparser.read_all
318
+
319
+ =end
@@ -8,10 +8,19 @@ class Test_RubyLogParser < Test::Unit::TestCase
8
8
  def setup
9
9
  @logparser = RubyLogParser.new
10
10
  end
11
+
12
+ def teardown
13
+ if @logparser.logparser_pipe.respond_to?("readline") then
14
+ @logparser.logparser_pipe.read
15
+ end
16
+ @logparser = nil
17
+ end
11
18
 
12
19
  def test_valid_executable
13
- assert_equal true, @logparser.valid_executable(nil)
14
- assert_equal false, @logparser.valid_executable('c:\someotherfilename.exe')
20
+ assert_not_equal nil, @logparser.valid_executable(nil)
21
+ assert_raise RuntimeError do
22
+ @logparser.valid_executable('c:\someotherfilename.exe')
23
+ end
15
24
  end
16
25
 
17
26
  def test_set_defaults
@@ -20,13 +29,14 @@ class Test_RubyLogParser < Test::Unit::TestCase
20
29
  assert_equal false, test_defaults['queryInfo']
21
30
  end
22
31
 
23
- def test_valid_input_type
32
+ def test_valid_input_format
24
33
  assert_equal true, @logparser.valid_input_format("CSV")
25
34
  assert_equal true, @logparser.valid_input_format("csv")
26
- assert_equal false, @logparser.valid_input_format("xxx")
35
+ assert_equal false, @logparser.valid_input_format("xxx")
36
+ assert_equal true, @logparser.valid_input_format(nil)
27
37
  end
28
38
 
29
- def test_valid_output_type
39
+ def test_valid_output_format
30
40
  assert_equal true, @logparser.valid_output_format("CSV")
31
41
  assert_equal true, @logparser.valid_output_format("csv")
32
42
  assert_equal false, @logparser.valid_output_format("xxx")
@@ -39,5 +49,89 @@ class Test_RubyLogParser < Test::Unit::TestCase
39
49
  @logparser.logparser_exe = 'LogParser.exe'
40
50
  assert_equal '"LogParser.exe" -i:EVT "SQL Test" -o:CSV -queryInfo', @logparser.build_command_string({'queryInfo' => true})
41
51
  end
52
+
53
+ def test_create_process
54
+ @logparser.cmd_options['i'] = 'EVT'
55
+ @logparser.cmd_options['sql'] = 'SELECT Top 2 SourceName INTO STDOUT From System'
56
+ @logparser.cmd_options['o'] = 'CSV'
57
+ @logparser.cmd_string = @logparser.build_command_string(nil)
58
+ @logparser.create_process
59
+ assert_equal true, @logparser.logparser_pipe.respond_to?("readline")
60
+ @logparser.cmd_string = ' '
61
+ assert_equal nil, @logparser.create_process
62
+ end
63
+
64
+ def test_process_line
65
+ assert_equal "test", @logparser.process_line("test\r\n")
66
+ assert_equal nil, @logparser.process_line("\r\n")
67
+ assert_equal true, @logparser.error_flag
68
+ end
69
+
70
+ def test_field_definitions
71
+ assert_equal [], @logparser.field_definitions(nil)
72
+ assert_equal ["A"], @logparser.field_definitions("A")
73
+ assert_equal ["A","B"], @logparser.field_definitions("A,B")
74
+ end
75
+
76
+ def test_process_array_line
77
+ assert_equal ["A","B","C"], @logparser.field_definitions("A,B,C")
78
+ assert_equal 3, @logparser.process_array_line('data1,data2,data3').length
79
+ assert_equal 3, @logparser.process_array_line('data1,"da,ta2",data3').length
80
+ assert_equal nil, @logparser.process_array_line('data1,"da,ta2",data3,"data4"')
81
+ end
82
+
83
+ def test_parse_errors_and_stats
84
+ text = "Task completed with parse errors.\r\nHere are the errors...\r\nStatistics:\r\n-----------\r\nElements processed: 2\r\nElements output: 2\r\nExecution time: 0.01 seconds\r\n\r\n"
85
+ @logparser.parse_errors_and_stats(text)
86
+ assert_equal '2', @logparser.elements_processed
87
+ assert_equal '2', @logparser.elements_output
88
+ assert_equal '0.01', @logparser.execution_time
89
+ assert_match "Here are the errors\.\.\.", @logparser.parse_errors
90
+ end
91
+
92
+ def test_readall
93
+ @logparser.cmd_options['i'] = 'EVT'
94
+ @logparser.cmd_options['sql'] = 'SELECT Top 2 SourceName INTO STDOUT From System'
95
+ @logparser.cmd_options['o'] = 'CSV'
96
+ @logparser.build_command_string(nil)
97
+ @logparser.create_process
98
+ assert_equal true, @logparser.logparser_pipe.respond_to?("read")
99
+ assert_equal true, @logparser.read.length > 100
100
+ assert_equal "", @logparser.read
101
+ end
102
+
103
+ def test_data_hash
104
+ assert_equal nil, @logparser.data_hash(nil)
105
+ assert_equal ["A","B","C"], @logparser.field_definitions("A,B,C")
106
+ temp = @logparser.data_hash(['data1','data2','data3'])
107
+ assert_equal 3, temp.length
108
+ assert_equal 'data1', temp.fetch("A")
109
+ assert_equal 'data2', temp.fetch("B")
110
+ assert_equal 'data3', temp.fetch("C")
111
+ end
112
+
113
+ def test_open_query_queryInfo
114
+ @logparser.open_query('EVT','SELECT * INTO STDOUT From System','CSV',{'queryInfo' => true})
115
+ assert_match "Input format: EVT", @logparser.queryInfo
116
+ end
117
+
118
+ def test_open_query_field_names
119
+ @logparser.open_query('EVT','SELECT TimeGenerated INTO STDOUT From System','CSV',nil)
120
+ assert_equal 'TimeGenerated', @logparser.field_names[0]
121
+ assert_equal 1, @logparser.field_names.length
122
+ end
123
+
124
+ def test_read_array_with_header
125
+ @logparser.open_query('EVT','SELECT Top 2 SourceName INTO STDOUT From System','CSV',nil)
126
+ temp = @logparser.read_array(true)
127
+ assert_equal temp[0][0], 'SourceName'
128
+ assert_equal 3, temp.length
129
+ end
42
130
 
131
+ def test_read_array_without_header
132
+ @logparser.open_query('EVT','SELECT Top 2 SourceName INTO STDOUT From System','CSV',nil)
133
+ temp = @logparser.read_array(false)
134
+ assert_equal 2, temp.length
135
+ end
136
+
43
137
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: rubylogparser
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2008-01-11 00:00:00 -08:00
6
+ version: 0.1.1
7
+ date: 2008-06-06 00:00:00 -07:00
8
8
  summary: RubyLogParser provides a wrapper around Microsoft's Log Parser executable.
9
9
  require_paths:
10
10
  - lib
@@ -66,5 +66,5 @@ dependencies:
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.4.0
69
+ version: 1.5.3
70
70
  version: