file-tail 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 2007-04-19 * 1.0.1 * Bugfix: File::Tail::Logfile#open with block, now closes
2
+ the file like File#open does. Found by Alex Doan
3
+ <alex.doan@wachovia.com>, ruby-talk:248383.
1
4
  2007-03-30 * 1.0.0 * Bugfix: David.Barzilay@swisscom.com reported, that file
2
5
  tails may skip some log file lines, after rotating it. I
3
6
  think, І fixed that problem.
data/Rakefile CHANGED
@@ -79,4 +79,4 @@ EOT
79
79
  end
80
80
  end
81
81
 
82
- task :release => [ :clean, :package ]
82
+ task :release => [ :clean, :version, :package ]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -1,63 +1,61 @@
1
- #
2
1
  require 'file/tail/version'
3
- # = File::Tail - Tailing files in Ruby
4
- #
5
- # == Description
6
- #
7
- # This is a small ruby library that allows it to "tail" files in Ruby,
8
- # including following a file, that still is growing like the unix command 'tail
9
- # -f' can.
10
- #
11
- # == Author
12
- #
13
- # Florian Frank mailto:flori@ping.de
14
- #
15
- # == License
16
- #
17
- # This is free software; you can redistribute it and/or modify it under
18
- # the terms of the GNU General Public License Version 2 as published by
19
- # the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
20
- #
21
- # == Download
22
- #
23
- # The latest version of <b>File::Tail</b> (file-tail) can be found at
24
- #
25
- # http://rubyforge.org/frs/?group_id=393
26
- #
27
- # Online Documentation should be located at
28
- #
29
- # http://file-tail.rubyforge.org
30
- #
31
- # == Usage
32
- #
33
- # File::Tail is a module in the File class. A lightweight class interface for
34
- # logfiles can be seen under File::Tail::Logfile.
35
- #
36
- # Direct extension of File objects with File::Tail works like that:
37
- # File.open(filename) do |log|
38
- # log.extend(File::Tail)
39
- # log.interval = 10
40
- # log.backward(10)
41
- # log.tail { |line| puts line }
42
- # end
43
- #
44
- # It's also possible to mix File::Tail in your own File classes
45
- # (see also File::Tail::Logfile):
46
- # class MyFile < File
47
- # include File::Tail
48
- # end
49
- # log = MyFile.new("myfile")
50
- # log.interval = 10
51
- # log.backward(10)
52
- # log.tail { |line| print line }
53
- #
54
- # The forward/backward method returns self, so it's possible to chain
55
- # methods together like that:
56
- # log.backward(10).tail { |line| puts line }
57
- #
2
+
58
3
  class File
59
- # The File::Tail module can be included in File objects and mixes in
60
- # the forward, backward and tail methods.
4
+ # = File::Tail - Tailing files in Ruby
5
+ #
6
+ # == Description
7
+ #
8
+ # This is a small ruby library that allows it to "tail" files in Ruby,
9
+ # including following a file, that still is growing like the unix command 'tail
10
+ # -f' can.
11
+ #
12
+ # == Author
13
+ #
14
+ # Florian Frank mailto:flori@ping.de
15
+ #
16
+ # == License
17
+ #
18
+ # This is free software; you can redistribute it and/or modify it under
19
+ # the terms of the GNU General Public License Version 2 as published by
20
+ # the Free Software Foundation: http://www.gnu.org/copyleft/gpl.html
21
+ #
22
+ # == Download
23
+ #
24
+ # The latest version of <b>File::Tail</b> (file-tail) can be found at
25
+ #
26
+ # http://rubyforge.org/frs/?group_id=393
27
+ #
28
+ # Online Documentation should be located at
29
+ #
30
+ # http://file-tail.rubyforge.org
31
+ #
32
+ # == Usage
33
+ #
34
+ # File::Tail is a module in the File class. A lightweight class interface for
35
+ # logfiles can be seen under File::Tail::Logfile.
36
+ #
37
+ # Direct extension of File objects with File::Tail works like that:
38
+ # File.open(filename) do |log|
39
+ # log.extend(File::Tail)
40
+ # log.interval = 10
41
+ # log.backward(10)
42
+ # log.tail { |line| puts line }
43
+ # end
44
+ #
45
+ # It's also possible to mix File::Tail in your own File classes
46
+ # (see also File::Tail::Logfile):
47
+ # class MyFile < File
48
+ # include File::Tail
49
+ # end
50
+ # log = MyFile.new("myfile")
51
+ # log.interval = 10
52
+ # log.backward(10)
53
+ # log.tail { |line| print line }
54
+ #
55
+ # The forward/backward method returns self, so it's possible to chain
56
+ # methods together like that:
57
+ # log.backward(10).tail { |line| puts line }
58
+ #
61
59
  module Tail
62
60
  # This is an easy to use Logfile class that includes
63
61
  # the File::Tail module.
@@ -86,7 +84,7 @@ class File
86
84
  include File::Tail
87
85
 
88
86
  # This method creates an File::Tail::Logfile object and
89
- # yields to it if a block is given, otherwise it just
87
+ # yields to it, and closes it, if a block is given, otherwise it just
90
88
  # returns it. The opts hash takes an option like
91
89
  # * <code>:backward => 10</code> to go backwards
92
90
  # * <code>:forward => 10</code> to go forwards
@@ -116,11 +114,15 @@ class File
116
114
  file.forward(forward)
117
115
  end
118
116
  if opts[:after_reopen]
119
- file.after_reopen &opts[:after_reopen]
117
+ file.after_reopen(&opts[:after_reopen])
120
118
  end
121
119
  if block_given?
122
- yield file
123
- nil
120
+ begin
121
+ yield file
122
+ ensure
123
+ file.close
124
+ nil
125
+ end
124
126
  else
125
127
  file
126
128
  end
@@ -1,7 +1,7 @@
1
1
  class File
2
2
  module Tail
3
3
  # File::Tail version
4
- VERSION = '0.1.5'
4
+ VERSION = '1.0.1'
5
5
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
6
6
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
7
7
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: file-tail
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-04-01 00:00:00 +02:00
6
+ version: 1.0.1
7
+ date: 2007-04-19 00:00:00 +02:00
8
8
  summary: File::Tail for Ruby
9
9
  require_paths:
10
10
  - lib
@@ -42,8 +42,8 @@ files:
42
42
  - examples/pager.rb
43
43
  - examples/tail.rb
44
44
  - lib/file
45
- - lib/file/tail
46
45
  - lib/file/tail.rb
46
+ - lib/file/tail
47
47
  - lib/file/tail/version.rb
48
48
  test_files:
49
49
  - tests/test_file-tail.rb