file-tail 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/README.en +9 -1
- data/Rakefile +27 -15
- data/VERSION +1 -1
- data/examples/pager.rb +10 -9
- data/examples/tail.rb +2 -2
- data/lib/file/tail.rb +109 -51
- data/tests/{test.rb → test_file-tail.rb} +23 -25
- metadata +39 -30
- data/make_doc.rb +0 -6
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2007-02-08 * 0.1.4 * Renamed rewind method to backward, and wind method to
|
2
|
+
forward, because someone already had the good idea to name
|
3
|
+
a method IO#rewind, which was overwritten by the mixed in
|
4
|
+
File::Tail methods. The old methods are now deprecated and
|
5
|
+
will be removed in a new 0.2.x version of the library.
|
6
|
+
* Added a bit more of documentation.
|
1
7
|
2005-08-20 * 0.1.3 * Applied LOAD_PATH patch by Daniel Berger, binary mode
|
2
8
|
changes were already in the CVS. Seemed to be like cheating
|
3
9
|
to me, though. ;)
|
data/README.en
CHANGED
@@ -3,6 +3,10 @@ Installation
|
|
3
3
|
|
4
4
|
Just type into the command line as root:
|
5
5
|
|
6
|
+
# rake install
|
7
|
+
|
8
|
+
or
|
9
|
+
|
6
10
|
# ruby install.rb
|
7
11
|
|
8
12
|
Documentation
|
@@ -10,6 +14,10 @@ Documentation
|
|
10
14
|
|
11
15
|
To create the documentation of this module, type
|
12
16
|
|
17
|
+
$ rake doc
|
18
|
+
|
19
|
+
or
|
20
|
+
|
13
21
|
$ ruby make_doc.rb
|
14
22
|
|
15
23
|
and the API documentation is generated by your rdoc command.
|
@@ -26,5 +34,5 @@ Florian Frank <flori@ping.de>
|
|
26
34
|
License
|
27
35
|
=======
|
28
36
|
|
29
|
-
GNU General Public License (GPL)
|
37
|
+
GNU General Public License (GPL), Version 2
|
30
38
|
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# vim: set filetype=ruby et sw=2 ts=2:
|
2
2
|
|
3
3
|
require 'rake/gempackagetask'
|
4
4
|
require 'rbconfig'
|
@@ -7,20 +7,32 @@ include Config
|
|
7
7
|
|
8
8
|
PKG_NAME = 'file-tail'
|
9
9
|
PKG_VERSION = File.read('VERSION').chomp
|
10
|
-
PKG_FILES =
|
11
|
-
item.include?("CVS") or item.include?("pkg")
|
12
|
-
}
|
10
|
+
PKG_FILES = FileList["**/*"].exclude(/pkg|coverage|doc/)
|
13
11
|
|
14
12
|
desc "Installing library"
|
15
13
|
task :install do
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
ruby 'install.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Creating documentation"
|
18
|
+
task :doc do
|
19
|
+
ruby 'make_doc.rb'
|
19
20
|
end
|
20
21
|
|
21
22
|
desc "Testing library"
|
22
23
|
task :test do
|
23
|
-
ruby %{-Ilib tests/
|
24
|
+
ruby %{-Ilib tests/test_file-tail.rb}
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Testing library with rcov"
|
28
|
+
task :coverage do
|
29
|
+
system %{rcov -x '\\btests\/' -Ilib tests/test_file-tail.rb}
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Removing generated files"
|
33
|
+
task :clean do
|
34
|
+
rm_rf 'doc'
|
35
|
+
rm_rf 'coverage'
|
24
36
|
end
|
25
37
|
|
26
38
|
spec = Gem::Specification.new do |s|
|
@@ -30,7 +42,7 @@ spec = Gem::Specification.new do |s|
|
|
30
42
|
s.name = 'file-tail'
|
31
43
|
s.version = PKG_VERSION
|
32
44
|
s.summary = "File::Tail for Ruby"
|
33
|
-
s.description = ""
|
45
|
+
s.description = "Library to tail files in Ruby"
|
34
46
|
|
35
47
|
#### Dependencies and requirements.
|
36
48
|
|
@@ -46,7 +58,7 @@ spec = Gem::Specification.new do |s|
|
|
46
58
|
#### Load-time details: library and application (you will need one or both).
|
47
59
|
|
48
60
|
s.require_path = 'lib' # Use these for libraries.
|
49
|
-
s.autorequire = 'file/tail'
|
61
|
+
#s.autorequire = 'file/tail'
|
50
62
|
|
51
63
|
#s.bindir = "bin" # Use these for applications.
|
52
64
|
#s.executables = ["bla.rb"]
|
@@ -56,11 +68,10 @@ spec = Gem::Specification.new do |s|
|
|
56
68
|
|
57
69
|
s.has_rdoc = true
|
58
70
|
#s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
59
|
-
|
60
|
-
|
61
|
-
# '--main' << 'README' <<
|
71
|
+
s.rdoc_options <<
|
72
|
+
'--title' << 'File::Tail' <<
|
62
73
|
# '--line-numbers'
|
63
|
-
s.test_files << 'tests/
|
74
|
+
s.test_files << 'tests/test_file-tail.rb'
|
64
75
|
|
65
76
|
#### Author and project details.
|
66
77
|
|
@@ -74,4 +85,5 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|
74
85
|
pkg.need_tar = true
|
75
86
|
pkg.package_files += PKG_FILES
|
76
87
|
end
|
77
|
-
|
88
|
+
|
89
|
+
task :release => [ :clean, :package ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/examples/pager.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# vim: set et sw=2 ts=2:
|
2
3
|
# A poor man's pager... :)
|
3
4
|
|
4
5
|
require 'file/tail'
|
5
6
|
|
6
7
|
filename = ARGV.shift or fail "Usage: #$0 filename [height]"
|
7
|
-
height = (ARGV.shift ||
|
8
|
+
height = (ARGV.shift || ENV['LINES'] || 23).to_i - 1
|
9
|
+
p height
|
8
10
|
|
9
11
|
File::Tail::Logfile.open(filename, :break_if_eof => true) do |log|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
begin
|
13
|
+
log.tail(height) { |line| puts line }
|
14
|
+
print "Press return key to continue!" ; gets
|
15
|
+
print ""
|
16
|
+
redo
|
17
|
+
rescue File::Tail::BreakException
|
18
|
+
end
|
17
19
|
end
|
18
|
-
# vim: set noet sw=4 ts=4:
|
data/examples/tail.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# vim: set et sw=2 ts=2:
|
2
3
|
|
3
4
|
require 'file/tail'
|
4
5
|
|
@@ -6,6 +7,5 @@ filename = ARGV.pop or fail "Usage: #$0 number filename"
|
|
6
7
|
number = (ARGV.pop || 0).to_i.abs
|
7
8
|
|
8
9
|
File::Tail::Logfile.open(filename) do |log|
|
9
|
-
|
10
|
+
log.backward(number).tail { |line| puts line }
|
10
11
|
end
|
11
|
-
# vim: set noet sw=4 ts=4:
|
data/lib/file/tail.rb
CHANGED
@@ -1,45 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# = File::Tail - Tailing files in Ruby
|
3
|
+
#
|
4
|
+
# == Description
|
5
|
+
#
|
6
|
+
# This is a small ruby library that allows it to "tail" files in Ruby,
|
7
|
+
# including following a file, that still is growing like the unix command 'tail
|
8
|
+
# -f' can.
|
9
|
+
#
|
10
|
+
# == Author
|
11
|
+
#
|
12
|
+
# Florian Frank mailto:flori@ping.de
|
13
|
+
#
|
14
|
+
# == License
|
15
|
+
#
|
16
|
+
# This is free software; you can redistribute it and/or modify it under
|
17
|
+
# the terms of the GNU General Public License Version 2 as published by
|
18
|
+
# the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
|
19
|
+
#
|
20
|
+
# == Download
|
21
|
+
#
|
22
|
+
# The latest version of <b>File::Tail</b> (file-tail) can be found at
|
23
|
+
#
|
24
|
+
# http://rubyforge.org/frs/?group_id=393
|
25
|
+
#
|
26
|
+
# Online Documentation should be located at
|
27
|
+
#
|
28
|
+
# http://file-tail.rubyforge.org
|
29
|
+
#
|
30
|
+
# == Usage
|
31
|
+
#
|
1
32
|
# File::Tail is a module in the File class. A lightweight class interface for
|
2
33
|
# logfiles can be seen under File::Tail::Logfile.
|
34
|
+
#
|
35
|
+
# Direct extension of File objects with File::Tail works like that:
|
36
|
+
# File.open(filename) do |log|
|
37
|
+
# log.extend(File::Tail)
|
38
|
+
# log.interval = 10
|
39
|
+
# log.backward(10)
|
40
|
+
# log.tail { |line| puts line }
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# It's also possible to mix File::Tail in your own File classes
|
44
|
+
# (see also File::Tail::Logfile):
|
45
|
+
# class MyFile < File
|
46
|
+
# include File::Tail
|
47
|
+
# end
|
48
|
+
# log = MyFile.new("myfile")
|
49
|
+
# log.interval = 10
|
50
|
+
# log.backward(10)
|
51
|
+
# log.tail { |line| print line }
|
52
|
+
#
|
53
|
+
# The forward/backward method returns self, so it's possible to chain
|
54
|
+
# methods together like that:
|
55
|
+
# log.backward(10).tail { |line| puts line }
|
56
|
+
#
|
3
57
|
class File
|
4
|
-
|
5
58
|
# The File::Tail module can be included in File objects and mixes in
|
6
|
-
# the
|
7
|
-
#
|
8
|
-
# === Usage
|
9
|
-
# Direct extension of File objects works like that:
|
10
|
-
# File.open(filename) do |log|
|
11
|
-
# log.extend(File::Tail)
|
12
|
-
# log.interval = 10
|
13
|
-
# log.rewind(10)
|
14
|
-
# log.tail { |line| puts line }
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# It's also possible to mix File::Tail in your own File classes
|
18
|
-
# (see also File::Tail::Logfile):
|
19
|
-
# class MyFile < File
|
20
|
-
# include File::Tail
|
21
|
-
# end
|
22
|
-
# log = MyFile.new("myfile")
|
23
|
-
# log.interval = 10
|
24
|
-
# log.rewind(10)
|
25
|
-
# log.tail { |line| print line }
|
26
|
-
#
|
27
|
-
# The wind/rewind method returns self, so it's possible to chain
|
28
|
-
# methods together like that:
|
29
|
-
# log.rewind(10).tail { |line| puts line }
|
59
|
+
# the forward, backward and tail methods.
|
30
60
|
module Tail
|
31
|
-
|
32
61
|
# This is an easy to use Logfile class that includes
|
33
62
|
# the File::Tail module.
|
34
63
|
#
|
35
64
|
# === Usage
|
36
65
|
# The unix command "tail -10f filename" can be emulated like that:
|
37
|
-
# File::Tail::Logfile.open(filename, :
|
66
|
+
# File::Tail::Logfile.open(filename, :backward => 10) do |log|
|
38
67
|
# log.tail { |line| puts line }
|
39
68
|
# end
|
40
69
|
#
|
70
|
+
# Or a bit shorter:
|
71
|
+
# File::Tail::Logfile.tail(filename, :backward => 10) do |line|
|
72
|
+
# puts line
|
73
|
+
# end
|
74
|
+
#
|
41
75
|
# To skip the first 10 lines of the file do that:
|
42
|
-
# File::Tail::Logfile.open(filename, :
|
76
|
+
# File::Tail::Logfile.open(filename, :forward => 10) do |log|
|
43
77
|
# log.tail { |line| puts line }
|
44
78
|
# end
|
45
79
|
#
|
@@ -48,31 +82,34 @@ class File
|
|
48
82
|
# log.tail(10) { |line| puts line }
|
49
83
|
# end
|
50
84
|
class Logfile < File
|
51
|
-
|
52
85
|
include File::Tail
|
53
86
|
|
54
87
|
# This method creates an File::Tail::Logfile object and
|
55
88
|
# yields to it if a block is given, otherwise it just
|
56
89
|
# returns it. The opts hash takes an option like
|
57
|
-
# <code>:
|
58
|
-
# <code>:
|
59
|
-
# the logfile for 10 lines at the start. The buffersize
|
60
|
-
# for
|
61
|
-
# <code>:bufsiz => 8192</code> option.
|
90
|
+
# * <code>:backward => 10</code> to go backwards
|
91
|
+
# * <code>:forward => 10</code> to go forwards
|
92
|
+
# in the logfile for 10 lines at the start. The buffersize
|
93
|
+
# for going backwards can be set with the
|
94
|
+
# * <code>:bufsiz => 8192</code> option.
|
62
95
|
# Every attribute of File::Tail can be set with a
|
63
96
|
# <code>:attributename => value</code> option.
|
64
|
-
def
|
97
|
+
def self.open(filename, opts = {}) # :yields: file
|
65
98
|
file = new filename
|
66
99
|
opts.each do |o, v|
|
67
100
|
writer = o.to_s + "="
|
68
101
|
file.__send__(writer, v) if file.respond_to? writer
|
69
102
|
end
|
70
|
-
if opts
|
71
|
-
|
103
|
+
if opts.key?(:wind) or opts.key?(:rewind)
|
104
|
+
warn ":wind and :rewind options are deprecated, "\
|
105
|
+
"use :forward and :backward instead!"
|
106
|
+
end
|
107
|
+
if backward = opts[:backward] || opts[:rewind]
|
108
|
+
(args = []) << backward
|
72
109
|
args << opt[:bufsiz] if opts[:bufsiz]
|
73
|
-
file.
|
74
|
-
elsif opts[:wind]
|
75
|
-
file.
|
110
|
+
file.backward(*args)
|
111
|
+
elsif forward = opts[:forward] || opts[:wind]
|
112
|
+
file.forward(forward)
|
76
113
|
end
|
77
114
|
if block_given?
|
78
115
|
yield file
|
@@ -81,7 +118,16 @@ class File
|
|
81
118
|
file
|
82
119
|
end
|
83
120
|
end
|
84
|
-
|
121
|
+
|
122
|
+
# Like open, but yields to every new line encountered in the logfile.
|
123
|
+
def self.tail(filename, opts = {})
|
124
|
+
if ([ :forward, :backward ] & opts.keys).empty?
|
125
|
+
opts[:backward] = 0
|
126
|
+
end
|
127
|
+
open(filename, opts) do |log|
|
128
|
+
log.tail { |line| yield line }
|
129
|
+
end
|
130
|
+
end
|
85
131
|
end
|
86
132
|
|
87
133
|
# This is the base class of all exceptions that are raised
|
@@ -106,7 +152,6 @@ class File
|
|
106
152
|
# the tailed file, e. g., it was rotated away. The exception
|
107
153
|
# is caught and an attempt to reopen it is made.
|
108
154
|
class ReopenException < TailException
|
109
|
-
|
110
155
|
attr_reader :mode
|
111
156
|
|
112
157
|
# Creates an ReopenException object. The mode defaults to
|
@@ -118,7 +163,6 @@ class File
|
|
118
163
|
super(self.class.name)
|
119
164
|
@mode = mode
|
120
165
|
end
|
121
|
-
|
122
166
|
end
|
123
167
|
|
124
168
|
# The maximum interval File::Tail sleeps, before it tries
|
@@ -160,9 +204,9 @@ class File
|
|
160
204
|
# just returns if the end of the file is reached.
|
161
205
|
attr_accessor :return_if_eof
|
162
206
|
|
163
|
-
# Skip the first <code>n</code> lines of this file. The default is to
|
164
|
-
#
|
165
|
-
def
|
207
|
+
# Skip the first <code>n</code> lines of this file. The default is to don't
|
208
|
+
# skip any lines at all and start at the beginning of this file.
|
209
|
+
def forward(n = 0)
|
166
210
|
seek(0, File::SEEK_SET)
|
167
211
|
while n > 0 and not eof?
|
168
212
|
readline
|
@@ -171,6 +215,12 @@ class File
|
|
171
215
|
self
|
172
216
|
end
|
173
217
|
|
218
|
+
# The wind method is deprecated, use forward instead.
|
219
|
+
def wind(*args)
|
220
|
+
warn "File::Tail#wind method is deprecated, use forward instead"
|
221
|
+
forward *args
|
222
|
+
end
|
223
|
+
|
174
224
|
# Rewind the last <code>n</code> lines of this file, starting
|
175
225
|
# from the end. The default is to start tailing directly from the
|
176
226
|
# end of the file.
|
@@ -180,7 +230,7 @@ class File
|
|
180
230
|
# the file backwards. It defaults to the block size of the
|
181
231
|
# filesystem this file belongs to or 8192 bytes if this cannot
|
182
232
|
# be determined.
|
183
|
-
def
|
233
|
+
def backward(n = 0, bufsiz = nil)
|
184
234
|
if n <= 0
|
185
235
|
seek(0, File::SEEK_END)
|
186
236
|
return self
|
@@ -332,7 +382,7 @@ class File
|
|
332
382
|
@no_read = 0
|
333
383
|
reopen(path)
|
334
384
|
if mode == :bottom
|
335
|
-
|
385
|
+
backward
|
336
386
|
end
|
337
387
|
rescue Errno::ESTALE
|
338
388
|
rescue Errno::ENOENT
|
@@ -353,9 +403,17 @@ class File
|
|
353
403
|
}
|
354
404
|
$stderr.print h.inspect, "\n"
|
355
405
|
end
|
356
|
-
|
357
406
|
end
|
358
407
|
|
408
|
+
# The rewind method is deprecated and will be removed soon, use backward
|
409
|
+
# instead. At the moment rewind accidentially overwrites the IO#rewind
|
410
|
+
# method, after the removal of the ol rewind mixin method, this will be no
|
411
|
+
# longer the case.
|
412
|
+
def rewind(*args)
|
413
|
+
warn "File::Tail#rewind method is deprecated and will be removed soon, "\
|
414
|
+
"use backward instead"
|
415
|
+
backward *args
|
416
|
+
end
|
359
417
|
end
|
360
418
|
|
361
419
|
if $0 == __FILE__
|
@@ -369,7 +427,7 @@ if $0 == __FILE__
|
|
369
427
|
log.reopen_deleted = true # is default
|
370
428
|
log.reopen_suspicious = true # is default
|
371
429
|
log.suspicious_interval = 20
|
372
|
-
number >= 0 ? log.
|
430
|
+
number >= 0 ? log.backward(number, 8192) : log.forward(-number)
|
373
431
|
#loop do # grab 5 lines at a time and return
|
374
432
|
# log.tail(5) { |line| puts line }
|
375
433
|
# print "Got 5!\n"
|
@@ -377,4 +435,4 @@ if $0 == __FILE__
|
|
377
435
|
log.tail { |line| puts line }
|
378
436
|
end
|
379
437
|
end
|
380
|
-
|
438
|
+
# vim: set et sw=2 ts=2:
|
@@ -14,7 +14,6 @@ require 'thread'
|
|
14
14
|
Thread.abort_on_exception = true
|
15
15
|
|
16
16
|
class TC_FileTail < Test::Unit::TestCase
|
17
|
-
|
18
17
|
include File::Tail
|
19
18
|
|
20
19
|
def setup
|
@@ -29,49 +28,49 @@ class TC_FileTail < Test::Unit::TestCase
|
|
29
28
|
@in.suspicious_interval = 60
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
31
|
+
def test_forward
|
33
32
|
[ 0, 1, 2, 10, 100 ].each do |lines|
|
34
|
-
@in.
|
33
|
+
@in.forward(lines)
|
35
34
|
assert_equal(100 - lines, count(@in))
|
36
35
|
end
|
37
|
-
@in.
|
36
|
+
@in.forward(101)
|
38
37
|
assert_equal(0, count(@in))
|
39
38
|
end
|
40
39
|
|
41
|
-
def
|
40
|
+
def test_backward
|
42
41
|
[ 0, 1, 2, 10, 100 ].each do |lines|
|
43
|
-
@in.
|
42
|
+
@in.backward(lines)
|
44
43
|
assert_equal(lines, count(@in))
|
45
44
|
end
|
46
|
-
@in.
|
45
|
+
@in.backward(101)
|
47
46
|
assert_equal(100, count(@in))
|
48
47
|
end
|
49
48
|
|
50
49
|
def test_tail_with_block_without_n
|
51
50
|
timeout(10) do
|
52
51
|
lines = []
|
53
|
-
@in.
|
52
|
+
@in.backward(1)
|
54
53
|
assert_raises(TimeoutError) do
|
55
54
|
timeout(1) { @in.tail { |l| lines << l } }
|
56
55
|
end
|
57
56
|
assert_equal(1, lines.size)
|
58
57
|
#
|
59
58
|
lines = []
|
60
|
-
@in.
|
59
|
+
@in.backward(10)
|
61
60
|
assert_raises(TimeoutError) do
|
62
61
|
timeout(1) { @in.tail { |l| lines << l } }
|
63
62
|
end
|
64
63
|
assert_equal(10, lines.size)
|
65
64
|
#
|
66
65
|
lines = []
|
67
|
-
@in.
|
66
|
+
@in.backward(100)
|
68
67
|
assert_raises(TimeoutError) do
|
69
68
|
timeout(1) { @in.tail { |l| lines << l } }
|
70
69
|
end
|
71
70
|
assert_equal(100, lines.size)
|
72
71
|
#
|
73
72
|
lines = []
|
74
|
-
@in.
|
73
|
+
@in.backward(101)
|
75
74
|
assert_raises(TimeoutError) do
|
76
75
|
timeout(1) { @in.tail { |l| lines << l } }
|
77
76
|
end
|
@@ -80,24 +79,24 @@ class TC_FileTail < Test::Unit::TestCase
|
|
80
79
|
|
81
80
|
def test_tail_with_block_with_n
|
82
81
|
timeout(10) do
|
83
|
-
@in.
|
82
|
+
@in.backward(1)
|
84
83
|
lines = []
|
85
84
|
timeout(1) { @in.tail(0) { |l| lines << l } }
|
86
85
|
assert_equal(0, lines.size)
|
87
86
|
#
|
88
|
-
@in.
|
87
|
+
@in.backward(1)
|
89
88
|
lines = []
|
90
89
|
timeout(1) { @in.tail(1) { |l| lines << l } }
|
91
90
|
assert_equal(1, lines.size)
|
92
91
|
#
|
93
|
-
@in.
|
92
|
+
@in.backward(10)
|
94
93
|
lines = []
|
95
94
|
timeout(1) { @in.tail(10) { |l| lines << l } }
|
96
95
|
assert_equal(10, lines.size)
|
97
96
|
#
|
98
|
-
@in.
|
97
|
+
@in.backward(100)
|
99
98
|
lines = []
|
100
|
-
@in.
|
99
|
+
@in.backward(1)
|
101
100
|
assert_raises(TimeoutError) do
|
102
101
|
timeout(1) { @in.tail(2) { |l| lines << l } }
|
103
102
|
end
|
@@ -108,24 +107,24 @@ class TC_FileTail < Test::Unit::TestCase
|
|
108
107
|
|
109
108
|
def test_tail_without_block_with_n
|
110
109
|
timeout(10) do
|
111
|
-
@in.
|
110
|
+
@in.backward(1)
|
112
111
|
lines = []
|
113
112
|
timeout(1) { lines += @in.tail(0) }
|
114
113
|
assert_equal(0, lines.size)
|
115
114
|
#
|
116
|
-
@in.
|
115
|
+
@in.backward(1)
|
117
116
|
lines = []
|
118
117
|
timeout(1) { lines += @in.tail(1) }
|
119
118
|
assert_equal(1, lines.size)
|
120
119
|
#
|
121
|
-
@in.
|
120
|
+
@in.backward(10)
|
122
121
|
lines = []
|
123
122
|
timeout(1) { lines += @in.tail(10) }
|
124
123
|
assert_equal(10, lines.size)
|
125
124
|
#
|
126
|
-
@in.
|
125
|
+
@in.backward(100)
|
127
126
|
lines = []
|
128
|
-
@in.
|
127
|
+
@in.backward(1)
|
129
128
|
assert_raises(TimeoutError) do
|
130
129
|
timeout(1) { lines += @in.tail(2) }
|
131
130
|
end
|
@@ -134,7 +133,7 @@ class TC_FileTail < Test::Unit::TestCase
|
|
134
133
|
end
|
135
134
|
|
136
135
|
def test_tail_withappend
|
137
|
-
@in.
|
136
|
+
@in.backward
|
138
137
|
lines = []
|
139
138
|
threads = []
|
140
139
|
threads << Thread.new do
|
@@ -149,7 +148,7 @@ class TC_FileTail < Test::Unit::TestCase
|
|
149
148
|
end
|
150
149
|
|
151
150
|
def test_tail_truncated
|
152
|
-
@in.
|
151
|
+
@in.backward
|
153
152
|
lines = []
|
154
153
|
threads = []
|
155
154
|
threads << appender = Thread.new do
|
@@ -176,7 +175,7 @@ class TC_FileTail < Test::Unit::TestCase
|
|
176
175
|
|
177
176
|
def test_tail_remove
|
178
177
|
return if File::PATH_SEPARATOR == ';' # Grmpf! Windows...
|
179
|
-
@in.
|
178
|
+
@in.backward
|
180
179
|
lines = []
|
181
180
|
threads = []
|
182
181
|
threads << appender = Thread.new do
|
@@ -222,6 +221,5 @@ class TC_FileTail < Test::Unit::TestCase
|
|
222
221
|
(1..n).each { |x| file << "#{x} #{"A" * 70}\n" }
|
223
222
|
file.flush
|
224
223
|
end
|
225
|
-
|
226
224
|
end
|
227
225
|
# vim: set noet sw=2 ts=2:
|
metadata
CHANGED
@@ -1,52 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: file-tail
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date:
|
6
|
+
version: 0.1.4
|
7
|
+
date: 2007-02-08 00:00:00 +01:00
|
8
8
|
summary: File::Tail for Ruby
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: flori@ping.de
|
12
12
|
homepage: http://file-tail.rubyforge.org
|
13
13
|
rubyforge_project: file-tail
|
14
|
-
description:
|
15
|
-
autorequire:
|
14
|
+
description: Library to tail files in Ruby
|
15
|
+
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
27
28
|
authors:
|
28
|
-
|
29
|
+
- Florian Frank
|
29
30
|
files:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
31
|
+
- VERSION
|
32
|
+
- tests
|
33
|
+
- GPL
|
34
|
+
- README.en
|
35
|
+
- install.rb
|
36
|
+
- Rakefile
|
37
|
+
- examples
|
38
|
+
- lib
|
39
|
+
- CHANGES
|
40
|
+
- tests/test_file-tail.rb
|
41
|
+
- examples/pager.rb
|
42
|
+
- examples/tail.rb
|
43
|
+
- lib/file
|
44
|
+
- lib/file/tail.rb
|
45
|
+
test_files: &id001 []
|
46
|
+
|
47
|
+
rdoc_options:
|
48
|
+
- --title
|
49
|
+
- File::Tail
|
50
|
+
- *id001
|
51
|
+
- tests/test_file-tail.rb
|
48
52
|
extra_rdoc_files: []
|
53
|
+
|
49
54
|
executables: []
|
55
|
+
|
50
56
|
extensions: []
|
57
|
+
|
51
58
|
requirements: []
|
52
|
-
|
59
|
+
|
60
|
+
dependencies: []
|
61
|
+
|