file-tail 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/README +55 -12
- data/Rakefile +23 -31
- data/VERSION +1 -1
- data/bin/rtail +67 -0
- data/lib/file/tail.rb +1 -1
- data/lib/file/tail/version.rb +1 -1
- data/make_doc.rb +1 -1
- metadata +27 -17
- data/doc-main.txt +0 -54
- data/file-tail.gemspec +0 -21
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
2010-03-25 * 1.0.5 * Added rtail executable, a nice app to supervise logfiles
|
2
|
+
and logdirs.
|
3
|
+
* Disabled creation of gem spec file.
|
4
|
+
* Cleaned up documentation a bit.
|
1
5
|
2009-08-21 * 1.0.4 * Fixed the threaded tests for Ruby 1.9.
|
2
6
|
* Create a gem spec file.
|
3
7
|
* Some cleanup.
|
data/README
CHANGED
@@ -1,7 +1,25 @@
|
|
1
|
-
|
2
|
-
============
|
1
|
+
== Description
|
3
2
|
|
4
|
-
|
3
|
+
This is a small ruby library that allows it to "tail" files in Ruby, including
|
4
|
+
following a file, that still is growing like the unix command 'tail -f' can.
|
5
|
+
|
6
|
+
== Download
|
7
|
+
|
8
|
+
The latest version of <b>File::Tail</b> (file-tail) can be found at
|
9
|
+
|
10
|
+
http://www.ping.de/~flori
|
11
|
+
|
12
|
+
Online Documentation should be located at
|
13
|
+
|
14
|
+
http://flori.github.com/file-tail
|
15
|
+
|
16
|
+
== Installation
|
17
|
+
|
18
|
+
To install file-tail via its gem type:
|
19
|
+
|
20
|
+
# gem install file-tail
|
21
|
+
|
22
|
+
To install from the source repository, just type into the command line as root:
|
5
23
|
|
6
24
|
# rake install
|
7
25
|
|
@@ -9,8 +27,34 @@ or
|
|
9
27
|
|
10
28
|
# ruby install.rb
|
11
29
|
|
12
|
-
|
13
|
-
|
30
|
+
== Usage
|
31
|
+
|
32
|
+
File::Tail is a module in the File class. A lightweight class interface for
|
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
|
+
|
57
|
+
== Documentation
|
14
58
|
|
15
59
|
To create the documentation of this module, type
|
16
60
|
|
@@ -26,13 +70,12 @@ In the examples direcotry is a small example of tail and
|
|
26
70
|
pager program that use this module. You also may want look
|
27
71
|
at the end of file/tail.rb for a little example.
|
28
72
|
|
29
|
-
Author
|
30
|
-
======
|
31
|
-
|
32
|
-
Florian Frank <flori@ping.de>
|
73
|
+
== Author
|
33
74
|
|
34
|
-
|
35
|
-
=======
|
75
|
+
Florian Frank mailto:flori@ping.de
|
36
76
|
|
37
|
-
|
77
|
+
== License
|
38
78
|
|
79
|
+
This is free software; you can redistribute it and/or modify it under
|
80
|
+
the terms of the GNU General Public License Version 2 as published by
|
81
|
+
the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
|
data/Rakefile
CHANGED
@@ -34,38 +34,30 @@ task :coverage do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
if defined? Gem
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
s.author = "Florian Frank"
|
55
|
-
s.email = "flori@ping.de"
|
56
|
-
s.homepage = "http://#{PKG_NAME}.rubyforge.org"
|
57
|
-
s.rubyforge_project = "#{PKG_NAME}"
|
58
|
-
end
|
59
|
-
GEM
|
37
|
+
spec = Gem::Specification.new do |s|
|
38
|
+
s.name = PKG_NAME
|
39
|
+
s.version = PKG_VERSION
|
40
|
+
s.summary = "File::Tail for Ruby"
|
41
|
+
s.description = "Library to tail files in Ruby"
|
42
|
+
|
43
|
+
s.executables = 'rtail'
|
44
|
+
s.files = PKG_FILES
|
45
|
+
|
46
|
+
s.require_path = 'lib'
|
47
|
+
|
48
|
+
s.add_dependency 'spruz', '>=0.1.0'
|
49
|
+
|
50
|
+
s.has_rdoc = true
|
51
|
+
s.rdoc_options << '--main' << 'README' << '--title' << 'File::Tail - Tailing files in Ruby'
|
52
|
+
s.extra_rdoc_files << 'README'
|
53
|
+
s.test_files << 'tests/test_file-tail.rb'
|
60
54
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
55
|
+
s.author = "Florian Frank"
|
56
|
+
s.email = "flori@ping.de"
|
57
|
+
s.homepage = "http://flori.github.com/#{PKG_NAME}"
|
58
|
+
s.rubyforge_project = PKG_NAME
|
66
59
|
end
|
67
60
|
|
68
|
-
spec = eval(spec_src)
|
69
61
|
Rake::GemPackageTask.new(spec) do |pkg|
|
70
62
|
pkg.need_tar = true
|
71
63
|
pkg.package_files += PKG_FILES
|
@@ -91,6 +83,6 @@ EOT
|
|
91
83
|
end
|
92
84
|
end
|
93
85
|
|
94
|
-
task :default => [ :version, :
|
86
|
+
task :default => [ :version, :test ]
|
95
87
|
|
96
|
-
task :release => [ :clean, :version, :
|
88
|
+
task :release => [ :clean, :version, :package ]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.5
|
data/bin/rtail
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'file/tail'
|
4
|
+
require 'spruz/go'
|
5
|
+
include Spruz::GO
|
6
|
+
require 'thread'
|
7
|
+
Thread.abort_on_exception = true
|
8
|
+
|
9
|
+
$opt = go 'm:h'
|
10
|
+
if $opt['h']
|
11
|
+
puts <<EOT
|
12
|
+
Usage: #{File.basename($0)} [OPTS] PATHES
|
13
|
+
|
14
|
+
OPTS are
|
15
|
+
-m PATTERN only tail files matching PATTERN, e. g. '*.log'
|
16
|
+
-h to display this help
|
17
|
+
|
18
|
+
EOT
|
19
|
+
end
|
20
|
+
|
21
|
+
dirs, logfiles = ARGV.partition { |path| File.directory?(path) }
|
22
|
+
$log_threads = {}
|
23
|
+
$log_mutex = Mutex.new
|
24
|
+
|
25
|
+
def add_log(logfile)
|
26
|
+
logfile = File.expand_path logfile
|
27
|
+
$log_threads.key?(logfile) and return
|
28
|
+
warn "Tailing '#{logfile}'."
|
29
|
+
$log_threads[logfile] = Thread.new do
|
30
|
+
File.open(logfile) do |l|
|
31
|
+
l.sync = true
|
32
|
+
l.extend File::Tail
|
33
|
+
l.backward
|
34
|
+
l.tail do |line|
|
35
|
+
$log_mutex.synchronize do
|
36
|
+
print line
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_logs(logfiles)
|
44
|
+
for l in logfiles
|
45
|
+
if $opt['m']
|
46
|
+
File.fnmatch?($opt['m'], l) and add_log l
|
47
|
+
else
|
48
|
+
add_log l
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
add_logs(logfiles)
|
54
|
+
|
55
|
+
begin
|
56
|
+
loop do
|
57
|
+
for d in dirs
|
58
|
+
logfiles = Dir[File.join(d, '*')].select do |x|
|
59
|
+
File.file?(x) || File.symlink?(x)
|
60
|
+
end
|
61
|
+
add_logs logfiles
|
62
|
+
end
|
63
|
+
sleep 1
|
64
|
+
end
|
65
|
+
rescue Interrupt
|
66
|
+
warn " *** Interrupted *** "
|
67
|
+
end
|
data/lib/file/tail.rb
CHANGED
data/lib/file/tail/version.rb
CHANGED
data/make_doc.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-tail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -9,41 +9,51 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-03-25 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: spruz
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.0
|
24
|
+
version:
|
16
25
|
description: Library to tail files in Ruby
|
17
26
|
email: flori@ping.de
|
18
|
-
executables:
|
19
|
-
|
27
|
+
executables:
|
28
|
+
- rtail
|
20
29
|
extensions: []
|
21
30
|
|
22
31
|
extra_rdoc_files:
|
23
|
-
-
|
32
|
+
- README
|
24
33
|
files:
|
25
34
|
- CHANGES
|
26
|
-
-
|
35
|
+
- bin/rtail
|
36
|
+
- VERSION
|
27
37
|
- README
|
38
|
+
- make_doc.rb
|
28
39
|
- Rakefile
|
29
|
-
- VERSION
|
30
40
|
- examples/pager.rb
|
31
41
|
- examples/tail.rb
|
32
|
-
- file-tail.gemspec
|
33
|
-
- install.rb
|
34
|
-
- lib/file/tail.rb
|
35
42
|
- lib/file/tail/version.rb
|
36
|
-
-
|
43
|
+
- lib/file/tail.rb
|
37
44
|
- tests/test_file-tail.rb
|
38
|
-
-
|
45
|
+
- COPYING
|
46
|
+
- install.rb
|
39
47
|
has_rdoc: true
|
40
|
-
homepage: http://file-tail
|
48
|
+
homepage: http://flori.github.com/file-tail
|
41
49
|
licenses: []
|
42
50
|
|
43
51
|
post_install_message:
|
44
52
|
rdoc_options:
|
45
53
|
- --main
|
46
|
-
-
|
54
|
+
- README
|
55
|
+
- --title
|
56
|
+
- File::Tail - Tailing files in Ruby
|
47
57
|
require_paths:
|
48
58
|
- lib
|
49
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -61,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
71
|
requirements: []
|
62
72
|
|
63
73
|
rubyforge_project: file-tail
|
64
|
-
rubygems_version: 1.3.
|
74
|
+
rubygems_version: 1.3.5
|
65
75
|
signing_key:
|
66
76
|
specification_version: 3
|
67
77
|
summary: File::Tail for Ruby
|
data/doc-main.txt
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
== File::Tail - Tailing files in Ruby
|
2
|
-
|
3
|
-
=== Description
|
4
|
-
|
5
|
-
This is a small ruby library that allows it to "tail" files in Ruby,
|
6
|
-
including following a file, that still is growing like the unix command 'tail
|
7
|
-
-f' can.
|
8
|
-
|
9
|
-
=== Author
|
10
|
-
|
11
|
-
Florian Frank mailto:flori@ping.de
|
12
|
-
|
13
|
-
=== License
|
14
|
-
|
15
|
-
This is free software; you can redistribute it and/or modify it under
|
16
|
-
the terms of the GNU General Public License Version 2 as published by
|
17
|
-
the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
|
18
|
-
|
19
|
-
=== Download
|
20
|
-
|
21
|
-
The latest version of <b>File::Tail</b> (file-tail) can be found at
|
22
|
-
|
23
|
-
http://rubyforge.org/frs/?group_id=393
|
24
|
-
|
25
|
-
Online Documentation should be located at
|
26
|
-
|
27
|
-
http://file-tail.rubyforge.org
|
28
|
-
|
29
|
-
=== Usage
|
30
|
-
|
31
|
-
File::Tail is a module in the File class. A lightweight class interface for
|
32
|
-
logfiles can be seen under File::Tail::Logfile.
|
33
|
-
|
34
|
-
Direct extension of File objects with File::Tail works like that:
|
35
|
-
File.open(filename) do |log|
|
36
|
-
log.extend(File::Tail)
|
37
|
-
log.interval = 10
|
38
|
-
log.backward(10)
|
39
|
-
log.tail { |line| puts line }
|
40
|
-
end
|
41
|
-
|
42
|
-
It's also possible to mix File::Tail in your own File classes
|
43
|
-
(see also File::Tail::Logfile):
|
44
|
-
class MyFile < File
|
45
|
-
include File::Tail
|
46
|
-
end
|
47
|
-
log = MyFile.new("myfile")
|
48
|
-
log.interval = 10
|
49
|
-
log.backward(10)
|
50
|
-
log.tail { |line| print line }
|
51
|
-
|
52
|
-
The forward/backward method returns self, so it's possible to chain
|
53
|
-
methods together like that:
|
54
|
-
log.backward(10).tail { |line| puts line }
|
data/file-tail.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
Gem::Specification.new do |s|
|
3
|
-
s.name = 'file-tail'
|
4
|
-
s.version = '1.0.4'
|
5
|
-
s.summary = "File::Tail for Ruby"
|
6
|
-
s.description = "Library to tail files in Ruby"
|
7
|
-
|
8
|
-
s.files = ["CHANGES", "COPYING", "README", "Rakefile", "VERSION", "examples", "examples/pager.rb", "examples/tail.rb", "file-tail.gemspec", "install.rb", "lib", "lib/file", "lib/file/tail", "lib/file/tail.rb", "lib/file/tail/version.rb", "make_doc.rb", "tests", "tests/test_file-tail.rb"]
|
9
|
-
|
10
|
-
s.require_path = 'lib'
|
11
|
-
|
12
|
-
s.has_rdoc = true
|
13
|
-
s.rdoc_options << '--main' << 'doc-main.txt'
|
14
|
-
s.extra_rdoc_files << 'doc-main.txt'
|
15
|
-
s.test_files << 'tests/test_file-tail.rb'
|
16
|
-
|
17
|
-
s.author = "Florian Frank"
|
18
|
-
s.email = "flori@ping.de"
|
19
|
-
s.homepage = "http://file-tail.rubyforge.org"
|
20
|
-
s.rubyforge_project = "file-tail"
|
21
|
-
end
|